pepka 1.6.8 → 1.6.10
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/bundle.cjs +3 -3
- package/dist/bundle.d.ts +2 -2
- package/dist/bundle.mjs +3 -3
- package/package.json +1 -1
- package/src/safe.ts +8 -8
package/dist/bundle.cjs
CHANGED
|
@@ -291,7 +291,7 @@ const slice = curry3((from, to, o) => o.slice(from, (isNum(to) ? to : inf)));
|
|
|
291
291
|
const flip = (fn) => curry2((b, a) => fn(a, b));
|
|
292
292
|
/** @returns first element of an array or a string. */
|
|
293
293
|
const head = nth(0);
|
|
294
|
-
/** @returns
|
|
294
|
+
/** @returns all elements of an array or a string after first one. */
|
|
295
295
|
const tail = slice(1, inf);
|
|
296
296
|
/** Returns last element of an array, readonly array or a string.
|
|
297
297
|
* @param s Array to extract that element.
|
|
@@ -391,7 +391,7 @@ const diff = curry2((_xs1, _xs2) => {
|
|
|
391
391
|
const genBy = curry2((generator, length) => [...Array(length)].map((_, i) => generator(i)));
|
|
392
392
|
const once = (fn) => {
|
|
393
393
|
let done = false, cache;
|
|
394
|
-
return (...args)
|
|
394
|
+
return function (...args) {
|
|
395
395
|
if (done)
|
|
396
396
|
return cache;
|
|
397
397
|
done = true;
|
|
@@ -440,7 +440,7 @@ const clone = (s, shallow = false) => {
|
|
|
440
440
|
const t = type(s);
|
|
441
441
|
switch (t) {
|
|
442
442
|
case 'Null': return s;
|
|
443
|
-
case 'Array': return shallow ? [...s] : map(compose(clone, take(0)), s);
|
|
443
|
+
case 'Array': return (shallow ? [...s] : map(compose(clone, take(0)), s));
|
|
444
444
|
case 'Object':
|
|
445
445
|
if (shallow)
|
|
446
446
|
return { ...s };
|
package/dist/bundle.d.ts
CHANGED
|
@@ -115,7 +115,7 @@ type TailOverload = {
|
|
|
115
115
|
] ? U : T;
|
|
116
116
|
<T extends any>(s: T[]): null;
|
|
117
117
|
};
|
|
118
|
-
/** @returns
|
|
118
|
+
/** @returns all elements of an array or a string after first one. */
|
|
119
119
|
export declare const tail: TailOverload;
|
|
120
120
|
type LastChar<T extends string> = T extends `${string}${infer Rest}` ? (Split<T>["length"] extends 1 ? T : LastChar<Rest>) : T;
|
|
121
121
|
type LastOverload = {
|
|
@@ -391,7 +391,7 @@ export declare const path: any;
|
|
|
391
391
|
export declare const pathEq: (...args: AnyArgs) => any;
|
|
392
392
|
export declare const pathsEq: (...args: AnyArgs) => any;
|
|
393
393
|
export declare const pathExists: Composed<any[], any>;
|
|
394
|
-
export declare const clone: (s:
|
|
394
|
+
export declare const clone: <T extends any>(s: T, shallow?: boolean) => T;
|
|
395
395
|
export declare const cloneShallow: (s: any) => any;
|
|
396
396
|
export declare const freeze: <T extends AnyObject>(o: T) => Readonly<T>;
|
|
397
397
|
export declare const freezeShallow: <T extends AnyObject>(o: T) => Readonly<T>;
|
package/dist/bundle.mjs
CHANGED
|
@@ -289,7 +289,7 @@ const slice = curry3((from, to, o) => o.slice(from, (isNum(to) ? to : inf)));
|
|
|
289
289
|
const flip = (fn) => curry2((b, a) => fn(a, b));
|
|
290
290
|
/** @returns first element of an array or a string. */
|
|
291
291
|
const head = nth(0);
|
|
292
|
-
/** @returns
|
|
292
|
+
/** @returns all elements of an array or a string after first one. */
|
|
293
293
|
const tail = slice(1, inf);
|
|
294
294
|
/** Returns last element of an array, readonly array or a string.
|
|
295
295
|
* @param s Array to extract that element.
|
|
@@ -389,7 +389,7 @@ const diff = curry2((_xs1, _xs2) => {
|
|
|
389
389
|
const genBy = curry2((generator, length) => [...Array(length)].map((_, i) => generator(i)));
|
|
390
390
|
const once = (fn) => {
|
|
391
391
|
let done = false, cache;
|
|
392
|
-
return (...args)
|
|
392
|
+
return function (...args) {
|
|
393
393
|
if (done)
|
|
394
394
|
return cache;
|
|
395
395
|
done = true;
|
|
@@ -438,7 +438,7 @@ const clone = (s, shallow = false) => {
|
|
|
438
438
|
const t = type(s);
|
|
439
439
|
switch (t) {
|
|
440
440
|
case 'Null': return s;
|
|
441
|
-
case 'Array': return shallow ? [...s] : map(compose(clone, take(0)), s);
|
|
441
|
+
case 'Array': return (shallow ? [...s] : map(compose(clone, take(0)), s));
|
|
442
442
|
case 'Object':
|
|
443
443
|
if (shallow)
|
|
444
444
|
return { ...s };
|
package/package.json
CHANGED
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"prod": "npm run gentypes && npm run prod:es && npm run prod:cjs",
|
|
42
42
|
"all": "npm run dev && npm run prod"
|
|
43
43
|
},
|
|
44
|
-
"version": "1.6.
|
|
44
|
+
"version": "1.6.10",
|
|
45
45
|
"devDependencies": {
|
|
46
46
|
"@rollup/plugin-commonjs": "^28.0.6",
|
|
47
47
|
"@rollup/plugin-node-resolve": "^16.0.1",
|
package/src/safe.ts
CHANGED
|
@@ -72,7 +72,7 @@ type TailOverload = {
|
|
|
72
72
|
: T extends readonly [any, ...infer U] ? U : T
|
|
73
73
|
<T extends any>(s: T[]): null
|
|
74
74
|
}
|
|
75
|
-
/** @returns
|
|
75
|
+
/** @returns all elements of an array or a string after first one. */
|
|
76
76
|
export const tail = slice(1, inf) as TailOverload
|
|
77
77
|
type LastChar<T extends string> = T extends `${string}${infer Rest}`
|
|
78
78
|
? (Split<T>['length'] extends 1 ? T : LastChar<Rest>) : T
|
|
@@ -194,7 +194,7 @@ export const genBy = curry2(
|
|
|
194
194
|
)
|
|
195
195
|
export const once = <Func extends AnyFunc>(fn: Func) => {
|
|
196
196
|
let done = false, cache: any
|
|
197
|
-
return (...args: Parameters<Func>)
|
|
197
|
+
return function(...args: Parameters<Func>) {
|
|
198
198
|
if(done) return cache
|
|
199
199
|
done = true
|
|
200
200
|
return cache = fn(...args)
|
|
@@ -265,21 +265,21 @@ export const pathsEq = curry3(
|
|
|
265
265
|
equals(path(_path, o1), path(_path, o2))
|
|
266
266
|
)
|
|
267
267
|
export const pathExists = compose(ifElse(equals(symbol), F, T), pathOr(symbol))
|
|
268
|
-
export const clone = (s:
|
|
268
|
+
export const clone = <T extends any>(s: T, shallow = false): T => {
|
|
269
269
|
const t = type(s)
|
|
270
270
|
switch(t) {
|
|
271
271
|
case 'Null': return s
|
|
272
|
-
case 'Array': return shallow ? [...s] : map(compose(clone, take(0)), s)
|
|
272
|
+
case 'Array': return (shallow ? [...(s as any[])] : map(compose(clone, take(0)), s as any[])) as T
|
|
273
273
|
case 'Object':
|
|
274
|
-
if(shallow) return {...s}
|
|
275
|
-
const out = {}
|
|
274
|
+
if(shallow) return {...s as AnyObject} as T
|
|
275
|
+
const out: AnyObject = {}
|
|
276
276
|
for(let k in s) out[k] = clone(s[k])
|
|
277
|
-
return out
|
|
277
|
+
return out as T
|
|
278
278
|
case 'String': case 'Number':
|
|
279
279
|
case 'Boolean': case 'Symbol':
|
|
280
280
|
return s
|
|
281
281
|
default:
|
|
282
|
-
return is_typed_arr(t) ? s.constructor.from(s) : s
|
|
282
|
+
return is_typed_arr(t) ? (s as any).constructor.from(s) : s
|
|
283
283
|
}
|
|
284
284
|
}
|
|
285
285
|
export const cloneShallow = (s: any) => clone(s, true)
|