File tree 1 file changed +19
-15
lines changed
1 file changed +19
-15
lines changed Original file line number Diff line number Diff line change @@ -55,22 +55,26 @@ function createIterableMethod(
55
55
)
56
56
// return a wrapped iterator which returns observed versions of the
57
57
// values emitted from the real iterator
58
- return {
59
- // iterator protocol
60
- next ( ) {
61
- const { value, done } = innerIterator . next ( )
62
- return done
63
- ? { value, done }
64
- : {
65
- value : isPair ? [ wrap ( value [ 0 ] ) , wrap ( value [ 1 ] ) ] : wrap ( value ) ,
66
- done,
67
- }
68
- } ,
69
- // iterable protocol
70
- [ Symbol . iterator ] ( ) {
71
- return this
58
+ return extend (
59
+ // inheriting all iterator properties
60
+ Object . create ( innerIterator ) ,
61
+ {
62
+ // iterator protocol
63
+ next ( ) {
64
+ const { value, done } = innerIterator . next ( )
65
+ return done
66
+ ? { value, done }
67
+ : {
68
+ value : isPair ? [ wrap ( value [ 0 ] ) , wrap ( value [ 1 ] ) ] : wrap ( value ) ,
69
+ done,
70
+ }
71
+ } ,
72
+ // iterable protocol
73
+ [ Symbol . iterator ] ( ) {
74
+ return this
75
+ } ,
72
76
} ,
73
- }
77
+ )
74
78
}
75
79
}
76
80
You can’t perform that action at this time.
0 commit comments