iter-fest 0.1.1-main.dd552c2 → 0.1.1-main.e1f1fd3
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/README.md +7 -26
- package/dist/chunk-5CRMPYKD.mjs +19 -0
- package/dist/chunk-5CRMPYKD.mjs.map +1 -0
- package/dist/chunk-6C3P4TNK.mjs +19 -0
- package/dist/chunk-6C3P4TNK.mjs.map +1 -0
- package/dist/chunk-EZC33HE6.mjs +15 -0
- package/dist/chunk-EZC33HE6.mjs.map +1 -0
- package/dist/chunk-JU353VSE.mjs +16 -0
- package/dist/chunk-JU353VSE.mjs.map +1 -0
- package/dist/chunk-MNLOWKTC.mjs +19 -0
- package/dist/chunk-MNLOWKTC.mjs.map +1 -0
- package/dist/chunk-XW34KZRY.mjs +17 -0
- package/dist/chunk-XW34KZRY.mjs.map +1 -0
- package/dist/chunk-ZUBHGSCW.mjs +18 -0
- package/dist/chunk-ZUBHGSCW.mjs.map +1 -0
- package/dist/iter-fest.d.mts +7 -12
- package/dist/iter-fest.d.ts +7 -12
- package/dist/iter-fest.iterableEvery.d.mts +24 -0
- package/dist/iter-fest.iterableEvery.d.ts +24 -0
- package/dist/iter-fest.iterableEvery.js +43 -0
- package/dist/iter-fest.iterableEvery.js.map +1 -0
- package/dist/iter-fest.iterableEvery.mjs +7 -0
- package/dist/iter-fest.iterableFilter.d.mts +16 -0
- package/dist/iter-fest.iterableFilter.d.ts +16 -0
- package/dist/iter-fest.iterableFilter.js +42 -0
- package/dist/iter-fest.iterableFilter.js.map +1 -0
- package/dist/iter-fest.iterableFilter.mjs +7 -0
- package/dist/iter-fest.iterableFind.d.mts +15 -0
- package/dist/iter-fest.iterableFind.d.ts +15 -0
- package/dist/iter-fest.iterableFind.js +43 -0
- package/dist/iter-fest.iterableFind.js.map +1 -0
- package/dist/iter-fest.iterableFind.mjs +7 -0
- package/dist/iter-fest.iterableForEach.d.mts +10 -0
- package/dist/iter-fest.iterableForEach.d.ts +10 -0
- package/dist/iter-fest.iterableForEach.js +40 -0
- package/dist/iter-fest.iterableForEach.js.map +1 -0
- package/dist/iter-fest.iterableForEach.mjs +7 -0
- package/dist/iter-fest.iterableMap.d.mts +8 -0
- package/dist/iter-fest.iterableMap.d.ts +8 -0
- package/dist/iter-fest.iterableMap.js +39 -0
- package/dist/iter-fest.iterableMap.js.map +1 -0
- package/dist/iter-fest.iterableMap.mjs +7 -0
- package/dist/{iter-fest.iteratorReduce.d.mts → iter-fest.iterableReduce.d.mts} +9 -13
- package/dist/{iter-fest.iteratorReduce.d.ts → iter-fest.iterableReduce.d.ts} +9 -13
- package/dist/iter-fest.iterableReduce.js +41 -0
- package/dist/iter-fest.iterableReduce.js.map +1 -0
- package/dist/iter-fest.iterableReduce.mjs +7 -0
- package/dist/iter-fest.iterableSome.d.mts +12 -0
- package/dist/iter-fest.iterableSome.d.ts +12 -0
- package/dist/iter-fest.iterableSome.js +43 -0
- package/dist/iter-fest.iterableSome.js.map +1 -0
- package/dist/iter-fest.iterableSome.mjs +7 -0
- package/dist/iter-fest.js +113 -100
- package/dist/iter-fest.js.map +1 -1
- package/dist/iter-fest.mjs +43 -63
- package/package.json +72 -122
- package/dist/chunk-3S6LCGE6.mjs +0 -10
- package/dist/chunk-3S6LCGE6.mjs.map +0 -1
- package/dist/chunk-FBST4AUL.mjs +0 -10
- package/dist/chunk-FBST4AUL.mjs.map +0 -1
- package/dist/chunk-FMIHIL6A.mjs +0 -10
- package/dist/chunk-FMIHIL6A.mjs.map +0 -1
- package/dist/chunk-KYMTQJIJ.mjs +0 -10
- package/dist/chunk-KYMTQJIJ.mjs.map +0 -1
- package/dist/chunk-LIMQXDFK.mjs +0 -10
- package/dist/chunk-LIMQXDFK.mjs.map +0 -1
- package/dist/chunk-OWUGLCQB.mjs +0 -10
- package/dist/chunk-OWUGLCQB.mjs.map +0 -1
- package/dist/chunk-QX6EMOSQ.mjs +0 -10
- package/dist/chunk-QX6EMOSQ.mjs.map +0 -1
- package/dist/chunk-R6SXIXMH.mjs +0 -10
- package/dist/chunk-R6SXIXMH.mjs.map +0 -1
- package/dist/chunk-TDHR35S7.mjs +0 -10
- package/dist/chunk-TDHR35S7.mjs.map +0 -1
- package/dist/chunk-VCKLUCOT.mjs +0 -10
- package/dist/chunk-VCKLUCOT.mjs.map +0 -1
- package/dist/chunk-XQDGXAAF.mjs +0 -10
- package/dist/chunk-XQDGXAAF.mjs.map +0 -1
- package/dist/chunk-YLERARWI.mjs +0 -10
- package/dist/chunk-YLERARWI.mjs.map +0 -1
- package/dist/iter-fest.iteratorDrop.d.mts +0 -12
- package/dist/iter-fest.iteratorDrop.d.ts +0 -12
- package/dist/iter-fest.iteratorDrop.js +0 -44
- package/dist/iter-fest.iteratorDrop.js.map +0 -1
- package/dist/iter-fest.iteratorDrop.mjs +0 -7
- package/dist/iter-fest.iteratorEvery.d.mts +0 -25
- package/dist/iter-fest.iteratorEvery.d.ts +0 -25
- package/dist/iter-fest.iteratorEvery.js +0 -44
- package/dist/iter-fest.iteratorEvery.js.map +0 -1
- package/dist/iter-fest.iteratorEvery.mjs +0 -7
- package/dist/iter-fest.iteratorFilter.d.mts +0 -18
- package/dist/iter-fest.iteratorFilter.d.ts +0 -18
- package/dist/iter-fest.iteratorFilter.js +0 -44
- package/dist/iter-fest.iteratorFilter.js.map +0 -1
- package/dist/iter-fest.iteratorFilter.mjs +0 -7
- package/dist/iter-fest.iteratorFind.d.mts +0 -14
- package/dist/iter-fest.iteratorFind.d.ts +0 -14
- package/dist/iter-fest.iteratorFind.js +0 -44
- package/dist/iter-fest.iteratorFind.js.map +0 -1
- package/dist/iter-fest.iteratorFind.mjs +0 -7
- package/dist/iter-fest.iteratorFlatMap.d.mts +0 -12
- package/dist/iter-fest.iteratorFlatMap.d.ts +0 -12
- package/dist/iter-fest.iteratorFlatMap.js +0 -44
- package/dist/iter-fest.iteratorFlatMap.js.map +0 -1
- package/dist/iter-fest.iteratorFlatMap.mjs +0 -7
- package/dist/iter-fest.iteratorForEach.d.mts +0 -10
- package/dist/iter-fest.iteratorForEach.d.ts +0 -10
- package/dist/iter-fest.iteratorForEach.js +0 -44
- package/dist/iter-fest.iteratorForEach.js.map +0 -1
- package/dist/iter-fest.iteratorForEach.mjs +0 -7
- package/dist/iter-fest.iteratorFrom.d.mts +0 -12
- package/dist/iter-fest.iteratorFrom.d.ts +0 -12
- package/dist/iter-fest.iteratorFrom.js +0 -44
- package/dist/iter-fest.iteratorFrom.js.map +0 -1
- package/dist/iter-fest.iteratorFrom.mjs +0 -7
- package/dist/iter-fest.iteratorMap.d.mts +0 -10
- package/dist/iter-fest.iteratorMap.d.ts +0 -10
- package/dist/iter-fest.iteratorMap.js +0 -44
- package/dist/iter-fest.iteratorMap.js.map +0 -1
- package/dist/iter-fest.iteratorMap.mjs +0 -7
- package/dist/iter-fest.iteratorMap.mjs.map +0 -1
- package/dist/iter-fest.iteratorReduce.js +0 -44
- package/dist/iter-fest.iteratorReduce.js.map +0 -1
- package/dist/iter-fest.iteratorReduce.mjs +0 -7
- package/dist/iter-fest.iteratorReduce.mjs.map +0 -1
- package/dist/iter-fest.iteratorSome.d.mts +0 -10
- package/dist/iter-fest.iteratorSome.d.ts +0 -10
- package/dist/iter-fest.iteratorSome.js +0 -44
- package/dist/iter-fest.iteratorSome.js.map +0 -1
- package/dist/iter-fest.iteratorSome.mjs +0 -7
- package/dist/iter-fest.iteratorSome.mjs.map +0 -1
- package/dist/iter-fest.iteratorTake.d.mts +0 -12
- package/dist/iter-fest.iteratorTake.d.ts +0 -12
- package/dist/iter-fest.iteratorTake.js +0 -44
- package/dist/iter-fest.iteratorTake.js.map +0 -1
- package/dist/iter-fest.iteratorTake.mjs +0 -7
- package/dist/iter-fest.iteratorTake.mjs.map +0 -1
- package/dist/iter-fest.iteratorToArray.d.mts +0 -13
- package/dist/iter-fest.iteratorToArray.d.ts +0 -13
- package/dist/iter-fest.iteratorToArray.js +0 -44
- package/dist/iter-fest.iteratorToArray.js.map +0 -1
- package/dist/iter-fest.iteratorToArray.mjs +0 -7
- package/dist/iter-fest.iteratorToArray.mjs.map +0 -1
- /package/dist/{iter-fest.iteratorDrop.mjs.map → iter-fest.iterableEvery.mjs.map} +0 -0
- /package/dist/{iter-fest.iteratorEvery.mjs.map → iter-fest.iterableFilter.mjs.map} +0 -0
- /package/dist/{iter-fest.iteratorFilter.mjs.map → iter-fest.iterableFind.mjs.map} +0 -0
- /package/dist/{iter-fest.iteratorFind.mjs.map → iter-fest.iterableForEach.mjs.map} +0 -0
- /package/dist/{iter-fest.iteratorFlatMap.mjs.map → iter-fest.iterableMap.mjs.map} +0 -0
- /package/dist/{iter-fest.iteratorForEach.mjs.map → iter-fest.iterableReduce.mjs.map} +0 -0
- /package/dist/{iter-fest.iteratorFrom.mjs.map → iter-fest.iterableSome.mjs.map} +0 -0
package/README.md
CHANGED
|
@@ -224,41 +224,22 @@ const generator = generatorWithLastValue(
|
|
|
224
224
|
);
|
|
225
225
|
```
|
|
226
226
|
|
|
227
|
-
## Adding types to `core-js-pure`
|
|
228
|
-
|
|
229
|
-
We added types to implementation from `core-js-pure`:
|
|
230
|
-
|
|
231
|
-
- [`Iterator.drop`](https://tc39.es/ecma262/#sec-array.prototype.drop)
|
|
232
|
-
- [`Iterator.every`](https://tc39.es/ecma262/#sec-array.prototype.every)
|
|
233
|
-
- [`Iterator.filter`](https://tc39.es/ecma262/#sec-array.prototype.filter)
|
|
234
|
-
- [`Iterator.find`](https://tc39.es/ecma262/#sec-array.prototype.find)
|
|
235
|
-
- [`Iterator.flatMap`](https://tc39.es/ecma262/#sec-array.prototype.flatmap)
|
|
236
|
-
- [`Iterator.forEach`](https://tc39.es/ecma262/#sec-array.prototype.foreach)
|
|
237
|
-
- [`Iterator.from`](https://tc39.es/ecma262/#sec-array.prototype.from)
|
|
238
|
-
- [`Iterator.map`](https://tc39.es/ecma262/#sec-array.prototype.map)
|
|
239
|
-
- [`Iterator.reduce`](https://tc39.es/ecma262/#sec-array.prototype.reduce)
|
|
240
|
-
- [`Iterator.some`](https://tc39.es/ecma262/#sec-array.prototype.some)
|
|
241
|
-
- [`Iterator.take`](https://tc39.es/ecma262/#sec-array.prototype.take)
|
|
242
|
-
- [`Iterator.toArray`](https://tc39.es/ecma262/#sec-array.prototype.toarray)
|
|
243
|
-
|
|
244
227
|
## `Array.prototype` ports
|
|
245
228
|
|
|
246
|
-
> Note: we are working to move them from `iterable*` to `iterator*` to make them similar to TC39 proposals.
|
|
247
|
-
|
|
248
229
|
We ported majority of functions from `Array.prototype.*` to `iterable*`.
|
|
249
230
|
|
|
250
231
|
```ts
|
|
251
|
-
import {
|
|
252
|
-
import {
|
|
232
|
+
import { iterableIncludes, iterableReduce } from 'iter-fest'; // Via default exports.
|
|
233
|
+
import { iterableSome } from 'iter-fest/iterableSome'; // Via named exports.
|
|
253
234
|
|
|
254
|
-
const
|
|
235
|
+
const iterable: Iterable<number> = [1, 2, 3, 4, 5].values();
|
|
255
236
|
|
|
256
|
-
console.log(
|
|
257
|
-
console.log(
|
|
258
|
-
console.log(
|
|
237
|
+
console.log(iterableIncludes(iterable, 3)); // Prints "true".
|
|
238
|
+
console.log(iterableReduce(iterable, (sum, value) => sum + value, 0)); // Prints "15".
|
|
239
|
+
console.log(iterableSome(iterable, value => value % 2)); // Prints "true".
|
|
259
240
|
```
|
|
260
241
|
|
|
261
|
-
List of ported functions: [`at`](https://tc39.es/ecma262/#sec-array.prototype.at), [`concat`](https://tc39.es/ecma262/#sec-array.prototype.concat), [`entries`](https://tc39.es/ecma262/#sec-array.prototype.entries), [`findIndex`](https://tc39.es/ecma262/#sec-array.prototype.findindex), [`findLast`](https://tc39.es/ecma262/#sec-array.prototype.findlast), [`findLastIndex`](https://tc39.es/ecma262/#sec-array.prototype.findlastindex), [`includes`](https://tc39.es/ecma262/#sec-array.prototype.includes), [`indexOf`](https://tc39.es/ecma262/#sec-array.prototype.indexof), [`join`](https://tc39.es/ecma262/#sec-array.prototype.join), [`keys`](https://tc39.es/ecma262/#sec-array.prototype.keys), [`slice`](https://tc39.es/ecma262/#sec-array.prototype.slice), [`toSpliced`](https://tc39.es/ecma262/#sec-array.prototype.tospliced), and [`toString`](https://tc39.es/ecma262/#sec-array.prototype.tostring).
|
|
242
|
+
List of ported functions: [`at`](https://tc39.es/ecma262/#sec-array.prototype.at), [`concat`](https://tc39.es/ecma262/#sec-array.prototype.concat), [`entries`](https://tc39.es/ecma262/#sec-array.prototype.entries), [`every`](https://tc39.es/ecma262/#sec-array.prototype.every), [`filter`](https://tc39.es/ecma262/#sec-array.prototype.filter), [`find`](https://tc39.es/ecma262/#sec-array.prototype.find), [`findIndex`](https://tc39.es/ecma262/#sec-array.prototype.findindex), [`findLast`](https://tc39.es/ecma262/#sec-array.prototype.findlast), [`findLastIndex`](https://tc39.es/ecma262/#sec-array.prototype.findlastindex), [`forEach`](https://tc39.es/ecma262/#sec-array.prototype.foreach), [`includes`](https://tc39.es/ecma262/#sec-array.prototype.includes), [`indexOf`](https://tc39.es/ecma262/#sec-array.prototype.indexof), [`join`](https://tc39.es/ecma262/#sec-array.prototype.join), [`keys`](https://tc39.es/ecma262/#sec-array.prototype.keys), [`map`](https://tc39.es/ecma262/#sec-array.prototype.map), [`reduce`](https://tc39.es/ecma262/#sec-array.prototype.reduce), [`slice`](https://tc39.es/ecma262/#sec-array.prototype.slice), [`some`](https://tc39.es/ecma262/#sec-array.prototype.some), [`toSpliced`](https://tc39.es/ecma262/#sec-array.prototype.tospliced), and [`toString`](https://tc39.es/ecma262/#sec-array.prototype.tostring).
|
|
262
243
|
|
|
263
244
|
## Behaviors
|
|
264
245
|
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// src/iterableEvery.ts
|
|
2
|
+
function iterableEvery(iterable, predicate, thisArg = void 0) {
|
|
3
|
+
let index = 0;
|
|
4
|
+
if (typeof predicate !== "function") {
|
|
5
|
+
throw new TypeError(`${predicate} is not a function`);
|
|
6
|
+
}
|
|
7
|
+
const boundPredicate = predicate.bind(thisArg);
|
|
8
|
+
for (const value of iterable) {
|
|
9
|
+
if (!boundPredicate(value, index++, iterable)) {
|
|
10
|
+
return false;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
return true;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export {
|
|
17
|
+
iterableEvery
|
|
18
|
+
};
|
|
19
|
+
//# sourceMappingURL=chunk-5CRMPYKD.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/iterableEvery.ts"],"sourcesContent":["/**\n * Determines whether all the members of an iterable satisfy the specified test.\n *\n * @param predicate A function that accepts up to three arguments. The every method calls\n * the predicate function for each element in the iterable until the predicate returns a value\n * which is coercible to the Boolean value false, or until the end of the iterable.\n *\n * @param thisArg An object to which the this keyword can refer in the predicate function.\n * If thisArg is omitted, undefined is used as the this value.\n */\nexport function iterableEvery<T, S extends T>(\n iterable: Iterable<T>,\n predicate: (value: T, index: number, iterable: Iterable<T>) => value is S,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n thisArg?: any\n): iterable is S[];\n\n/**\n * Determines whether all the members of an iterable satisfy the specified test.\n *\n * @param predicate A function that accepts up to three arguments. The every method calls\n * the predicate function for each element in the iterable until the predicate returns a value\n * which is coercible to the Boolean value false, or until the end of the iterable.\n *\n * @param thisArg An object to which the this keyword can refer in the predicate function.\n * If thisArg is omitted, undefined is used as the this value.\n */\nexport function iterableEvery<T>(\n iterable: Iterable<T>,\n predicate: (value: T, index: number, iterable: Iterable<T>) => unknown,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n thisArg?: any\n): boolean;\n\nexport function iterableEvery<T>(\n iterable: Iterable<T>,\n predicate: (value: T, index: number, iterable: Iterable<T>) => unknown,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n thisArg: any = undefined\n): boolean {\n let index = 0;\n\n if (typeof predicate !== 'function') {\n throw new TypeError(`${predicate} is not a function`);\n }\n\n const boundPredicate = predicate.bind(thisArg);\n\n for (const value of iterable) {\n if (!boundPredicate(value, index++, iterable)) {\n return false;\n }\n }\n\n return true;\n}\n"],"mappings":";AAkCO,SAAS,cACd,UACA,WAEA,UAAe,QACN;AACT,MAAI,QAAQ;AAEZ,MAAI,OAAO,cAAc,YAAY;AACnC,UAAM,IAAI,UAAU,GAAG,SAAS,oBAAoB;AAAA,EACtD;AAEA,QAAM,iBAAiB,UAAU,KAAK,OAAO;AAE7C,aAAW,SAAS,UAAU;AAC5B,QAAI,CAAC,eAAe,OAAO,SAAS,QAAQ,GAAG;AAC7C,aAAO;AAAA,IACT;AAAA,EACF;AAEA,SAAO;AACT;","names":[]}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// src/iterableSome.ts
|
|
2
|
+
function iterableSome(iterable, predicate, thisArg = void 0) {
|
|
3
|
+
let index = 0;
|
|
4
|
+
if (typeof predicate !== "function") {
|
|
5
|
+
throw new TypeError(`${predicate} is not a function`);
|
|
6
|
+
}
|
|
7
|
+
const boundPredicate = predicate.bind(thisArg);
|
|
8
|
+
for (const value of iterable) {
|
|
9
|
+
if (boundPredicate(value, index++, iterable)) {
|
|
10
|
+
return true;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
return false;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export {
|
|
17
|
+
iterableSome
|
|
18
|
+
};
|
|
19
|
+
//# sourceMappingURL=chunk-6C3P4TNK.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/iterableSome.ts"],"sourcesContent":["/**\n * Determines whether the specified callback function returns true for any element of an iterable.\n *\n * @param predicate\n * A function that accepts up to three arguments. The some method calls the predicate function for each element in the iterable until the predicate returns a value which is coercible to the Boolean value true, or until the end of the iterable.\n *\n * @param thisArg\n * An object to which the this keyword can refer in the predicate function. If thisArg is omitted, undefined is used as the this value.\n */\nexport function iterableSome<T>(\n iterable: Iterable<T>,\n predicate: (value: T, index: number, iterable: Iterable<T>) => unknown,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n thisArg: any = undefined\n): boolean {\n let index = 0;\n\n if (typeof predicate !== 'function') {\n throw new TypeError(`${predicate} is not a function`);\n }\n\n const boundPredicate = predicate.bind(thisArg);\n\n for (const value of iterable) {\n if (boundPredicate(value, index++, iterable)) {\n return true;\n }\n }\n\n return false;\n}\n"],"mappings":";AASO,SAAS,aACd,UACA,WAEA,UAAe,QACN;AACT,MAAI,QAAQ;AAEZ,MAAI,OAAO,cAAc,YAAY;AACnC,UAAM,IAAI,UAAU,GAAG,SAAS,oBAAoB;AAAA,EACtD;AAEA,QAAM,iBAAiB,UAAU,KAAK,OAAO;AAE7C,aAAW,SAAS,UAAU;AAC5B,QAAI,eAAe,OAAO,SAAS,QAAQ,GAAG;AAC5C,aAAO;AAAA,IACT;AAAA,EACF;AAEA,SAAO;AACT;","names":[]}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// src/iterableMap.ts
|
|
2
|
+
function* iterableMap(iterable, callbackfn, thisArg) {
|
|
3
|
+
let index = 0;
|
|
4
|
+
if (typeof callbackfn !== "function") {
|
|
5
|
+
throw new TypeError(`${callbackfn} is not a function`);
|
|
6
|
+
}
|
|
7
|
+
for (const value of iterable) {
|
|
8
|
+
yield callbackfn.call(thisArg, value, index++, iterable);
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export {
|
|
13
|
+
iterableMap
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=chunk-EZC33HE6.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/iterableMap.ts"],"sourcesContent":["/**\n * Calls a defined callback function on each element of an array, and returns an array that contains the results.\n * @param callbackfn A function that accepts up to three arguments. The map method calls the callbackfn function one time for each element in the array.\n * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value.\n */\nexport function* iterableMap<T, U>(\n iterable: Iterable<T>,\n callbackfn: (value: T, index: number, array: Iterable<T>) => U,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n thisArg?: any\n): IterableIterator<U> {\n let index = 0;\n\n if (typeof callbackfn !== 'function') {\n throw new TypeError(`${callbackfn} is not a function`);\n }\n\n for (const value of iterable) {\n yield callbackfn.call(thisArg, value, index++, iterable);\n }\n}\n"],"mappings":";AAKO,UAAU,YACf,UACA,YAEA,SACqB;AACrB,MAAI,QAAQ;AAEZ,MAAI,OAAO,eAAe,YAAY;AACpC,UAAM,IAAI,UAAU,GAAG,UAAU,oBAAoB;AAAA,EACvD;AAEA,aAAW,SAAS,UAAU;AAC5B,UAAM,WAAW,KAAK,SAAS,OAAO,SAAS,QAAQ;AAAA,EACzD;AACF;","names":[]}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// src/iterableForEach.ts
|
|
2
|
+
function iterableForEach(iterable, callbackfn, thisArg) {
|
|
3
|
+
let index = 0;
|
|
4
|
+
if (typeof callbackfn !== "function") {
|
|
5
|
+
throw new TypeError(`${callbackfn} is not a function`);
|
|
6
|
+
}
|
|
7
|
+
const boundCallbackfn = callbackfn.bind(thisArg);
|
|
8
|
+
for (const value of iterable) {
|
|
9
|
+
boundCallbackfn(value, index++, iterable);
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export {
|
|
14
|
+
iterableForEach
|
|
15
|
+
};
|
|
16
|
+
//# sourceMappingURL=chunk-JU353VSE.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/iterableForEach.ts"],"sourcesContent":["/**\n * Performs the specified action for each element in an iterable.\n *\n * @param callbackfn A function that accepts up to three arguments. forEach calls the callbackfn function one time for each element in the iterable.\n *\n * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value.\n */\nexport function iterableForEach<T>(\n iterable: Iterable<T>,\n callbackfn: (value: T, index: number, iterable: Iterable<T>) => void,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n thisArg?: any\n): void {\n let index = 0;\n\n if (typeof callbackfn !== 'function') {\n throw new TypeError(`${callbackfn} is not a function`);\n }\n\n const boundCallbackfn = callbackfn.bind(thisArg);\n\n for (const value of iterable) {\n boundCallbackfn(value, index++, iterable);\n }\n}\n"],"mappings":";AAOO,SAAS,gBACd,UACA,YAEA,SACM;AACN,MAAI,QAAQ;AAEZ,MAAI,OAAO,eAAe,YAAY;AACpC,UAAM,IAAI,UAAU,GAAG,UAAU,oBAAoB;AAAA,EACvD;AAEA,QAAM,kBAAkB,WAAW,KAAK,OAAO;AAE/C,aAAW,SAAS,UAAU;AAC5B,oBAAgB,OAAO,SAAS,QAAQ;AAAA,EAC1C;AACF;","names":[]}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// src/iterableFind.ts
|
|
2
|
+
function iterableFind(iterable, predicate, thisArg) {
|
|
3
|
+
let index = 0;
|
|
4
|
+
if (typeof predicate !== "function") {
|
|
5
|
+
throw new TypeError(`${predicate} is not a function`);
|
|
6
|
+
}
|
|
7
|
+
const boundPredicate = predicate.bind(thisArg);
|
|
8
|
+
for (const value of iterable) {
|
|
9
|
+
if (boundPredicate(value, index++, iterable)) {
|
|
10
|
+
return value;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
return void 0;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export {
|
|
17
|
+
iterableFind
|
|
18
|
+
};
|
|
19
|
+
//# sourceMappingURL=chunk-MNLOWKTC.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/iterableFind.ts"],"sourcesContent":["/**\n * Returns the value of the first element in the iterable where predicate is true, and undefined\n * otherwise.\n *\n * @param predicate find calls predicate once for each element of the iterable, in ascending\n * order, until it finds one where predicate returns true. If such an element is found, find\n * immediately returns that element value. Otherwise, find returns undefined.\n *\n * @param thisArg If provided, it will be used as the this value for each invocation of\n * predicate. If it is not provided, undefined is used instead.\n */\nexport function iterableFind<T, S extends T>(\n iterable: Iterable<T>,\n predicate: (value: T, index: number, obj: Iterable<T>) => value is S,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n thisArg?: any\n): S | undefined;\n\nexport function iterableFind<T>(\n iterable: Iterable<T>,\n predicate: (value: T, index: number, obj: Iterable<T>) => unknown,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n thisArg?: any\n): T | undefined;\n\nexport function iterableFind<T, S extends T>(\n iterable: Iterable<T>,\n predicate: (value: T, index: number, obj: Iterable<T>) => unknown,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n thisArg?: any\n): S | undefined {\n let index = 0;\n\n if (typeof predicate !== 'function') {\n throw new TypeError(`${predicate} is not a function`);\n }\n\n const boundPredicate = predicate.bind(thisArg);\n\n for (const value of iterable) {\n if (boundPredicate(value, index++, iterable)) {\n return value as S;\n }\n }\n\n return undefined;\n}\n"],"mappings":";AAyBO,SAAS,aACd,UACA,WAEA,SACe;AACf,MAAI,QAAQ;AAEZ,MAAI,OAAO,cAAc,YAAY;AACnC,UAAM,IAAI,UAAU,GAAG,SAAS,oBAAoB;AAAA,EACtD;AAEA,QAAM,iBAAiB,UAAU,KAAK,OAAO;AAE7C,aAAW,SAAS,UAAU;AAC5B,QAAI,eAAe,OAAO,SAAS,QAAQ,GAAG;AAC5C,aAAO;AAAA,IACT;AAAA,EACF;AAEA,SAAO;AACT;","names":[]}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// src/iterableReduce.ts
|
|
2
|
+
function iterableReduce(iterable, callbackfn, initialValue) {
|
|
3
|
+
let index = 0;
|
|
4
|
+
let previousValue = initialValue;
|
|
5
|
+
if (typeof callbackfn !== "function") {
|
|
6
|
+
throw new TypeError(`${callbackfn} is not a function`);
|
|
7
|
+
}
|
|
8
|
+
for (const currentValue of iterable) {
|
|
9
|
+
previousValue = callbackfn(previousValue, currentValue, index++, iterable);
|
|
10
|
+
}
|
|
11
|
+
return previousValue;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export {
|
|
15
|
+
iterableReduce
|
|
16
|
+
};
|
|
17
|
+
//# sourceMappingURL=chunk-XW34KZRY.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/iterableReduce.ts"],"sourcesContent":["/**\n * Calls the specified callback function for all the elements in an iterable. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function.\n *\n * @param callbackfn A function that accepts up to four arguments. The reduce method calls the callbackfn function one time for each element in the iterable.\n *\n * @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an iterable value.\n */\nexport function iterableReduce<T>(\n iterable: Iterable<T>,\n callbackfn: (previousValue: T, currentValue: T, currentIndex: number, iterable: Iterable<T>) => T\n): T;\n\nexport function iterableReduce<T>(\n iterable: Iterable<T>,\n callbackfn: (previousValue: T, currentValue: T, currentIndex: number, iterable: Iterable<T>) => T,\n initialValue: T\n): T;\n\n/**\n * Calls the specified callback function for all the elements in an iterable. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function.\n *\n * @param callbackfn A function that accepts up to four arguments. The reduce method calls the callbackfn function one time for each element in the iterable.\n *\n * @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value.\n */\n\nexport function iterableReduce<T, U>(\n iterable: Iterable<T>,\n callbackfn: (previousValue: U, currentValue: T, currentIndex: number, iterable: Iterable<T>) => U,\n initialValue: U\n): U;\n\nexport function iterableReduce<T, U = undefined>(\n iterable: Iterable<T>,\n callbackfn: (previousValue: U | undefined, currentValue: T, currentIndex: number, iterable: Iterable<T>) => U,\n initialValue?: U\n): U | undefined {\n let index = 0;\n let previousValue: U | undefined = initialValue;\n\n if (typeof callbackfn !== 'function') {\n throw new TypeError(`${callbackfn} is not a function`);\n }\n\n for (const currentValue of iterable) {\n previousValue = callbackfn(previousValue, currentValue, index++, iterable);\n }\n\n return previousValue;\n}\n"],"mappings":";AAgCO,SAAS,eACd,UACA,YACA,cACe;AACf,MAAI,QAAQ;AACZ,MAAI,gBAA+B;AAEnC,MAAI,OAAO,eAAe,YAAY;AACpC,UAAM,IAAI,UAAU,GAAG,UAAU,oBAAoB;AAAA,EACvD;AAEA,aAAW,gBAAgB,UAAU;AACnC,oBAAgB,WAAW,eAAe,cAAc,SAAS,QAAQ;AAAA,EAC3E;AAEA,SAAO;AACT;","names":[]}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// src/iterableFilter.ts
|
|
2
|
+
function* iterableFilter(iterable, predicate, thisArg) {
|
|
3
|
+
let index = 0;
|
|
4
|
+
if (typeof predicate !== "function") {
|
|
5
|
+
throw new TypeError(`${predicate} is not a function`);
|
|
6
|
+
}
|
|
7
|
+
const boundPredicate = predicate.bind(thisArg);
|
|
8
|
+
for (const value of iterable) {
|
|
9
|
+
if (boundPredicate(value, index++, iterable)) {
|
|
10
|
+
yield value;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export {
|
|
16
|
+
iterableFilter
|
|
17
|
+
};
|
|
18
|
+
//# sourceMappingURL=chunk-ZUBHGSCW.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/iterableFilter.ts"],"sourcesContent":["/**\n * Returns the elements of an iterable that meet the condition specified in a callback function.\n *\n * @param predicate A function that accepts up to three arguments. The filter method calls the predicate function one time for each element in the iterable.\n * @param thisArg An object to which the this keyword can refer in the predicate function. If thisArg is omitted, undefined is used as the this value.\n */\nexport function iterableFilter<T, S extends T>(\n iterable: Iterable<T>,\n predicate: (value: T, index: number, iterable: Iterable<T>) => value is S,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n thisArg?: unknown\n): IterableIterator<S>;\n\n/**\n * Returns the elements of an iterable that meet the condition specified in a callback function.\n *\n * @param predicate A function that accepts up to three arguments. The filter method calls the predicate function one time for each element in the iterable.\n * @param thisArg An object to which the this keyword can refer in the predicate function. If thisArg is omitted, undefined is used as the this value.\n */\nexport function iterableFilter<T>(\n iterable: Iterable<T>,\n predicate: (value: T, index: number, iterable: Iterable<T>) => unknown,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n thisArg?: any\n): IterableIterator<T>;\n\nexport function* iterableFilter<T, S extends T>(\n iterable: Iterable<T>,\n predicate: (value: T, index: number, iterable: Iterable<T>) => unknown,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n thisArg?: unknown\n): IterableIterator<S> {\n let index = 0;\n\n if (typeof predicate !== 'function') {\n throw new TypeError(`${predicate} is not a function`);\n }\n\n const boundPredicate = predicate.bind(thisArg);\n\n for (const value of iterable) {\n if (boundPredicate(value, index++, iterable)) {\n yield value as S;\n }\n }\n}\n"],"mappings":";AA0BO,UAAU,eACf,UACA,WAEA,SACqB;AACrB,MAAI,QAAQ;AAEZ,MAAI,OAAO,cAAc,YAAY;AACnC,UAAM,IAAI,UAAU,GAAG,SAAS,oBAAoB;AAAA,EACtD;AAEA,QAAM,iBAAiB,UAAU,KAAK,OAAO;AAE7C,aAAW,SAAS,UAAU;AAC5B,QAAI,eAAe,OAAO,SAAS,QAAQ,GAAG;AAC5C,YAAM;AAAA,IACR;AAAA,EACF;AACF;","names":[]}
|
package/dist/iter-fest.d.mts
CHANGED
|
@@ -6,29 +6,24 @@ export { GeneratorWithLastValue, generatorWithLastValue } from './iter-fest.gene
|
|
|
6
6
|
export { iterableAt } from './iter-fest.iterableAt.mjs';
|
|
7
7
|
export { iterableConcat } from './iter-fest.iterableConcat.mjs';
|
|
8
8
|
export { iterableEntries } from './iter-fest.iterableEntries.mjs';
|
|
9
|
+
export { iterableEvery } from './iter-fest.iterableEvery.mjs';
|
|
10
|
+
export { iterableFilter } from './iter-fest.iterableFilter.mjs';
|
|
11
|
+
export { iterableFind } from './iter-fest.iterableFind.mjs';
|
|
9
12
|
export { iterableFindIndex } from './iter-fest.iterableFindIndex.mjs';
|
|
10
13
|
export { iterableFindLast } from './iter-fest.iterableFindLast.mjs';
|
|
11
14
|
export { iterableFindLastIndex } from './iter-fest.iterableFindLastIndex.mjs';
|
|
15
|
+
export { iterableForEach } from './iter-fest.iterableForEach.mjs';
|
|
12
16
|
export { iterableIncludes } from './iter-fest.iterableIncludes.mjs';
|
|
13
17
|
export { iterableIndexOf } from './iter-fest.iterableIndexOf.mjs';
|
|
14
18
|
export { iterableJoin } from './iter-fest.iterableJoin.mjs';
|
|
15
19
|
export { iterableKeys } from './iter-fest.iterableKeys.mjs';
|
|
20
|
+
export { iterableMap } from './iter-fest.iterableMap.mjs';
|
|
21
|
+
export { iterableReduce } from './iter-fest.iterableReduce.mjs';
|
|
16
22
|
export { iterableSlice } from './iter-fest.iterableSlice.mjs';
|
|
23
|
+
export { iterableSome } from './iter-fest.iterableSome.mjs';
|
|
17
24
|
export { iterableToSpliced } from './iter-fest.iterableToSpliced.mjs';
|
|
18
25
|
export { iterableToString } from './iter-fest.iterableToString.mjs';
|
|
19
26
|
export { IterableWritableStream } from './iter-fest.iterableWritableStream.mjs';
|
|
20
|
-
export { iteratorDrop } from './iter-fest.iteratorDrop.mjs';
|
|
21
|
-
export { iteratorEvery } from './iter-fest.iteratorEvery.mjs';
|
|
22
|
-
export { iteratorFilter } from './iter-fest.iteratorFilter.mjs';
|
|
23
|
-
export { iteratorFind } from './iter-fest.iteratorFind.mjs';
|
|
24
|
-
export { iteratorFlatMap } from './iter-fest.iteratorFlatMap.mjs';
|
|
25
|
-
export { iteratorForEach } from './iter-fest.iteratorForEach.mjs';
|
|
26
|
-
export { iteratorFrom } from './iter-fest.iteratorFrom.mjs';
|
|
27
|
-
export { iteratorMap } from './iter-fest.iteratorMap.mjs';
|
|
28
|
-
export { iteratorReduce } from './iter-fest.iteratorReduce.mjs';
|
|
29
|
-
export { iteratorSome } from './iter-fest.iteratorSome.mjs';
|
|
30
|
-
export { iteratorTake } from './iter-fest.iteratorTake.mjs';
|
|
31
|
-
export { iteratorToArray } from './iter-fest.iteratorToArray.mjs';
|
|
32
27
|
export { iteratorToIterable } from './iter-fest.iteratorToIterable.mjs';
|
|
33
28
|
export { observableFromAsync } from './iter-fest.observableFromAsync.mjs';
|
|
34
29
|
export { observableSubscribeAsReadable } from './iter-fest.observableSubscribeAsReadable.mjs';
|
package/dist/iter-fest.d.ts
CHANGED
|
@@ -6,29 +6,24 @@ export { GeneratorWithLastValue, generatorWithLastValue } from './iter-fest.gene
|
|
|
6
6
|
export { iterableAt } from './iter-fest.iterableAt.js';
|
|
7
7
|
export { iterableConcat } from './iter-fest.iterableConcat.js';
|
|
8
8
|
export { iterableEntries } from './iter-fest.iterableEntries.js';
|
|
9
|
+
export { iterableEvery } from './iter-fest.iterableEvery.js';
|
|
10
|
+
export { iterableFilter } from './iter-fest.iterableFilter.js';
|
|
11
|
+
export { iterableFind } from './iter-fest.iterableFind.js';
|
|
9
12
|
export { iterableFindIndex } from './iter-fest.iterableFindIndex.js';
|
|
10
13
|
export { iterableFindLast } from './iter-fest.iterableFindLast.js';
|
|
11
14
|
export { iterableFindLastIndex } from './iter-fest.iterableFindLastIndex.js';
|
|
15
|
+
export { iterableForEach } from './iter-fest.iterableForEach.js';
|
|
12
16
|
export { iterableIncludes } from './iter-fest.iterableIncludes.js';
|
|
13
17
|
export { iterableIndexOf } from './iter-fest.iterableIndexOf.js';
|
|
14
18
|
export { iterableJoin } from './iter-fest.iterableJoin.js';
|
|
15
19
|
export { iterableKeys } from './iter-fest.iterableKeys.js';
|
|
20
|
+
export { iterableMap } from './iter-fest.iterableMap.js';
|
|
21
|
+
export { iterableReduce } from './iter-fest.iterableReduce.js';
|
|
16
22
|
export { iterableSlice } from './iter-fest.iterableSlice.js';
|
|
23
|
+
export { iterableSome } from './iter-fest.iterableSome.js';
|
|
17
24
|
export { iterableToSpliced } from './iter-fest.iterableToSpliced.js';
|
|
18
25
|
export { iterableToString } from './iter-fest.iterableToString.js';
|
|
19
26
|
export { IterableWritableStream } from './iter-fest.iterableWritableStream.js';
|
|
20
|
-
export { iteratorDrop } from './iter-fest.iteratorDrop.js';
|
|
21
|
-
export { iteratorEvery } from './iter-fest.iteratorEvery.js';
|
|
22
|
-
export { iteratorFilter } from './iter-fest.iteratorFilter.js';
|
|
23
|
-
export { iteratorFind } from './iter-fest.iteratorFind.js';
|
|
24
|
-
export { iteratorFlatMap } from './iter-fest.iteratorFlatMap.js';
|
|
25
|
-
export { iteratorForEach } from './iter-fest.iteratorForEach.js';
|
|
26
|
-
export { iteratorFrom } from './iter-fest.iteratorFrom.js';
|
|
27
|
-
export { iteratorMap } from './iter-fest.iteratorMap.js';
|
|
28
|
-
export { iteratorReduce } from './iter-fest.iteratorReduce.js';
|
|
29
|
-
export { iteratorSome } from './iter-fest.iteratorSome.js';
|
|
30
|
-
export { iteratorTake } from './iter-fest.iteratorTake.js';
|
|
31
|
-
export { iteratorToArray } from './iter-fest.iteratorToArray.js';
|
|
32
27
|
export { iteratorToIterable } from './iter-fest.iteratorToIterable.js';
|
|
33
28
|
export { observableFromAsync } from './iter-fest.observableFromAsync.js';
|
|
34
29
|
export { observableSubscribeAsReadable } from './iter-fest.observableSubscribeAsReadable.js';
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Determines whether all the members of an iterable satisfy the specified test.
|
|
3
|
+
*
|
|
4
|
+
* @param predicate A function that accepts up to three arguments. The every method calls
|
|
5
|
+
* the predicate function for each element in the iterable until the predicate returns a value
|
|
6
|
+
* which is coercible to the Boolean value false, or until the end of the iterable.
|
|
7
|
+
*
|
|
8
|
+
* @param thisArg An object to which the this keyword can refer in the predicate function.
|
|
9
|
+
* If thisArg is omitted, undefined is used as the this value.
|
|
10
|
+
*/
|
|
11
|
+
declare function iterableEvery<T, S extends T>(iterable: Iterable<T>, predicate: (value: T, index: number, iterable: Iterable<T>) => value is S, thisArg?: any): iterable is S[];
|
|
12
|
+
/**
|
|
13
|
+
* Determines whether all the members of an iterable satisfy the specified test.
|
|
14
|
+
*
|
|
15
|
+
* @param predicate A function that accepts up to three arguments. The every method calls
|
|
16
|
+
* the predicate function for each element in the iterable until the predicate returns a value
|
|
17
|
+
* which is coercible to the Boolean value false, or until the end of the iterable.
|
|
18
|
+
*
|
|
19
|
+
* @param thisArg An object to which the this keyword can refer in the predicate function.
|
|
20
|
+
* If thisArg is omitted, undefined is used as the this value.
|
|
21
|
+
*/
|
|
22
|
+
declare function iterableEvery<T>(iterable: Iterable<T>, predicate: (value: T, index: number, iterable: Iterable<T>) => unknown, thisArg?: any): boolean;
|
|
23
|
+
|
|
24
|
+
export { iterableEvery };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Determines whether all the members of an iterable satisfy the specified test.
|
|
3
|
+
*
|
|
4
|
+
* @param predicate A function that accepts up to three arguments. The every method calls
|
|
5
|
+
* the predicate function for each element in the iterable until the predicate returns a value
|
|
6
|
+
* which is coercible to the Boolean value false, or until the end of the iterable.
|
|
7
|
+
*
|
|
8
|
+
* @param thisArg An object to which the this keyword can refer in the predicate function.
|
|
9
|
+
* If thisArg is omitted, undefined is used as the this value.
|
|
10
|
+
*/
|
|
11
|
+
declare function iterableEvery<T, S extends T>(iterable: Iterable<T>, predicate: (value: T, index: number, iterable: Iterable<T>) => value is S, thisArg?: any): iterable is S[];
|
|
12
|
+
/**
|
|
13
|
+
* Determines whether all the members of an iterable satisfy the specified test.
|
|
14
|
+
*
|
|
15
|
+
* @param predicate A function that accepts up to three arguments. The every method calls
|
|
16
|
+
* the predicate function for each element in the iterable until the predicate returns a value
|
|
17
|
+
* which is coercible to the Boolean value false, or until the end of the iterable.
|
|
18
|
+
*
|
|
19
|
+
* @param thisArg An object to which the this keyword can refer in the predicate function.
|
|
20
|
+
* If thisArg is omitted, undefined is used as the this value.
|
|
21
|
+
*/
|
|
22
|
+
declare function iterableEvery<T>(iterable: Iterable<T>, predicate: (value: T, index: number, iterable: Iterable<T>) => unknown, thisArg?: any): boolean;
|
|
23
|
+
|
|
24
|
+
export { iterableEvery };
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/iterableEvery.ts
|
|
21
|
+
var iterableEvery_exports = {};
|
|
22
|
+
__export(iterableEvery_exports, {
|
|
23
|
+
iterableEvery: () => iterableEvery
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(iterableEvery_exports);
|
|
26
|
+
function iterableEvery(iterable, predicate, thisArg = void 0) {
|
|
27
|
+
let index = 0;
|
|
28
|
+
if (typeof predicate !== "function") {
|
|
29
|
+
throw new TypeError(`${predicate} is not a function`);
|
|
30
|
+
}
|
|
31
|
+
const boundPredicate = predicate.bind(thisArg);
|
|
32
|
+
for (const value of iterable) {
|
|
33
|
+
if (!boundPredicate(value, index++, iterable)) {
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
return true;
|
|
38
|
+
}
|
|
39
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
40
|
+
0 && (module.exports = {
|
|
41
|
+
iterableEvery
|
|
42
|
+
});
|
|
43
|
+
//# sourceMappingURL=iter-fest.iterableEvery.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/iterableEvery.ts"],"sourcesContent":["/**\n * Determines whether all the members of an iterable satisfy the specified test.\n *\n * @param predicate A function that accepts up to three arguments. The every method calls\n * the predicate function for each element in the iterable until the predicate returns a value\n * which is coercible to the Boolean value false, or until the end of the iterable.\n *\n * @param thisArg An object to which the this keyword can refer in the predicate function.\n * If thisArg is omitted, undefined is used as the this value.\n */\nexport function iterableEvery<T, S extends T>(\n iterable: Iterable<T>,\n predicate: (value: T, index: number, iterable: Iterable<T>) => value is S,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n thisArg?: any\n): iterable is S[];\n\n/**\n * Determines whether all the members of an iterable satisfy the specified test.\n *\n * @param predicate A function that accepts up to three arguments. The every method calls\n * the predicate function for each element in the iterable until the predicate returns a value\n * which is coercible to the Boolean value false, or until the end of the iterable.\n *\n * @param thisArg An object to which the this keyword can refer in the predicate function.\n * If thisArg is omitted, undefined is used as the this value.\n */\nexport function iterableEvery<T>(\n iterable: Iterable<T>,\n predicate: (value: T, index: number, iterable: Iterable<T>) => unknown,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n thisArg?: any\n): boolean;\n\nexport function iterableEvery<T>(\n iterable: Iterable<T>,\n predicate: (value: T, index: number, iterable: Iterable<T>) => unknown,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n thisArg: any = undefined\n): boolean {\n let index = 0;\n\n if (typeof predicate !== 'function') {\n throw new TypeError(`${predicate} is not a function`);\n }\n\n const boundPredicate = predicate.bind(thisArg);\n\n for (const value of iterable) {\n if (!boundPredicate(value, index++, iterable)) {\n return false;\n }\n }\n\n return true;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAkCO,SAAS,cACd,UACA,WAEA,UAAe,QACN;AACT,MAAI,QAAQ;AAEZ,MAAI,OAAO,cAAc,YAAY;AACnC,UAAM,IAAI,UAAU,GAAG,SAAS,oBAAoB;AAAA,EACtD;AAEA,QAAM,iBAAiB,UAAU,KAAK,OAAO;AAE7C,aAAW,SAAS,UAAU;AAC5B,QAAI,CAAC,eAAe,OAAO,SAAS,QAAQ,GAAG;AAC7C,aAAO;AAAA,IACT;AAAA,EACF;AAEA,SAAO;AACT;","names":[]}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns the elements of an iterable that meet the condition specified in a callback function.
|
|
3
|
+
*
|
|
4
|
+
* @param predicate A function that accepts up to three arguments. The filter method calls the predicate function one time for each element in the iterable.
|
|
5
|
+
* @param thisArg An object to which the this keyword can refer in the predicate function. If thisArg is omitted, undefined is used as the this value.
|
|
6
|
+
*/
|
|
7
|
+
declare function iterableFilter<T, S extends T>(iterable: Iterable<T>, predicate: (value: T, index: number, iterable: Iterable<T>) => value is S, thisArg?: unknown): IterableIterator<S>;
|
|
8
|
+
/**
|
|
9
|
+
* Returns the elements of an iterable that meet the condition specified in a callback function.
|
|
10
|
+
*
|
|
11
|
+
* @param predicate A function that accepts up to three arguments. The filter method calls the predicate function one time for each element in the iterable.
|
|
12
|
+
* @param thisArg An object to which the this keyword can refer in the predicate function. If thisArg is omitted, undefined is used as the this value.
|
|
13
|
+
*/
|
|
14
|
+
declare function iterableFilter<T>(iterable: Iterable<T>, predicate: (value: T, index: number, iterable: Iterable<T>) => unknown, thisArg?: any): IterableIterator<T>;
|
|
15
|
+
|
|
16
|
+
export { iterableFilter };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns the elements of an iterable that meet the condition specified in a callback function.
|
|
3
|
+
*
|
|
4
|
+
* @param predicate A function that accepts up to three arguments. The filter method calls the predicate function one time for each element in the iterable.
|
|
5
|
+
* @param thisArg An object to which the this keyword can refer in the predicate function. If thisArg is omitted, undefined is used as the this value.
|
|
6
|
+
*/
|
|
7
|
+
declare function iterableFilter<T, S extends T>(iterable: Iterable<T>, predicate: (value: T, index: number, iterable: Iterable<T>) => value is S, thisArg?: unknown): IterableIterator<S>;
|
|
8
|
+
/**
|
|
9
|
+
* Returns the elements of an iterable that meet the condition specified in a callback function.
|
|
10
|
+
*
|
|
11
|
+
* @param predicate A function that accepts up to three arguments. The filter method calls the predicate function one time for each element in the iterable.
|
|
12
|
+
* @param thisArg An object to which the this keyword can refer in the predicate function. If thisArg is omitted, undefined is used as the this value.
|
|
13
|
+
*/
|
|
14
|
+
declare function iterableFilter<T>(iterable: Iterable<T>, predicate: (value: T, index: number, iterable: Iterable<T>) => unknown, thisArg?: any): IterableIterator<T>;
|
|
15
|
+
|
|
16
|
+
export { iterableFilter };
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/iterableFilter.ts
|
|
21
|
+
var iterableFilter_exports = {};
|
|
22
|
+
__export(iterableFilter_exports, {
|
|
23
|
+
iterableFilter: () => iterableFilter
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(iterableFilter_exports);
|
|
26
|
+
function* iterableFilter(iterable, predicate, thisArg) {
|
|
27
|
+
let index = 0;
|
|
28
|
+
if (typeof predicate !== "function") {
|
|
29
|
+
throw new TypeError(`${predicate} is not a function`);
|
|
30
|
+
}
|
|
31
|
+
const boundPredicate = predicate.bind(thisArg);
|
|
32
|
+
for (const value of iterable) {
|
|
33
|
+
if (boundPredicate(value, index++, iterable)) {
|
|
34
|
+
yield value;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
39
|
+
0 && (module.exports = {
|
|
40
|
+
iterableFilter
|
|
41
|
+
});
|
|
42
|
+
//# sourceMappingURL=iter-fest.iterableFilter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/iterableFilter.ts"],"sourcesContent":["/**\n * Returns the elements of an iterable that meet the condition specified in a callback function.\n *\n * @param predicate A function that accepts up to three arguments. The filter method calls the predicate function one time for each element in the iterable.\n * @param thisArg An object to which the this keyword can refer in the predicate function. If thisArg is omitted, undefined is used as the this value.\n */\nexport function iterableFilter<T, S extends T>(\n iterable: Iterable<T>,\n predicate: (value: T, index: number, iterable: Iterable<T>) => value is S,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n thisArg?: unknown\n): IterableIterator<S>;\n\n/**\n * Returns the elements of an iterable that meet the condition specified in a callback function.\n *\n * @param predicate A function that accepts up to three arguments. The filter method calls the predicate function one time for each element in the iterable.\n * @param thisArg An object to which the this keyword can refer in the predicate function. If thisArg is omitted, undefined is used as the this value.\n */\nexport function iterableFilter<T>(\n iterable: Iterable<T>,\n predicate: (value: T, index: number, iterable: Iterable<T>) => unknown,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n thisArg?: any\n): IterableIterator<T>;\n\nexport function* iterableFilter<T, S extends T>(\n iterable: Iterable<T>,\n predicate: (value: T, index: number, iterable: Iterable<T>) => unknown,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n thisArg?: unknown\n): IterableIterator<S> {\n let index = 0;\n\n if (typeof predicate !== 'function') {\n throw new TypeError(`${predicate} is not a function`);\n }\n\n const boundPredicate = predicate.bind(thisArg);\n\n for (const value of iterable) {\n if (boundPredicate(value, index++, iterable)) {\n yield value as S;\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AA0BO,UAAU,eACf,UACA,WAEA,SACqB;AACrB,MAAI,QAAQ;AAEZ,MAAI,OAAO,cAAc,YAAY;AACnC,UAAM,IAAI,UAAU,GAAG,SAAS,oBAAoB;AAAA,EACtD;AAEA,QAAM,iBAAiB,UAAU,KAAK,OAAO;AAE7C,aAAW,SAAS,UAAU;AAC5B,QAAI,eAAe,OAAO,SAAS,QAAQ,GAAG;AAC5C,YAAM;AAAA,IACR;AAAA,EACF;AACF;","names":[]}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns the value of the first element in the iterable where predicate is true, and undefined
|
|
3
|
+
* otherwise.
|
|
4
|
+
*
|
|
5
|
+
* @param predicate find calls predicate once for each element of the iterable, in ascending
|
|
6
|
+
* order, until it finds one where predicate returns true. If such an element is found, find
|
|
7
|
+
* immediately returns that element value. Otherwise, find returns undefined.
|
|
8
|
+
*
|
|
9
|
+
* @param thisArg If provided, it will be used as the this value for each invocation of
|
|
10
|
+
* predicate. If it is not provided, undefined is used instead.
|
|
11
|
+
*/
|
|
12
|
+
declare function iterableFind<T, S extends T>(iterable: Iterable<T>, predicate: (value: T, index: number, obj: Iterable<T>) => value is S, thisArg?: any): S | undefined;
|
|
13
|
+
declare function iterableFind<T>(iterable: Iterable<T>, predicate: (value: T, index: number, obj: Iterable<T>) => unknown, thisArg?: any): T | undefined;
|
|
14
|
+
|
|
15
|
+
export { iterableFind };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns the value of the first element in the iterable where predicate is true, and undefined
|
|
3
|
+
* otherwise.
|
|
4
|
+
*
|
|
5
|
+
* @param predicate find calls predicate once for each element of the iterable, in ascending
|
|
6
|
+
* order, until it finds one where predicate returns true. If such an element is found, find
|
|
7
|
+
* immediately returns that element value. Otherwise, find returns undefined.
|
|
8
|
+
*
|
|
9
|
+
* @param thisArg If provided, it will be used as the this value for each invocation of
|
|
10
|
+
* predicate. If it is not provided, undefined is used instead.
|
|
11
|
+
*/
|
|
12
|
+
declare function iterableFind<T, S extends T>(iterable: Iterable<T>, predicate: (value: T, index: number, obj: Iterable<T>) => value is S, thisArg?: any): S | undefined;
|
|
13
|
+
declare function iterableFind<T>(iterable: Iterable<T>, predicate: (value: T, index: number, obj: Iterable<T>) => unknown, thisArg?: any): T | undefined;
|
|
14
|
+
|
|
15
|
+
export { iterableFind };
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/iterableFind.ts
|
|
21
|
+
var iterableFind_exports = {};
|
|
22
|
+
__export(iterableFind_exports, {
|
|
23
|
+
iterableFind: () => iterableFind
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(iterableFind_exports);
|
|
26
|
+
function iterableFind(iterable, predicate, thisArg) {
|
|
27
|
+
let index = 0;
|
|
28
|
+
if (typeof predicate !== "function") {
|
|
29
|
+
throw new TypeError(`${predicate} is not a function`);
|
|
30
|
+
}
|
|
31
|
+
const boundPredicate = predicate.bind(thisArg);
|
|
32
|
+
for (const value of iterable) {
|
|
33
|
+
if (boundPredicate(value, index++, iterable)) {
|
|
34
|
+
return value;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
return void 0;
|
|
38
|
+
}
|
|
39
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
40
|
+
0 && (module.exports = {
|
|
41
|
+
iterableFind
|
|
42
|
+
});
|
|
43
|
+
//# sourceMappingURL=iter-fest.iterableFind.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/iterableFind.ts"],"sourcesContent":["/**\n * Returns the value of the first element in the iterable where predicate is true, and undefined\n * otherwise.\n *\n * @param predicate find calls predicate once for each element of the iterable, in ascending\n * order, until it finds one where predicate returns true. If such an element is found, find\n * immediately returns that element value. Otherwise, find returns undefined.\n *\n * @param thisArg If provided, it will be used as the this value for each invocation of\n * predicate. If it is not provided, undefined is used instead.\n */\nexport function iterableFind<T, S extends T>(\n iterable: Iterable<T>,\n predicate: (value: T, index: number, obj: Iterable<T>) => value is S,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n thisArg?: any\n): S | undefined;\n\nexport function iterableFind<T>(\n iterable: Iterable<T>,\n predicate: (value: T, index: number, obj: Iterable<T>) => unknown,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n thisArg?: any\n): T | undefined;\n\nexport function iterableFind<T, S extends T>(\n iterable: Iterable<T>,\n predicate: (value: T, index: number, obj: Iterable<T>) => unknown,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n thisArg?: any\n): S | undefined {\n let index = 0;\n\n if (typeof predicate !== 'function') {\n throw new TypeError(`${predicate} is not a function`);\n }\n\n const boundPredicate = predicate.bind(thisArg);\n\n for (const value of iterable) {\n if (boundPredicate(value, index++, iterable)) {\n return value as S;\n }\n }\n\n return undefined;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAyBO,SAAS,aACd,UACA,WAEA,SACe;AACf,MAAI,QAAQ;AAEZ,MAAI,OAAO,cAAc,YAAY;AACnC,UAAM,IAAI,UAAU,GAAG,SAAS,oBAAoB;AAAA,EACtD;AAEA,QAAM,iBAAiB,UAAU,KAAK,OAAO;AAE7C,aAAW,SAAS,UAAU;AAC5B,QAAI,eAAe,OAAO,SAAS,QAAQ,GAAG;AAC5C,aAAO;AAAA,IACT;AAAA,EACF;AAEA,SAAO;AACT;","names":[]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Performs the specified action for each element in an iterable.
|
|
3
|
+
*
|
|
4
|
+
* @param callbackfn A function that accepts up to three arguments. forEach calls the callbackfn function one time for each element in the iterable.
|
|
5
|
+
*
|
|
6
|
+
* @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value.
|
|
7
|
+
*/
|
|
8
|
+
declare function iterableForEach<T>(iterable: Iterable<T>, callbackfn: (value: T, index: number, iterable: Iterable<T>) => void, thisArg?: any): void;
|
|
9
|
+
|
|
10
|
+
export { iterableForEach };
|