pepka 0.14.0-beta0 → 0.14.0-beta1
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.d.ts +30 -29
- package/dist/bundle.esm.js +1 -1
- package/dist/bundle.js +1 -1
- package/package.json +2 -2
- package/src/curry.ts +1 -1
- package/src/safe.ts +7 -2
package/dist/bundle.d.ts
CHANGED
|
@@ -40,8 +40,8 @@ export declare const equals: {
|
|
|
40
40
|
(a: any): (b: any) => boolean;
|
|
41
41
|
(a: any, b: any): boolean;
|
|
42
42
|
};
|
|
43
|
-
export declare const ifElse:
|
|
44
|
-
export declare const when:
|
|
43
|
+
export declare const ifElse: FT.Curry<AnyFunc<any, AnyArgs>>;
|
|
44
|
+
export declare const when: FT.Curry<(cond: (s: any) => boolean, pipe: (s: any) => any, s: any) => any>;
|
|
45
45
|
export type Composed<TIn extends any[], TOut> = (...xs: TIn) => TOut;
|
|
46
46
|
export declare const compose: <TIn extends any[] = any[], TOut = any>(...fns: AnyFunc[]) => Composed<TIn, TOut>;
|
|
47
47
|
export declare const bind: {
|
|
@@ -62,9 +62,11 @@ export declare const includes: {
|
|
|
62
62
|
(a: unknown): (b: unknown[]) => boolean;
|
|
63
63
|
(a: unknown, b: unknown[]): boolean;
|
|
64
64
|
};
|
|
65
|
-
export declare const slice:
|
|
65
|
+
export declare const slice: FT.Curry<(from: number, to: number, o: any[] | string) => string | any[]>;
|
|
66
|
+
export type TupleFn<ARG1 = any, ARG2 = any, Out = any> = (a: ARG1, b: ARG2) => Out;
|
|
67
|
+
export declare const flip: <ARG1 = any, ARG2 = any, Out = any>(fn: FT.Curry<TupleFn<ARG1, ARG2, Out>>) => FT.Curry<TupleFn<ARG2, ARG1, Out>>;
|
|
66
68
|
export declare const head: (b: string | unknown[]) => unknown;
|
|
67
|
-
export declare const tail:
|
|
69
|
+
export declare const tail: FT.Curry<(o: string | any[]) => string | any[]>;
|
|
68
70
|
export declare const add: {
|
|
69
71
|
(a: symbol, b: number): (a: number) => number;
|
|
70
72
|
(a: number, b: symbol): (b: number) => number;
|
|
@@ -89,7 +91,6 @@ export declare const divide: {
|
|
|
89
91
|
(a: number): (b: number) => number;
|
|
90
92
|
(a: number, b: number): number;
|
|
91
93
|
};
|
|
92
|
-
export declare const flip: (fn: Function) => import("ts-toolbelt/out/Function/Curry").Curry<AnyFunc<any, AnyArgs>>;
|
|
93
94
|
export declare const isNil: (s: any) => boolean;
|
|
94
95
|
export declare const length: (s: any[] | string) => number;
|
|
95
96
|
export declare const always: <T = any>(s: T) => () => T;
|
|
@@ -219,7 +220,7 @@ export declare const cond: {
|
|
|
219
220
|
Function
|
|
220
221
|
][], b: any): any;
|
|
221
222
|
};
|
|
222
|
-
export declare const assoc:
|
|
223
|
+
export declare const assoc: FT.Curry<(prop: string, v: any, obj: AnyObject) => {
|
|
223
224
|
[x: string]: any;
|
|
224
225
|
}>;
|
|
225
226
|
export declare const assocPath: any;
|
|
@@ -253,15 +254,15 @@ export declare const prop: {
|
|
|
253
254
|
(a: string): (b: AnyObject) => any;
|
|
254
255
|
(a: string, b: AnyObject): any;
|
|
255
256
|
};
|
|
256
|
-
export declare const propEq:
|
|
257
|
-
export declare const propsEq:
|
|
258
|
-
export declare const pathOr:
|
|
259
|
-
export declare const path:
|
|
260
|
-
export declare const pathEq:
|
|
261
|
-
export declare const pathsEq:
|
|
257
|
+
export declare const propEq: FT.Curry<(key: string, value: any, o: AnyObject) => boolean>;
|
|
258
|
+
export declare const propsEq: FT.Curry<(key: string, o1: any, o2: AnyObject) => boolean>;
|
|
259
|
+
export declare const pathOr: FT.Curry<(_default: any, path: string[], o: any) => any>;
|
|
260
|
+
export declare const path: FT.Curry<(path: string[], o: any) => any>;
|
|
261
|
+
export declare const pathEq: FT.Curry<(_path: string[], value: any, o: AnyObject) => (a: any) => boolean>;
|
|
262
|
+
export declare const pathsEq: FT.Curry<(_path: string[], o1: AnyObject, o2: AnyObject) => (a: any) => boolean>;
|
|
262
263
|
export declare const clone: (s: any, shallow?: boolean) => any;
|
|
263
264
|
export declare const cloneShallow: (s: any) => any;
|
|
264
|
-
export declare const reduce:
|
|
265
|
+
export declare const reduce: FT.Curry<(fn: Reducer, accum: any, arr: any[]) => FT.Curry<(...p: [
|
|
265
266
|
] | [
|
|
266
267
|
accum: any
|
|
267
268
|
]) => any>>;
|
|
@@ -286,7 +287,7 @@ export declare const omit: {
|
|
|
286
287
|
export declare const fromPairs: (pairs: [
|
|
287
288
|
string,
|
|
288
289
|
any
|
|
289
|
-
][]) =>
|
|
290
|
+
][]) => FT.Curry<(fn: Reducer, accum: any, arr: any[]) => FT.Curry<(...p: [
|
|
290
291
|
] | [
|
|
291
292
|
accum: any
|
|
292
293
|
]) => any>>;
|
|
@@ -314,10 +315,10 @@ export declare const forEach: {
|
|
|
314
315
|
(a: (s: any) => any): (b: any[]) => void;
|
|
315
316
|
(a: (s: any) => any, b: any[]): void;
|
|
316
317
|
};
|
|
317
|
-
export declare const both:
|
|
318
|
+
export declare const both: FT.Curry<(cond1: Cond, cond2: Cond, s: any) => boolean>;
|
|
318
319
|
export declare const isEmpty: (s: any) => boolean | null;
|
|
319
320
|
export declare const empty: (s: any) => {} | undefined;
|
|
320
|
-
export declare const replace:
|
|
321
|
+
export declare const replace: FT.Curry<(a: string | RegExp, b: string | ((substring: string, ...ps: any[]) => string), where: string) => string>;
|
|
321
322
|
export declare const filter: any;
|
|
322
323
|
export declare const memoize: (fn: Function) => () => any;
|
|
323
324
|
export declare const mergeShallow: {
|
|
@@ -327,7 +328,7 @@ export declare const mergeShallow: {
|
|
|
327
328
|
(a: AnyObject, b: AnyObject): AnyObject;
|
|
328
329
|
};
|
|
329
330
|
export declare const mergeDeep: {
|
|
330
|
-
(a: symbol, b: AnyObject): (a: AnyObject) =>
|
|
331
|
+
(a: symbol, b: AnyObject): (a: AnyObject) => FT.Curry<(...p: [
|
|
331
332
|
] | [
|
|
332
333
|
o1: AnyObject,
|
|
333
334
|
o2: AnyObject
|
|
@@ -336,7 +337,7 @@ export declare const mergeDeep: {
|
|
|
336
337
|
] | [
|
|
337
338
|
o1: AnyObject
|
|
338
339
|
]) => any>;
|
|
339
|
-
(a: AnyObject, b: symbol): (b: AnyObject) =>
|
|
340
|
+
(a: AnyObject, b: symbol): (b: AnyObject) => FT.Curry<(...p: [
|
|
340
341
|
] | [
|
|
341
342
|
o1: AnyObject,
|
|
342
343
|
o2: AnyObject
|
|
@@ -345,7 +346,7 @@ export declare const mergeDeep: {
|
|
|
345
346
|
] | [
|
|
346
347
|
o1: AnyObject
|
|
347
348
|
]) => any>;
|
|
348
|
-
(a: AnyObject): (b: AnyObject) =>
|
|
349
|
+
(a: AnyObject): (b: AnyObject) => FT.Curry<(...p: [
|
|
349
350
|
] | [
|
|
350
351
|
o1: AnyObject,
|
|
351
352
|
o2: AnyObject
|
|
@@ -354,7 +355,7 @@ export declare const mergeDeep: {
|
|
|
354
355
|
] | [
|
|
355
356
|
o1: AnyObject
|
|
356
357
|
]) => any>;
|
|
357
|
-
(a: AnyObject, b: AnyObject):
|
|
358
|
+
(a: AnyObject, b: AnyObject): FT.Curry<(...p: [
|
|
358
359
|
] | [
|
|
359
360
|
o1: AnyObject,
|
|
360
361
|
o2: AnyObject
|
|
@@ -365,7 +366,7 @@ export declare const mergeDeep: {
|
|
|
365
366
|
]) => any>;
|
|
366
367
|
};
|
|
367
368
|
export declare const mergeDeepX: {
|
|
368
|
-
(a: symbol, b: AnyObject): (a: AnyObject) =>
|
|
369
|
+
(a: symbol, b: AnyObject): (a: AnyObject) => FT.Curry<(...p: [
|
|
369
370
|
] | [
|
|
370
371
|
o1: AnyObject,
|
|
371
372
|
o2: AnyObject
|
|
@@ -374,7 +375,7 @@ export declare const mergeDeepX: {
|
|
|
374
375
|
] | [
|
|
375
376
|
o1: AnyObject
|
|
376
377
|
]) => any>;
|
|
377
|
-
(a: AnyObject, b: symbol): (b: AnyObject) =>
|
|
378
|
+
(a: AnyObject, b: symbol): (b: AnyObject) => FT.Curry<(...p: [
|
|
378
379
|
] | [
|
|
379
380
|
o1: AnyObject,
|
|
380
381
|
o2: AnyObject
|
|
@@ -383,7 +384,7 @@ export declare const mergeDeepX: {
|
|
|
383
384
|
] | [
|
|
384
385
|
o1: AnyObject
|
|
385
386
|
]) => any>;
|
|
386
|
-
(a: AnyObject): (b: AnyObject) =>
|
|
387
|
+
(a: AnyObject): (b: AnyObject) => FT.Curry<(...p: [
|
|
387
388
|
] | [
|
|
388
389
|
o1: AnyObject,
|
|
389
390
|
o2: AnyObject
|
|
@@ -392,7 +393,7 @@ export declare const mergeDeepX: {
|
|
|
392
393
|
] | [
|
|
393
394
|
o1: AnyObject
|
|
394
395
|
]) => any>;
|
|
395
|
-
(a: AnyObject, b: AnyObject):
|
|
396
|
+
(a: AnyObject, b: AnyObject): FT.Curry<(...p: [
|
|
396
397
|
] | [
|
|
397
398
|
o1: AnyObject,
|
|
398
399
|
o2: AnyObject
|
|
@@ -403,7 +404,7 @@ export declare const mergeDeepX: {
|
|
|
403
404
|
]) => any>;
|
|
404
405
|
};
|
|
405
406
|
export declare const mergeDeepAdd: {
|
|
406
|
-
(a: symbol, b: AnyObject): (a: AnyObject) =>
|
|
407
|
+
(a: symbol, b: AnyObject): (a: AnyObject) => FT.Curry<(...p: [
|
|
407
408
|
] | [
|
|
408
409
|
o1: AnyObject,
|
|
409
410
|
o2: AnyObject
|
|
@@ -412,7 +413,7 @@ export declare const mergeDeepAdd: {
|
|
|
412
413
|
] | [
|
|
413
414
|
o1: AnyObject
|
|
414
415
|
]) => any>;
|
|
415
|
-
(a: AnyObject, b: symbol): (b: AnyObject) =>
|
|
416
|
+
(a: AnyObject, b: symbol): (b: AnyObject) => FT.Curry<(...p: [
|
|
416
417
|
] | [
|
|
417
418
|
o1: AnyObject,
|
|
418
419
|
o2: AnyObject
|
|
@@ -421,7 +422,7 @@ export declare const mergeDeepAdd: {
|
|
|
421
422
|
] | [
|
|
422
423
|
o1: AnyObject
|
|
423
424
|
]) => any>;
|
|
424
|
-
(a: AnyObject): (b: AnyObject) =>
|
|
425
|
+
(a: AnyObject): (b: AnyObject) => FT.Curry<(...p: [
|
|
425
426
|
] | [
|
|
426
427
|
o1: AnyObject,
|
|
427
428
|
o2: AnyObject
|
|
@@ -430,7 +431,7 @@ export declare const mergeDeepAdd: {
|
|
|
430
431
|
] | [
|
|
431
432
|
o1: AnyObject
|
|
432
433
|
]) => any>;
|
|
433
|
-
(a: AnyObject, b: AnyObject):
|
|
434
|
+
(a: AnyObject, b: AnyObject): FT.Curry<(...p: [
|
|
434
435
|
] | [
|
|
435
436
|
o1: AnyObject,
|
|
436
437
|
o2: AnyObject
|
|
@@ -440,7 +441,7 @@ export declare const mergeDeepAdd: {
|
|
|
440
441
|
o1: AnyObject
|
|
441
442
|
]) => any>;
|
|
442
443
|
};
|
|
443
|
-
export declare const overProp:
|
|
444
|
+
export declare const overProp: FT.Curry<(prop: string, pipe: AnyFunc, data: any) => FT.Curry<(...p: [
|
|
444
445
|
] | [
|
|
445
446
|
v: any,
|
|
446
447
|
obj: AnyObject
|
package/dist/bundle.esm.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const e=Symbol("Placeholder"),r=r=>{let t=0;for(const n of r)n!==e&&t++;return t},t=(r,t)=>{const n=r.length,s=r.slice(),c=t.length;let o=c,u=0;for(;o&&u<n;u++)s[u]===e&&(s[u]=t[c-o],o--);for(u=n;o;u++,o--)s[u]=t[c-o];return s},n=(e,s,c)=>{const o=e.length-s.length-r(c);if(o<1)return e(...t(s,c));{const r=(...r)=>n(e,t(s,c),r);return r.$args_left=o,r}},s=e=>(...t)=>e.length>r(t)?n(e,[],t):e(...t),c=r=>function(t){return t===e?r:r(t)};function o(r){return function(t,n){const s=t===e,o=arguments.length;if(1===o&&s)throw new Error("Senseless placeholder usage.");return arguments.length>1?s?c((e=>r(e,n))):r(t,n):e=>r(t,e)}}function u(e){return s(e)}const a=void 0,i=1/0,l=e=>typeof e,f=e=>null===e,h=e=>"number"==l(e),b=e=>Array.isArray(e),g=e=>"function"===l(e),p={u:"U",b:"B",n:"N",s:"S",f:"F"},y=e=>e.toLowerCase(),d=e=>e.toUpperCase(),j=e=>{const r=l(e);return"object"===r?f(e)?"Null":e.constructor.name:p[r[0]]+r.slice(1)},m=o(((e,r)=>j(r)===e)),w=o(((e,r)=>(r.push(e),r))),O=u(((e,r,t)=>(t[e]=r,t))),A=u(((e,r,t)=>t.reduce(e,r))),S=u(((e,r,t)=>{for(let n in t)switch(j(t[n])){case"Array":if(e>1&&"Array"===j(r[n]))switch(e){case 2:const s=r[n],c=t[n];for(const r in c)s[r]?S(e,s[r],c[r]):s[r]=c[r];break;case 3:r[n].push(...t[n])}else r[n]=t[n];break;case"Object":if("Object"===j(r[n])){S(e,r[n],t[n]);break}default:r[n]=t[n]}return r})),k=S(1),v=S(2),N=S(3),x=o(((e,r)=>{let t,n,s,c;for(t in e)n=e[t],[s,c]=g(n)?n(r):[n,r[t]],r[s]=c,t!==s&&delete r[t];return r})),C=o(((e,r)=>{const t=b(r);for(let n in r)e(r[n],n)||(t?r.splice(n,1):delete r[n]);return r})),P=o(((e,r)=>r.indexOf(e))),$=e=>(...r)=>A(((e,r)=>e?e(r):e),e,r),B=e=>(...r)=>r[e],E=o(((e,r)=>{const t=j(e);if(t===j(r)&&("Object"===t||"Array"==t)){if(f(e)||f(r))return e===r;if(e===r)return!0;for(const t of[e,r])for(const n in t)if(!(t===r&&n in e||t===e&&n in r&&E(e[n],r[n])))return!1;return!0}return e===r})),U=s(((e,r,t,n)=>e(n)?r(n):t(n))),_=u(((e,r,t)=>U(e,r,W,t))),F=(...r)=>(...t)=>{let n,s=!0;for(let c=T(r)-1;c>-1;c--)s?(s=!1,n=r[c](...t)):n=n===e?r[c]():r[c](n);return n},I=o(((e,r)=>e.bind(r))),L=o(((e,r)=>r[e])),q=o(((e,r)=>{if((e=>"string"===l(e))(r))return r.includes(e);for(const t of r)if(E(t,e))return!0;return!1})),z=u(((e,r,t)=>t.slice(e,h(r)?r:i))),D=L(0),
|
|
1
|
+
const e=Symbol("Placeholder"),r=r=>{let t=0;for(const n of r)n!==e&&t++;return t},t=(r,t)=>{const n=r.length,s=r.slice(),c=t.length;let o=c,u=0;for(;o&&u<n;u++)s[u]===e&&(s[u]=t[c-o],o--);for(u=n;o;u++,o--)s[u]=t[c-o];return s},n=(e,s,c)=>{const o=e.length-s.length-r(c);if(o<1)return e(...t(s,c));{const r=(...r)=>n(e,t(s,c),r);return r.$args_left=o,r}},s=e=>(...t)=>e.length>r(t)?n(e,[],t):e(...t),c=r=>function(t){return t===e?r:r(t)};function o(r){return function(t,n){const s=t===e,o=arguments.length;if(1===o&&s)throw new Error("Senseless placeholder usage.");return arguments.length>1?s?c((e=>r(e,n))):r(t,n):e=>r(t,e)}}function u(e){return s(e)}const a=void 0,i=1/0,l=e=>typeof e,f=e=>null===e,h=e=>"number"==l(e),b=e=>Array.isArray(e),g=e=>"function"===l(e),p={u:"U",b:"B",n:"N",s:"S",f:"F"},y=e=>e.toLowerCase(),d=e=>e.toUpperCase(),j=e=>{const r=l(e);return"object"===r?f(e)?"Null":e.constructor.name:p[r[0]]+r.slice(1)},m=o(((e,r)=>j(r)===e)),w=o(((e,r)=>(r.push(e),r))),O=u(((e,r,t)=>(t[e]=r,t))),A=u(((e,r,t)=>t.reduce(e,r))),S=u(((e,r,t)=>{for(let n in t)switch(j(t[n])){case"Array":if(e>1&&"Array"===j(r[n]))switch(e){case 2:const s=r[n],c=t[n];for(const r in c)s[r]?S(e,s[r],c[r]):s[r]=c[r];break;case 3:r[n].push(...t[n])}else r[n]=t[n];break;case"Object":if("Object"===j(r[n])){S(e,r[n],t[n]);break}default:r[n]=t[n]}return r})),k=S(1),v=S(2),N=S(3),x=o(((e,r)=>{let t,n,s,c;for(t in e)n=e[t],[s,c]=g(n)?n(r):[n,r[t]],r[s]=c,t!==s&&delete r[t];return r})),C=o(((e,r)=>{const t=b(r);for(let n in r)e(r[n],n)||(t?r.splice(n,1):delete r[n]);return r})),P=o(((e,r)=>r.indexOf(e))),$=e=>(...r)=>A(((e,r)=>e?e(r):e),e,r),B=e=>(...r)=>r[e],E=o(((e,r)=>{const t=j(e);if(t===j(r)&&("Object"===t||"Array"==t)){if(f(e)||f(r))return e===r;if(e===r)return!0;for(const t of[e,r])for(const n in t)if(!(t===r&&n in e||t===e&&n in r&&E(e[n],r[n])))return!1;return!0}return e===r})),U=s(((e,r,t,n)=>e(n)?r(n):t(n))),_=u(((e,r,t)=>U(e,r,W,t))),F=(...r)=>(...t)=>{let n,s=!0;for(let c=T(r)-1;c>-1;c--)s?(s=!1,n=r[c](...t)):n=n===e?r[c]():r[c](n);return n},I=o(((e,r)=>e.bind(r))),L=o(((e,r)=>r[e])),q=o(((e,r)=>{if((e=>"string"===l(e))(r))return r.includes(e);for(const t of r)if(E(t,e))return!0;return!1})),z=u(((e,r,t)=>t.slice(e,h(r)?r:i))),D=e=>o(((r,t)=>e(t,r))),G=L(0),H=z(1,i),J=o(((e,r)=>e+r)),K=o(((e,r)=>r-e)),M=o(((e,r)=>e*r)),Q=o(((e,r)=>e/r)),R=e=>f(e)||(e=>e===a)(e),T=e=>e.length,V=e=>()=>e,W=e=>e,X=e=>e.trim(),Y=e=>e[T(e)-1],Z=e=>!e,ee=e=>(...r)=>{const t=e(...r);return g(t)&&t.$args_left?ee(t):Z(t)},re=e=>Object.keys(e),te=e=>Object.values(e),ne=e=>Object.entries(e),se=o(((e,r)=>e.test(r))),ce=o(((e,r)=>(e(r),r))),oe=o(((e,r)=>[...r,e])),ue=o(((e,r)=>r.split(e))),ae=V(!0),ie=V(!1),le=e=>{if("Object"===j(e)){let r=0;for(let t in e)r++;return r}return T(e)},fe=o(((e,r)=>ge(J(e),r-e))),he=e=>A(((e,r)=>q(r,e)?e:w(r,e)),[],e),be=o(((e,r)=>e.filter(D(q)(r)))),ge=o(((e,r)=>[...Array(r)].map(((r,t)=>e(t))))),pe=e=>{let r,t=!1;return(...n)=>t?r:(t=!0,r=e(...n))},ye=e=>F((r=>Je(((t,n,s)=>w(e[r-s],t)),[],e)),J(-1),T)(e),de=o(((e,r)=>e>r)),je=o(((e,r)=>e<r)),me=o(((e,r)=>r>=e)),we=o(((e,r)=>r<=e)),Oe=o(((e,r)=>r.sort(e))),Ae=o(((e,r)=>r.find(e))),Se=o(((e,r)=>r.findIndex(e))),ke=o(((e,r)=>Se(E(e),r))),ve=(e,r="log")=>ce((t=>console[r](e,t))),Ne=o(((e,r)=>{for(const[t,n]of e)if(t(r))return n(r)})),xe=u(((e,r,t)=>({...t,[e]:r}))),Ce=u(((e,r,t)=>F((n=>{return xe(n,T(e)<2?r:Ce(z(1,i,e),r,(s=t[n],f(s)||"object"!==l(s)?{}:t[n])),t);var s}),G)(e))),Pe=o(((e,r)=>r.every(e))),$e=o(((e,r)=>r.some(e))),Be=o(((e,r)=>e.every((e=>e(r))))),Ee=o(((e,r)=>e.some((e=>e(r))))),Ue=o(((e,r)=>r[e])),_e=u(((e,r,t)=>E(t[e],r))),Fe=u(((e,r,t)=>E(r[e],t[e]))),Ie=u(((e,r,t)=>U(T,(()=>R(t)?e:F(U(R,V(e),(t=>Ie(e,z(1,i,r),t))),D(Ue)(t),G)(r)),V(t),r))),Le=Ie(a),qe=u(((e,r,t)=>E(Le(e,t),r))),ze=u(((e,r,t)=>E(Le(e,r),Le(e,t)))),De=/^(.*?)(8|16|32|64)(Clamped)?Array$/,Ge=(e,r=!1)=>{const t=j(e);switch(t){case"Null":case"String":case"Number":case"Boolean":case"Symbol":return e;case"Array":return r?[...e]:We(Ge,e);case"Object":if(r)return{...e};const n={};for(let r in e)n[r]=Ge(e[r]);return n;default:return De.test(t)?e.constructor.from(e):e}},He=e=>Ge(e,!0),Je=u(((e,r,t)=>A(e,Ge(r),t))),Ke=o(((e,r)=>tr(e,r))),Me=o(((e,r)=>{const t={};for(const n of e)n in r&&(t[n]=r[n]);return t})),Qe=o(((e,r)=>tr(((r,t)=>!q(t,e)),r))),Re=e=>Je(((e,r)=>xe(...r,e)),{},e),Te=o(((e,r)=>e.concat(r))),Ve=o(((e,r)=>r.join(e))),We=o(((e,r)=>r.map(e))),Xe=o(((e,r)=>r.forEach(e))),Ye=u(((e,r,t)=>r(t)&&e(t))),Ze=e=>{switch(j(e)){case"String":case"Array":return 0==T(e);case"Object":for(const r in e)return!1;return!0;default:return null}},er=e=>{switch(j(e)){case"String":return"";case"Object":return{};case"Array":return[];default:return a}},rr=u(((e,r,t)=>t.replace(e,r))),tr=o(((e,r)=>b(r)?r.filter(e):F(Re,tr((([r,t])=>e(t,r))),ne)(r))),nr=e=>{let r,t=!1;return()=>t?r:(t=!0,r=e())},sr=o(((e,r)=>Object.assign({},e,r))),cr=o(((e,r)=>k(Ge(e),Ge(r)))),or=o(((e,r)=>v(Ge(e),Ge(r)))),ur=o(((e,r)=>N(Ge(e),Ge(r)))),ar=u(((e,r,t)=>xe(e,r(t[e]),t))),ir=o(((e,r)=>x(e,Object.assign({},r)))),lr=(()=>{const e=async(r,t,n)=>{n<t.length&&(await r(t[n]),await e(r,t,++n))};return o(((r,t)=>e(r,t,0)))})(),fr=e=>Promise.all(e),hr=o((async(e,r)=>(await e(r),r))),br=o(((e,r)=>Promise.all(r.map(e)))),gr=(()=>{const e=async(r,t,n)=>~n?await e(r,await r[n](t),--n):t;return(...r)=>t=>e(r,t,r.length-1)})(),pr=W,yr=W,dr=W,jr=e=>{const r=[],t=[],n=e.length;let s,c,o,u=0,a=0,i=!1,l=G(e),f=!1;for(u=0;u<n;u++)switch(s=e[u],s){case"{":if(!l){i=!0,a=u;break}case"}":if(!l){i=!1,r.push(""),t.push(e.slice(a+1,u));break}default:o=e[u+1],f="\\"===s,i||f&&("{"===o||"}"===o)||(c=r.length-1,c<0&&(r.push(""),c++),r[c]+=s),l=f}return e=>{const n=[],s=r.length-1;for(const c in r)u=+c,n.push(r[u]),u!==s&&n.push(Le(t[u].split("."),e));return n.join("")}};export{ie as F,ae as T,e as __,J as add,Pe as all,Be as allPass,V as always,$e as any,Ee as anyPass,oe as append,xe as assoc,Ce as assocPath,I as bind,Ye as both,Ge as clone,He as cloneShallow,ee as complement,F as compose,gr as composeAsync,Te as concat,Ne as cond,s as curry,o as curry2,u as curry3,Q as divide,dr as echo,er as empty,E as equals,ve as explore,tr as filter,Ae as find,Se as findIndex,D as flip,Xe as forEach,br as forEachAsync,lr as forEachSerial,Re as fromPairs,ge as genBy,jr as getTmpl,de as gt,me as gte,G as head,W as identity,U as ifElse,q as includes,ke as indexOf,be as intersection,Ze as isEmpty,R as isNil,Ve as join,re as keys,Y as last,T as length,je as lt,we as lte,We as map,ir as mapKeys,nr as memoize,cr as mergeDeep,ur as mergeDeepAdd,or as mergeDeepX,sr as mergeShallow,pr as mirror,M as multiply,Z as not,L as nth,Qe as omit,pe as once,ar as overProp,Le as path,qe as pathEq,Ie as pathOr,ze as pathsEq,Me as pick,Ke as pickBy,Ue as prop,_e as propEq,Fe as propsEq,w as qappend,O as qassoc,C as qfilter,P as qindexOf,x as qmapKeys,k as qmergeDeep,N as qmergeDeepAdd,v as qmergeDeepX,A as qreduce,fe as range,Je as reduce,yr as reflect,rr as replace,ye as reverse,le as sizeof,z as slice,Oe as sort,ue as split,K as subtract,H as tail,B as take,ce as tap,se as test,y as toLower,ne as toPairs,d as toUpper,X as trim,j as type,m as typeIs,$ as uncurry,he as uniq,te as values,fr as waitAll,hr as waitTap,_ as when};
|
package/dist/bundle.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const e=Symbol("Placeholder"),r=r=>{let t=0;for(const s of r)s!==e&&t++;return t},t=(r,t)=>{const s=r.length,o=r.slice(),p=t.length;let n=p,c=0;for(;n&&c<s;c++)o[c]===e&&(o[c]=t[p-n],n--);for(c=s;n;c++,n--)o[c]=t[p-n];return o},s=(e,o,p)=>{const n=e.length-o.length-r(p);if(n<1)return e(...t(o,p));{const r=(...r)=>s(e,t(o,p),r);return r.$args_left=n,r}},o=e=>(...t)=>e.length>r(t)?s(e,[],t):e(...t),p=r=>function(t){return t===e?r:r(t)};function n(r){return function(t,s){const o=t===e,n=arguments.length;if(1===n&&o)throw new Error("Senseless placeholder usage.");return arguments.length>1?o?p((e=>r(e,s))):r(t,s):e=>r(t,e)}}function c(e){return o(e)}const x=void 0,a=1/0,i=e=>typeof e,l=e=>null===e,u=e=>"number"==i(e),f=e=>Array.isArray(e),h=e=>"function"===i(e),d={u:"U",b:"B",n:"N",s:"S",f:"F"},m=e=>{const r=i(e);return"object"===r?l(e)?"Null":e.constructor.name:d[r[0]]+r.slice(1)},y=n(((e,r)=>m(r)===e)),g=n(((e,r)=>(r.push(e),r))),b=c(((e,r,t)=>(t[e]=r,t))),w=c(((e,r,t)=>t.reduce(e,r))),j=c(((e,r,t)=>{for(let s in t)switch(m(t[s])){case"Array":if(e>1&&"Array"===m(r[s]))switch(e){case 2:const o=r[s],p=t[s];for(const r in p)o[r]?j(e,o[r],p[r]):o[r]=p[r];break;case 3:r[s].push(...t[s])}else r[s]=t[s];break;case"Object":if("Object"===m(r[s])){j(e,r[s],t[s]);break}default:r[s]=t[s]}return r})),O=j(1),q=j(2),A=j(3),E=n(((e,r)=>{let t,s,o,p;for(t in e)s=e[t],[o,p]=h(s)?s(r):[s,r[t]],r[o]=p,t!==o&&delete r[t];return r})),k=n(((e,r)=>{const t=f(r);for(let s in r)e(r[s],s)||(t?r.splice(s,1):delete r[s]);return r})),S=n(((e,r)=>r.indexOf(e))),v=n(((e,r)=>{const t=m(e);if(t===m(r)&&("Object"===t||"Array"==t)){if(l(e)||l(r))return e===r;if(e===r)return!0;for(const t of[e,r])for(const s in t)if(!(t===r&&s in e||t===e&&s in r&&v(e[s],r[s])))return!1;return!0}return e===r})),P=o(((e,r,t,s)=>e(s)?r(s):t(s))),D=c(((e,r,t)=>P(e,r,J,t))),N=(...r)=>(...t)=>{let s,o=!0;for(let p=G(r)-1;p>-1;p--)o?(o=!1,s=r[p](...t)):s=s===e?r[p]():r[p](s);return s},B=n(((e,r)=>e.bind(r))),_=n(((e,r)=>r[e])),C=n(((e,r)=>{if((e=>"string"===i(e))(r))return r.includes(e);for(const t of r)if(v(t,e))return!0;return!1})),I=c(((e,r,t)=>t.slice(e,u(r)?r:a))),T=
|
|
1
|
+
"use strict";const e=Symbol("Placeholder"),r=r=>{let t=0;for(const s of r)s!==e&&t++;return t},t=(r,t)=>{const s=r.length,o=r.slice(),p=t.length;let n=p,c=0;for(;n&&c<s;c++)o[c]===e&&(o[c]=t[p-n],n--);for(c=s;n;c++,n--)o[c]=t[p-n];return o},s=(e,o,p)=>{const n=e.length-o.length-r(p);if(n<1)return e(...t(o,p));{const r=(...r)=>s(e,t(o,p),r);return r.$args_left=n,r}},o=e=>(...t)=>e.length>r(t)?s(e,[],t):e(...t),p=r=>function(t){return t===e?r:r(t)};function n(r){return function(t,s){const o=t===e,n=arguments.length;if(1===n&&o)throw new Error("Senseless placeholder usage.");return arguments.length>1?o?p((e=>r(e,s))):r(t,s):e=>r(t,e)}}function c(e){return o(e)}const x=void 0,a=1/0,i=e=>typeof e,l=e=>null===e,u=e=>"number"==i(e),f=e=>Array.isArray(e),h=e=>"function"===i(e),d={u:"U",b:"B",n:"N",s:"S",f:"F"},m=e=>{const r=i(e);return"object"===r?l(e)?"Null":e.constructor.name:d[r[0]]+r.slice(1)},y=n(((e,r)=>m(r)===e)),g=n(((e,r)=>(r.push(e),r))),b=c(((e,r,t)=>(t[e]=r,t))),w=c(((e,r,t)=>t.reduce(e,r))),j=c(((e,r,t)=>{for(let s in t)switch(m(t[s])){case"Array":if(e>1&&"Array"===m(r[s]))switch(e){case 2:const o=r[s],p=t[s];for(const r in p)o[r]?j(e,o[r],p[r]):o[r]=p[r];break;case 3:r[s].push(...t[s])}else r[s]=t[s];break;case"Object":if("Object"===m(r[s])){j(e,r[s],t[s]);break}default:r[s]=t[s]}return r})),O=j(1),q=j(2),A=j(3),E=n(((e,r)=>{let t,s,o,p;for(t in e)s=e[t],[o,p]=h(s)?s(r):[s,r[t]],r[o]=p,t!==o&&delete r[t];return r})),k=n(((e,r)=>{const t=f(r);for(let s in r)e(r[s],s)||(t?r.splice(s,1):delete r[s]);return r})),S=n(((e,r)=>r.indexOf(e))),v=n(((e,r)=>{const t=m(e);if(t===m(r)&&("Object"===t||"Array"==t)){if(l(e)||l(r))return e===r;if(e===r)return!0;for(const t of[e,r])for(const s in t)if(!(t===r&&s in e||t===e&&s in r&&v(e[s],r[s])))return!1;return!0}return e===r})),P=o(((e,r,t,s)=>e(s)?r(s):t(s))),D=c(((e,r,t)=>P(e,r,J,t))),N=(...r)=>(...t)=>{let s,o=!0;for(let p=G(r)-1;p>-1;p--)o?(o=!1,s=r[p](...t)):s=s===e?r[p]():r[p](s);return s},B=n(((e,r)=>e.bind(r))),_=n(((e,r)=>r[e])),C=n(((e,r)=>{if((e=>"string"===i(e))(r))return r.includes(e);for(const t of r)if(v(t,e))return!0;return!1})),I=c(((e,r,t)=>t.slice(e,u(r)?r:a))),T=e=>n(((r,t)=>e(t,r))),U=_(0),$=I(1,a),z=n(((e,r)=>e+r)),F=n(((e,r)=>r-e)),K=n(((e,r)=>e*r)),L=n(((e,r)=>e/r)),X=e=>l(e)||(e=>e===x)(e),G=e=>e.length,H=e=>()=>e,J=e=>e,M=e=>!e,Q=e=>(...r)=>{const t=e(...r);return h(t)&&t.$args_left?Q(t):M(t)},R=e=>Object.entries(e),V=n(((e,r)=>e.test(r))),W=n(((e,r)=>(e(r),r))),Y=n(((e,r)=>[...r,e])),Z=n(((e,r)=>r.split(e))),ee=H(!0),re=H(!1),te=n(((e,r)=>oe(z(e),r-e))),se=n(((e,r)=>e.filter(T(C)(r)))),oe=n(((e,r)=>[...Array(r)].map(((r,t)=>e(t))))),pe=n(((e,r)=>e>r)),ne=n(((e,r)=>e<r)),ce=n(((e,r)=>r>=e)),xe=n(((e,r)=>r<=e)),ae=n(((e,r)=>r.sort(e))),ie=n(((e,r)=>r.find(e))),le=n(((e,r)=>r.findIndex(e))),ue=n(((e,r)=>le(v(e),r))),fe=n(((e,r)=>{for(const[t,s]of e)if(t(r))return s(r)})),he=c(((e,r,t)=>({...t,[e]:r}))),de=c(((e,r,t)=>N((s=>{return he(s,G(e)<2?r:de(I(1,a,e),r,(o=t[s],l(o)||"object"!==i(o)?{}:t[s])),t);var o}),U)(e))),me=n(((e,r)=>r.every(e))),ye=n(((e,r)=>r.some(e))),ge=n(((e,r)=>e.every((e=>e(r))))),be=n(((e,r)=>e.some((e=>e(r))))),we=n(((e,r)=>r[e])),je=c(((e,r,t)=>v(t[e],r))),Oe=c(((e,r,t)=>v(r[e],t[e]))),qe=c(((e,r,t)=>P(G,(()=>X(t)?e:N(P(X,H(e),(t=>qe(e,I(1,a,r),t))),T(we)(t),U)(r)),H(t),r))),Ae=qe(x),Ee=c(((e,r,t)=>v(Ae(e,t),r))),ke=c(((e,r,t)=>v(Ae(e,r),Ae(e,t)))),Se=/^(.*?)(8|16|32|64)(Clamped)?Array$/,ve=(e,r=!1)=>{const t=m(e);switch(t){case"Null":case"String":case"Number":case"Boolean":case"Symbol":return e;case"Array":return r?[...e]:Te(ve,e);case"Object":if(r)return{...e};const s={};for(let r in e)s[r]=ve(e[r]);return s;default:return Se.test(t)?e.constructor.from(e):e}},Pe=c(((e,r,t)=>w(e,ve(r),t))),De=n(((e,r)=>Fe(e,r))),Ne=n(((e,r)=>{const t={};for(const s of e)s in r&&(t[s]=r[s]);return t})),Be=n(((e,r)=>Fe(((r,t)=>!C(t,e)),r))),_e=e=>Pe(((e,r)=>he(...r,e)),{},e),Ce=n(((e,r)=>e.concat(r))),Ie=n(((e,r)=>r.join(e))),Te=n(((e,r)=>r.map(e))),Ue=n(((e,r)=>r.forEach(e))),$e=c(((e,r,t)=>r(t)&&e(t))),ze=c(((e,r,t)=>t.replace(e,r))),Fe=n(((e,r)=>f(r)?r.filter(e):N(_e,Fe((([r,t])=>e(t,r))),R)(r))),Ke=n(((e,r)=>Object.assign({},e,r))),Le=n(((e,r)=>O(ve(e),ve(r)))),Xe=n(((e,r)=>q(ve(e),ve(r)))),Ge=n(((e,r)=>A(ve(e),ve(r)))),He=c(((e,r,t)=>he(e,r(t[e]),t))),Je=n(((e,r)=>E(e,Object.assign({},r)))),Me=(()=>{const e=async(r,t,s)=>{s<t.length&&(await r(t[s]),await e(r,t,++s))};return n(((r,t)=>e(r,t,0)))})(),Qe=n((async(e,r)=>(await e(r),r))),Re=n(((e,r)=>Promise.all(r.map(e)))),Ve=(()=>{const e=async(r,t,s)=>~s?await e(r,await r[s](t),--s):t;return(...r)=>t=>e(r,t,r.length-1)})(),We=J,Ye=J,Ze=J;exports.F=re,exports.T=ee,exports.__=e,exports.add=z,exports.all=me,exports.allPass=ge,exports.always=H,exports.any=ye,exports.anyPass=be,exports.append=Y,exports.assoc=he,exports.assocPath=de,exports.bind=B,exports.both=$e,exports.clone=ve,exports.cloneShallow=e=>ve(e,!0),exports.complement=Q,exports.compose=N,exports.composeAsync=Ve,exports.concat=Ce,exports.cond=fe,exports.curry=o,exports.curry2=n,exports.curry3=c,exports.divide=L,exports.echo=Ze,exports.empty=e=>{switch(m(e)){case"String":return"";case"Object":return{};case"Array":return[];default:return x}},exports.equals=v,exports.explore=(e,r="log")=>W((t=>console[r](e,t))),exports.filter=Fe,exports.find=ie,exports.findIndex=le,exports.flip=T,exports.forEach=Ue,exports.forEachAsync=Re,exports.forEachSerial=Me,exports.fromPairs=_e,exports.genBy=oe,exports.getTmpl=e=>{const r=[],t=[],s=e.length;let o,p,n,c=0,x=0,a=!1,i=U(e),l=!1;for(c=0;c<s;c++)switch(o=e[c],o){case"{":if(!i){a=!0,x=c;break}case"}":if(!i){a=!1,r.push(""),t.push(e.slice(x+1,c));break}default:n=e[c+1],l="\\"===o,a||l&&("{"===n||"}"===n)||(p=r.length-1,p<0&&(r.push(""),p++),r[p]+=o),i=l}return e=>{const s=[],o=r.length-1;for(const p in r)c=+p,s.push(r[c]),c!==o&&s.push(Ae(t[c].split("."),e));return s.join("")}},exports.gt=pe,exports.gte=ce,exports.head=U,exports.identity=J,exports.ifElse=P,exports.includes=C,exports.indexOf=ue,exports.intersection=se,exports.isEmpty=e=>{switch(m(e)){case"String":case"Array":return 0==G(e);case"Object":for(const r in e)return!1;return!0;default:return null}},exports.isNil=X,exports.join=Ie,exports.keys=e=>Object.keys(e),exports.last=e=>e[G(e)-1],exports.length=G,exports.lt=ne,exports.lte=xe,exports.map=Te,exports.mapKeys=Je,exports.memoize=e=>{let r,t=!1;return()=>t?r:(t=!0,r=e())},exports.mergeDeep=Le,exports.mergeDeepAdd=Ge,exports.mergeDeepX=Xe,exports.mergeShallow=Ke,exports.mirror=We,exports.multiply=K,exports.not=M,exports.nth=_,exports.omit=Be,exports.once=e=>{let r,t=!1;return(...s)=>t?r:(t=!0,r=e(...s))},exports.overProp=He,exports.path=Ae,exports.pathEq=Ee,exports.pathOr=qe,exports.pathsEq=ke,exports.pick=Ne,exports.pickBy=De,exports.prop=we,exports.propEq=je,exports.propsEq=Oe,exports.qappend=g,exports.qassoc=b,exports.qfilter=k,exports.qindexOf=S,exports.qmapKeys=E,exports.qmergeDeep=O,exports.qmergeDeepAdd=A,exports.qmergeDeepX=q,exports.qreduce=w,exports.range=te,exports.reduce=Pe,exports.reflect=Ye,exports.replace=ze,exports.reverse=e=>N((r=>Pe(((t,s,o)=>g(e[r-o],t)),[],e)),z(-1),G)(e),exports.sizeof=e=>{if("Object"===m(e)){let r=0;for(let t in e)r++;return r}return G(e)},exports.slice=I,exports.sort=ae,exports.split=Z,exports.subtract=F,exports.tail=$,exports.take=e=>(...r)=>r[e],exports.tap=W,exports.test=V,exports.toLower=e=>e.toLowerCase(),exports.toPairs=R,exports.toUpper=e=>e.toUpperCase(),exports.trim=e=>e.trim(),exports.type=m,exports.typeIs=y,exports.uncurry=e=>(...r)=>w(((e,r)=>e?e(r):e),e,r),exports.uniq=e=>w(((e,r)=>C(r,e)?e:g(r,e)),[],e),exports.values=e=>Object.values(e),exports.waitAll=e=>Promise.all(e),exports.waitTap=Qe,exports.when=D;
|
package/package.json
CHANGED
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"prod": "npm run gentypes && npm run prod:es && npm run prod:cjs",
|
|
43
43
|
"all": "npm run dev && npm run prod"
|
|
44
44
|
},
|
|
45
|
-
"version": "0.14.0-
|
|
45
|
+
"version": "0.14.0-beta1",
|
|
46
46
|
"ava": {
|
|
47
47
|
"files": [ "./test/specs/*.ts" ],
|
|
48
48
|
"failFast": true,
|
|
@@ -69,7 +69,7 @@
|
|
|
69
69
|
"rollup-plugin-typescript2": "^0.34.1",
|
|
70
70
|
"ts-node": "^10.9.1",
|
|
71
71
|
"tslint": "^6.1.0",
|
|
72
|
-
"typescript": "^4.9.
|
|
72
|
+
"typescript": "^4.9.4"
|
|
73
73
|
},
|
|
74
74
|
"types": "./dist/bundle.d.ts",
|
|
75
75
|
"sideEffects": false
|
package/src/curry.ts
CHANGED
package/src/safe.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import { F as FT } from 'ts-toolbelt'
|
|
1
2
|
import { __, curry, curry2, curry3 } from './curry'
|
|
2
3
|
import { isNum, isUndef, undef, isNull, isArray, isFunc, isStr, isObj, inf } from './utils'
|
|
3
4
|
import { qmergeDeep, qreduce, qappend, qmapKeys, qmergeDeepX, qmergeDeepAdd } from './quick'
|
|
4
|
-
import { AnyFunc, Cond, AnyObject, Reducer } from './types'
|
|
5
|
+
import { AnyFunc, Cond, AnyObject, Reducer, Curried } from './types'
|
|
5
6
|
import { type } from './common'
|
|
6
7
|
// SomeType, totype, over, lensProp
|
|
7
8
|
|
|
@@ -86,13 +87,17 @@ export const slice = curry3(
|
|
|
86
87
|
(from: number, to: number, o: any[] | string) =>
|
|
87
88
|
o.slice(from, (isNum(to)?to:inf) as number)
|
|
88
89
|
)
|
|
90
|
+
type TupleFn<ARG1=any, ARG2=any, Out=any> = (a: ARG1, b: ARG2) => Out
|
|
91
|
+
export const flip = <ARG1=any, ARG2=any, Out=any>(
|
|
92
|
+
fn: FT.Curry<TupleFn<ARG1, ARG2, Out>>
|
|
93
|
+
): FT.Curry<TupleFn<ARG2, ARG1, Out>> =>
|
|
94
|
+
curry2((b: ARG2, a: ARG1) => fn(a as any, b as any))
|
|
89
95
|
export const head = nth(0)
|
|
90
96
|
export const tail = slice(1, inf) // typeshit.
|
|
91
97
|
export const add = curry2((n: number, m: number) => n+m)
|
|
92
98
|
export const subtract = curry2((n: number, m: number) => m-n)
|
|
93
99
|
export const multiply = curry2((n: number, m: number) => n*m)
|
|
94
100
|
export const divide = curry2((n: number, m: number) => n/m)
|
|
95
|
-
export const flip = (fn: Function) => curry((b: any, a: any) => fn(a, b))
|
|
96
101
|
export const isNil = (s: any) => isNull(s) || isUndef(s)
|
|
97
102
|
export const length = (s: any[] | string) => s.length
|
|
98
103
|
export const always = <T=any>(s: T) => () => s
|