extra-iterator 0.9.0 → 0.9.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +4 -4
- package/dist/index.js +1 -1
- package/dist/index.test.js +2 -2
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -106,7 +106,7 @@ export declare class ExtraIterator<T> extends Iterator<T, any, any> {
|
|
|
106
106
|
* .toArray()
|
|
107
107
|
* // returns [1, 2, 3, 4]
|
|
108
108
|
*/
|
|
109
|
-
append(item:
|
|
109
|
+
append<U>(item: U): ExtraIterator<T | U>;
|
|
110
110
|
/**
|
|
111
111
|
* Prepends a new value to the beginning of the iterator. The new value will be yielded first, then the rest of this
|
|
112
112
|
* iterator will be yielded.
|
|
@@ -118,7 +118,7 @@ export declare class ExtraIterator<T> extends Iterator<T, any, any> {
|
|
|
118
118
|
* .toArray()
|
|
119
119
|
* // returns [0, 1, 2, 3]
|
|
120
120
|
*/
|
|
121
|
-
prepend(item:
|
|
121
|
+
prepend<U>(item: U): ExtraIterator<T | U>;
|
|
122
122
|
/**
|
|
123
123
|
* Concatenates multiple values to the end of this iterator.
|
|
124
124
|
*
|
|
@@ -129,7 +129,7 @@ export declare class ExtraIterator<T> extends Iterator<T, any, any> {
|
|
|
129
129
|
* .toArray()
|
|
130
130
|
* // returns [1, 2, 3, 4, 5, 6]
|
|
131
131
|
*/
|
|
132
|
-
concat(items: Iterable<
|
|
132
|
+
concat<U>(items: Iterable<U>): ExtraIterator<T | U>;
|
|
133
133
|
/**
|
|
134
134
|
* Concatenates multiple values to the start of this iterator.
|
|
135
135
|
*
|
|
@@ -144,7 +144,7 @@ export declare class ExtraIterator<T> extends Iterator<T, any, any> {
|
|
|
144
144
|
* .toArray()
|
|
145
145
|
* // returns [1, 2, 3, 4, 5, 6]
|
|
146
146
|
*/
|
|
147
|
-
prependMany(items: Iterable<
|
|
147
|
+
prependMany<U>(items: Iterable<U>): ExtraIterator<T | U>;
|
|
148
148
|
/**
|
|
149
149
|
* Creates a new iterator that invokes the provided callback function over each element of this iterator and yields
|
|
150
150
|
* the elements for which the callback returns `true`, only for as long as the callback returns `true`.
|
package/dist/index.js
CHANGED
|
@@ -137,7 +137,7 @@ export class ExtraIterator extends Iterator {
|
|
|
137
137
|
* @example ExtraIterator.from([[1, 2], [3, 4]]).flatten().toArray() // returns [1, 2, 3, 4]
|
|
138
138
|
*/
|
|
139
139
|
flatten() {
|
|
140
|
-
return this.flatMap(value => value);
|
|
140
|
+
return this.flatMap(value => Array.isArray(value) ? new ExtraIterator(value).flatten() : [value]);
|
|
141
141
|
}
|
|
142
142
|
/**
|
|
143
143
|
* Creates a new iterator that yields the values of this iterator, but won't yield any duplicates.
|
package/dist/index.test.js
CHANGED
|
@@ -47,8 +47,8 @@ describe('ExtraIterator', () => {
|
|
|
47
47
|
expect(iterator.toArray()).toEqual([3, 4]);
|
|
48
48
|
});
|
|
49
49
|
it('should flatten nested iterables', () => {
|
|
50
|
-
const iterator = ExtraIterator.from([[1, 2
|
|
51
|
-
expect(iterator.toArray()).toEqual([1, 2, 3, 4]);
|
|
50
|
+
const iterator = ExtraIterator.from([0, [1, [2, [3, 4]]], [5, [6]], 7]).flatten();
|
|
51
|
+
expect(iterator.toArray()).toEqual([0, 1, 2, 3, 4, 5, 6, 7]);
|
|
52
52
|
});
|
|
53
53
|
it('should return the first value', () => {
|
|
54
54
|
const iterator = ExtraIterator.from([1, 2, 3]);
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"description": "An extension of the Iterator class with additional utility helper functions.",
|
|
4
4
|
"author": "Leonardo Raele <leonardoraele@gmail.com>",
|
|
5
5
|
"license": "MIT",
|
|
6
|
-
"version": "0.9.
|
|
6
|
+
"version": "0.9.2",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"exports": {
|
|
9
9
|
".": "./dist/index.js",
|