Skip to content

Commit

Permalink
Added \ method to Object
Browse files Browse the repository at this point in the history
  • Loading branch information
HalidOdat committed Aug 5, 2020
1 parent 8ea3fcd commit d0e1c2b
Showing 1 changed file with 36 additions and 1 deletion.
37 changes: 36 additions & 1 deletion boa/src/builtins/object/iter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,18 @@ impl Object {
}

#[inline]
pub fn indexe_keys(&self) -> IndexKeys<'_> {
pub fn index_keys(&self) -> IndexKeys<'_> {
IndexKeys {
indexes: self.indexed_properties.keys(),
}
}

#[inline]
pub fn index_values(&self) -> IndexValues<'_> {
IndexValues {
indexes: self.indexed_properties.values(),
}
}
}

#[derive(Debug, Clone)]
Expand Down Expand Up @@ -267,3 +274,31 @@ impl ExactSizeIterator for IndexKeys<'_> {
}

impl FusedIterator for IndexKeys<'_> {}

#[derive(Debug, Clone)]
pub struct IndexValues<'a> {
indexes: hash_map::Values<'a, u32, Property>,
}

impl<'a> Iterator for IndexValues<'a> {
type Item = &'a Property;

#[inline]
fn next(&mut self) -> Option<Self::Item> {
self.indexes.next()
}

#[inline]
fn size_hint(&self) -> (usize, Option<usize>) {
self.indexes.size_hint()
}
}

impl ExactSizeIterator for IndexValues<'_> {
#[inline]
fn len(&self) -> usize {
self.indexes.len()
}
}

impl FusedIterator for IndexValues<'_> {}

0 comments on commit d0e1c2b

Please sign in to comment.