@naturalcycles/js-lib 14.195.0 → 14.196.0
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/http/fetcher.js +1 -1
- package/dist/iter/iterable2.d.ts +4 -2
- package/dist/iter/iterable2.js +17 -1
- package/dist/log/commonLogger.js +1 -1
- package/dist-esm/iter/iterable2.js +17 -1
- package/dist-esm/log/commonLogger.js +1 -1
- package/package.json +1 -1
- package/src/iter/iterable2.ts +19 -3
- package/src/string/leven.ts +2 -2
- package/src/typeFest.ts +10 -10
package/dist/http/fetcher.js
CHANGED
|
@@ -562,7 +562,7 @@ class Fetcher {
|
|
|
562
562
|
},
|
|
563
563
|
init: (0, object_util_1._merge)({
|
|
564
564
|
...this.cfg.init,
|
|
565
|
-
headers: { ...this.cfg.init.headers },
|
|
565
|
+
headers: { ...this.cfg.init.headers }, // this avoids mutation
|
|
566
566
|
method: opt.method || this.cfg.init.method,
|
|
567
567
|
credentials: opt.credentials || this.cfg.init.credentials,
|
|
568
568
|
redirect: opt.redirect || this.cfg.init.redirect || 'follow',
|
package/dist/iter/iterable2.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AbortableMapper, AbortablePredicate, END
|
|
1
|
+
import { AbortableMapper, AbortablePredicate, END } from '../types';
|
|
2
2
|
/**
|
|
3
3
|
* Iterable2 is a wrapper around Iterable that implements "Iterator Helpers proposal":
|
|
4
4
|
* https://github.com/tc39/proposal-iterator-helpers
|
|
@@ -15,7 +15,9 @@ export declare class Iterable2<T> implements Iterable<T> {
|
|
|
15
15
|
[Symbol.iterator](): Iterator<T>;
|
|
16
16
|
toArray(): T[];
|
|
17
17
|
forEach(cb: (v: T, i: number) => any | typeof END): void;
|
|
18
|
-
|
|
18
|
+
some(cb: AbortablePredicate<T>): boolean;
|
|
19
|
+
every(cb: AbortablePredicate<T>): boolean;
|
|
20
|
+
find(cb: AbortablePredicate<T>): T | undefined;
|
|
19
21
|
filter(cb: AbortablePredicate<T>): Iterable2<T>;
|
|
20
22
|
map<OUT>(mapper: AbortableMapper<T, OUT>): Iterable2<OUT>;
|
|
21
23
|
}
|
package/dist/iter/iterable2.js
CHANGED
|
@@ -33,10 +33,26 @@ class Iterable2 {
|
|
|
33
33
|
return;
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
|
+
some(cb) {
|
|
37
|
+
// eslint-disable-next-line unicorn/prefer-array-some
|
|
38
|
+
return !!this.find(cb);
|
|
39
|
+
}
|
|
40
|
+
every(cb) {
|
|
41
|
+
let i = 0;
|
|
42
|
+
for (const v of this.it) {
|
|
43
|
+
const r = cb(v, i++);
|
|
44
|
+
if (r === types_1.END || !r)
|
|
45
|
+
return false;
|
|
46
|
+
}
|
|
47
|
+
return true;
|
|
48
|
+
}
|
|
36
49
|
find(cb) {
|
|
37
50
|
let i = 0;
|
|
38
51
|
for (const v of this.it) {
|
|
39
|
-
|
|
52
|
+
const r = cb(v, i++);
|
|
53
|
+
if (r === types_1.END)
|
|
54
|
+
return;
|
|
55
|
+
if (r)
|
|
40
56
|
return v;
|
|
41
57
|
}
|
|
42
58
|
}
|
package/dist/log/commonLogger.js
CHANGED
|
@@ -43,7 +43,7 @@ function commonLoggerMinLevel(logger, minLevel, mutate = false) {
|
|
|
43
43
|
return exports.commonLoggerNoop;
|
|
44
44
|
}
|
|
45
45
|
return {
|
|
46
|
-
log: index_1._noop,
|
|
46
|
+
log: index_1._noop, // otherwise it is "log everything" logger (same logger as input)
|
|
47
47
|
warn: level <= exports.commonLogLevelNumber['warn'] ? logger.warn.bind(logger) : index_1._noop,
|
|
48
48
|
error: logger.error.bind(logger), // otherwise it's "log nothing" logger (same as noopLogger)
|
|
49
49
|
};
|
|
@@ -30,10 +30,26 @@ export class Iterable2 {
|
|
|
30
30
|
return;
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
|
+
some(cb) {
|
|
34
|
+
// eslint-disable-next-line unicorn/prefer-array-some
|
|
35
|
+
return !!this.find(cb);
|
|
36
|
+
}
|
|
37
|
+
every(cb) {
|
|
38
|
+
let i = 0;
|
|
39
|
+
for (const v of this.it) {
|
|
40
|
+
const r = cb(v, i++);
|
|
41
|
+
if (r === END || !r)
|
|
42
|
+
return false;
|
|
43
|
+
}
|
|
44
|
+
return true;
|
|
45
|
+
}
|
|
33
46
|
find(cb) {
|
|
34
47
|
let i = 0;
|
|
35
48
|
for (const v of this.it) {
|
|
36
|
-
|
|
49
|
+
const r = cb(v, i++);
|
|
50
|
+
if (r === END)
|
|
51
|
+
return;
|
|
52
|
+
if (r)
|
|
37
53
|
return v;
|
|
38
54
|
}
|
|
39
55
|
}
|
|
@@ -40,7 +40,7 @@ export function commonLoggerMinLevel(logger, minLevel, mutate = false) {
|
|
|
40
40
|
return commonLoggerNoop;
|
|
41
41
|
}
|
|
42
42
|
return {
|
|
43
|
-
log: _noop,
|
|
43
|
+
log: _noop, // otherwise it is "log everything" logger (same logger as input)
|
|
44
44
|
warn: level <= commonLogLevelNumber['warn'] ? logger.warn.bind(logger) : _noop,
|
|
45
45
|
error: logger.error.bind(logger), // otherwise it's "log nothing" logger (same as noopLogger)
|
|
46
46
|
};
|
package/package.json
CHANGED
package/src/iter/iterable2.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AbortableMapper, AbortablePredicate, END,
|
|
1
|
+
import { AbortableMapper, AbortablePredicate, END, SKIP } from '../types'
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Iterable2 is a wrapper around Iterable that implements "Iterator Helpers proposal":
|
|
@@ -34,10 +34,26 @@ export class Iterable2<T> implements Iterable<T> {
|
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
-
|
|
37
|
+
some(cb: AbortablePredicate<T>): boolean {
|
|
38
|
+
// eslint-disable-next-line unicorn/prefer-array-some
|
|
39
|
+
return !!this.find(cb)
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
every(cb: AbortablePredicate<T>): boolean {
|
|
43
|
+
let i = 0
|
|
44
|
+
for (const v of this.it) {
|
|
45
|
+
const r = cb(v, i++)
|
|
46
|
+
if (r === END || !r) return false
|
|
47
|
+
}
|
|
48
|
+
return true
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
find(cb: AbortablePredicate<T>): T | undefined {
|
|
38
52
|
let i = 0
|
|
39
53
|
for (const v of this.it) {
|
|
40
|
-
|
|
54
|
+
const r = cb(v, i++)
|
|
55
|
+
if (r === END) return
|
|
56
|
+
if (r) return v
|
|
41
57
|
}
|
|
42
58
|
}
|
|
43
59
|
|
package/src/string/leven.ts
CHANGED
package/src/typeFest.ts
CHANGED
|
@@ -30,8 +30,8 @@ export type IsEqual<T, U> = (<G>() => G extends T ? 1 : 2) extends <G>() => G ex
|
|
|
30
30
|
type Filter<KeyType, ExcludeType> = IsEqual<KeyType, ExcludeType> extends true
|
|
31
31
|
? never
|
|
32
32
|
: KeyType extends ExcludeType
|
|
33
|
-
|
|
34
|
-
|
|
33
|
+
? never
|
|
34
|
+
: KeyType
|
|
35
35
|
|
|
36
36
|
/**
|
|
37
37
|
Create a type from an object type without certain keys.
|
|
@@ -94,12 +94,12 @@ export type Except<ObjectType, KeysType extends keyof ObjectType> = {
|
|
|
94
94
|
export type ReadonlyDeep<T> = T extends Primitive | ((...args: any[]) => unknown)
|
|
95
95
|
? T
|
|
96
96
|
: T extends ReadonlyMap<infer KeyType, infer ValueType>
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
97
|
+
? ReadonlyMapDeep<KeyType, ValueType>
|
|
98
|
+
: T extends ReadonlySet<infer ItemType>
|
|
99
|
+
? ReadonlySetDeep<ItemType>
|
|
100
|
+
: T extends object
|
|
101
|
+
? ReadonlyObjectDeep<T>
|
|
102
|
+
: unknown
|
|
103
103
|
|
|
104
104
|
/**
|
|
105
105
|
Same as `ReadonlyDeep`, but accepts only `ReadonlyMap`s as inputs. Internal helper for `ReadonlyDeep`.
|
|
@@ -171,8 +171,8 @@ export type Merge<Destination, Source> = {
|
|
|
171
171
|
[Key in keyof OmitIndexSignature<Destination & Source>]: Key extends keyof Source
|
|
172
172
|
? Source[Key]
|
|
173
173
|
: Key extends keyof Destination
|
|
174
|
-
|
|
175
|
-
|
|
174
|
+
? Destination[Key]
|
|
175
|
+
: never
|
|
176
176
|
} & PickIndexSignature<Destination & Source>
|
|
177
177
|
|
|
178
178
|
/**
|