@naturalcycles/js-lib
Advanced tools
Comparing version 14.195.0 to 14.196.0
@@ -33,6 +33,22 @@ import { END, SKIP } from '../types'; | ||
} | ||
some(cb) { | ||
// eslint-disable-next-line unicorn/prefer-array-some | ||
return !!this.find(cb); | ||
} | ||
every(cb) { | ||
let i = 0; | ||
for (const v of this.it) { | ||
const r = cb(v, i++); | ||
if (r === END || !r) | ||
return false; | ||
} | ||
return true; | ||
} | ||
find(cb) { | ||
let i = 0; | ||
for (const v of this.it) { | ||
if (cb(v, i++)) | ||
const r = cb(v, i++); | ||
if (r === END) | ||
return; | ||
if (r) | ||
return v; | ||
@@ -39,0 +55,0 @@ } |
@@ -43,3 +43,3 @@ import { _noop } from '../index'; | ||
return { | ||
log: _noop, | ||
log: _noop, // otherwise it is "log everything" logger (same logger as input) | ||
warn: level <= commonLogLevelNumber['warn'] ? logger.warn.bind(logger) : _noop, | ||
@@ -46,0 +46,0 @@ error: logger.error.bind(logger), // otherwise it's "log nothing" logger (same as noopLogger) |
@@ -565,3 +565,3 @@ "use strict"; | ||
...this.cfg.init, | ||
headers: { ...this.cfg.init.headers }, | ||
headers: { ...this.cfg.init.headers }, // this avoids mutation | ||
method: opt.method || this.cfg.init.method, | ||
@@ -568,0 +568,0 @@ credentials: opt.credentials || this.cfg.init.credentials, |
@@ -1,2 +0,2 @@ | ||
import { AbortableMapper, AbortablePredicate, END, Predicate } from '../types'; | ||
import { AbortableMapper, AbortablePredicate, END } from '../types'; | ||
/** | ||
@@ -18,5 +18,7 @@ * Iterable2 is a wrapper around Iterable that implements "Iterator Helpers proposal": | ||
forEach(cb: (v: T, i: number) => any | typeof END): void; | ||
find(cb: Predicate<T>): T | undefined; | ||
some(cb: AbortablePredicate<T>): boolean; | ||
every(cb: AbortablePredicate<T>): boolean; | ||
find(cb: AbortablePredicate<T>): T | undefined; | ||
filter(cb: AbortablePredicate<T>): Iterable2<T>; | ||
map<OUT>(mapper: AbortableMapper<T, OUT>): Iterable2<OUT>; | ||
} |
@@ -36,6 +36,22 @@ "use strict"; | ||
} | ||
some(cb) { | ||
// eslint-disable-next-line unicorn/prefer-array-some | ||
return !!this.find(cb); | ||
} | ||
every(cb) { | ||
let i = 0; | ||
for (const v of this.it) { | ||
const r = cb(v, i++); | ||
if (r === types_1.END || !r) | ||
return false; | ||
} | ||
return true; | ||
} | ||
find(cb) { | ||
let i = 0; | ||
for (const v of this.it) { | ||
if (cb(v, i++)) | ||
const r = cb(v, i++); | ||
if (r === types_1.END) | ||
return; | ||
if (r) | ||
return v; | ||
@@ -42,0 +58,0 @@ } |
@@ -46,3 +46,3 @@ "use strict"; | ||
return { | ||
log: index_1._noop, | ||
log: index_1._noop, // otherwise it is "log everything" logger (same logger as input) | ||
warn: level <= exports.commonLogLevelNumber['warn'] ? logger.warn.bind(logger) : index_1._noop, | ||
@@ -49,0 +49,0 @@ error: logger.error.bind(logger), // otherwise it's "log nothing" logger (same as noopLogger) |
{ | ||
"name": "@naturalcycles/js-lib", | ||
"version": "14.195.0", | ||
"version": "14.196.0", | ||
"scripts": { | ||
@@ -5,0 +5,0 @@ "prepare": "husky install", |
@@ -1,2 +0,2 @@ | ||
import { AbortableMapper, AbortablePredicate, END, Predicate, SKIP } from '../types' | ||
import { AbortableMapper, AbortablePredicate, END, SKIP } from '../types' | ||
@@ -37,9 +37,25 @@ /** | ||
find(cb: Predicate<T>): T | undefined { | ||
some(cb: AbortablePredicate<T>): boolean { | ||
// eslint-disable-next-line unicorn/prefer-array-some | ||
return !!this.find(cb) | ||
} | ||
every(cb: AbortablePredicate<T>): boolean { | ||
let i = 0 | ||
for (const v of this.it) { | ||
if (cb(v, i++)) return v | ||
const r = cb(v, i++) | ||
if (r === END || !r) return false | ||
} | ||
return true | ||
} | ||
find(cb: AbortablePredicate<T>): T | undefined { | ||
let i = 0 | ||
for (const v of this.it) { | ||
const r = cb(v, i++) | ||
if (r === END) return | ||
if (r) return v | ||
} | ||
} | ||
filter(cb: AbortablePredicate<T>): Iterable2<T> { | ||
@@ -46,0 +62,0 @@ const { it } = this |
@@ -80,4 +80,4 @@ const array: number[] = [] | ||
: temporary2 > temporary | ||
? temporary + 1 | ||
: temporary2 | ||
? temporary + 1 | ||
: temporary2 | ||
} | ||
@@ -84,0 +84,0 @@ } |
@@ -33,4 +33,4 @@ /* eslint-disable */ | ||
: KeyType extends ExcludeType | ||
? never | ||
: KeyType | ||
? never | ||
: KeyType | ||
@@ -98,8 +98,8 @@ /** | ||
: T extends ReadonlyMap<infer KeyType, infer ValueType> | ||
? ReadonlyMapDeep<KeyType, ValueType> | ||
: T extends ReadonlySet<infer ItemType> | ||
? ReadonlySetDeep<ItemType> | ||
: T extends object | ||
? ReadonlyObjectDeep<T> | ||
: unknown | ||
? ReadonlyMapDeep<KeyType, ValueType> | ||
: T extends ReadonlySet<infer ItemType> | ||
? ReadonlySetDeep<ItemType> | ||
: T extends object | ||
? ReadonlyObjectDeep<T> | ||
: unknown | ||
@@ -176,4 +176,4 @@ /** | ||
: Key extends keyof Destination | ||
? Destination[Key] | ||
: never | ||
? Destination[Key] | ||
: never | ||
} & PickIndexSignature<Destination & Source> | ||
@@ -180,0 +180,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
961247
28832