pepka 0.13.0-b7 → 0.13.0-beta10

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 CHANGED
@@ -9,10 +9,11 @@ export interface AnyObject {
9
9
  }
10
10
  export type AnyArgs = any[];
11
11
  export type Curried<Args extends AnyArgs = AnyArgs, ReturnT = any> = (arg: Args[number]) => Curried<Args> | ReturnT;
12
+ export type Reducer = <T = any>(accum: T, cur: any, index: number) => T;
12
13
  export type AnyFunc<ReturnT = any, Args extends AnyArgs = AnyArgs> = (...args: Args) => ReturnT;
13
14
  export type Placeholder = symbol;
14
15
  declare const __: Placeholder;
15
- export declare const curry: (fn: AnyFunc) => (...args: AnyArgs) => any;
16
+ export declare const curry: <Func extends AnyFunc<any, AnyArgs>>(fn: AnyFunc) => FT.Curry<Func>;
16
17
  export type Func2 = (a: any, b: any) => any;
17
18
  export declare function curry2<Func extends Func2>(fn: Func): {
18
19
  (a: Placeholder, b: Parameters<Func>[1]): (a: Parameters<Func>[0]) => ReturnType<Func>;
@@ -21,7 +22,7 @@ export declare function curry2<Func extends Func2>(fn: Func): {
21
22
  (a: Parameters<Func>[0], b: Parameters<Func>[1]): ReturnType<Func>;
22
23
  };
23
24
  export type Func3 = (a: any, b: any, c: any) => any;
24
- export declare function curry3<Func extends Func3>(fn: Func): (...args: AnyArgs) => any;
25
+ export declare function curry3<Func extends Func3>(fn: Func): FT.Curry<Func>;
25
26
  export declare const uncurry: <Args extends any[] = any[], ReturnT = any>(fn: Curried<Args, any>) => AnyFunc;
26
27
  export declare const toLower: (s: string) => string;
27
28
  export declare const toUpper: (s: string) => string;
@@ -32,9 +33,10 @@ export declare const equals: {
32
33
  (a: any): (b: any) => boolean;
33
34
  (a: any, b: any): boolean;
34
35
  };
35
- export declare const ifElse: (...args: AnyArgs) => any;
36
- export declare const when: (...args: AnyArgs) => any;
37
- export declare const compose: FT.Compose;
36
+ export declare const ifElse: FT.Curry<AnyFunc<any, AnyArgs>>;
37
+ export declare const when: FT.Curry<(cond: (s: any) => boolean, pipe: (s: any) => any, s: any) => any>;
38
+ export type Composed<TIn, TOut> = (x: TIn) => TOut;
39
+ export declare const compose: <TIn = any, TOut = any>(...fns: AnyFunc[]) => Composed<TIn, TOut>;
38
40
  export declare const bind: {
39
41
  (a: symbol, b: any): (a: any) => any;
40
42
  (a: any, b: symbol): (b: any) => any;
@@ -53,9 +55,9 @@ export declare const includes: {
53
55
  (a: unknown): (b: unknown[]) => boolean;
54
56
  (a: unknown, b: unknown[]): boolean;
55
57
  };
56
- export declare const slice: (...args: AnyArgs) => any;
58
+ export declare const slice: FT.Curry<(from: number, to: number, o: any[] | string) => string | any[]>;
57
59
  export declare const head: (b: string | unknown[]) => unknown;
58
- export declare const tail: any;
60
+ export declare const tail: FT.Curry<(o: string | any[]) => string | any[]>;
59
61
  export declare const add: {
60
62
  (a: symbol, b: number): (a: number) => number;
61
63
  (a: number, b: symbol): (b: number) => number;
@@ -68,7 +70,7 @@ export declare const subtract: {
68
70
  (a: number): (b: number) => number;
69
71
  (a: number, b: number): number;
70
72
  };
71
- export declare const flip: (fn: Function) => (...args: AnyArgs) => any;
73
+ export declare const flip: (fn: Function) => FT.Curry<AnyFunc<any, AnyArgs>>;
72
74
  export declare const isNil: (s: any) => boolean;
73
75
  export declare const length: (s: any[] | string) => number;
74
76
  export declare const always: <T = any>(s: T) => () => T;
@@ -198,7 +200,9 @@ export declare const cond: {
198
200
  Function
199
201
  ][], b: any): any;
200
202
  };
201
- export declare const assoc: (...args: AnyArgs) => any;
203
+ export declare const assoc: FT.Curry<(prop: string, v: any, obj: AnyObject) => {
204
+ [x: string]: any;
205
+ }>;
202
206
  export declare const assocPath: any;
203
207
  export declare const all: {
204
208
  (a: symbol, b: any[]): (a: Cond) => boolean;
@@ -230,15 +234,18 @@ export declare const prop: {
230
234
  (a: string): (b: AnyObject) => any;
231
235
  (a: string, b: AnyObject): any;
232
236
  };
233
- export declare const propEq: (...args: AnyArgs) => any;
234
- export declare const propsEq: (...args: AnyArgs) => any;
235
- export declare const pathOr: (...args: AnyArgs) => any;
236
- export declare const path: any;
237
- export declare const pathEq: (...args: AnyArgs) => any;
238
- export declare const pathsEq: (...args: AnyArgs) => any;
237
+ export declare const propEq: FT.Curry<(key: string, value: any, o: AnyObject) => boolean>;
238
+ export declare const propsEq: FT.Curry<(key: string, o1: any, o2: AnyObject) => boolean>;
239
+ export declare const pathOr: FT.Curry<(_default: any, path: string[], o: any) => any>;
240
+ export declare const path: FT.Curry<(path: string[], o: any) => any>;
241
+ export declare const pathEq: FT.Curry<(_path: string[], value: any, o: AnyObject) => (a: any) => boolean>;
242
+ export declare const pathsEq: FT.Curry<(_path: string[], o1: AnyObject, o2: AnyObject) => (a: any) => boolean>;
239
243
  export declare const clone: (s: any, shallow?: boolean) => any;
240
244
  export declare const cloneShallow: (s: any) => any;
241
- export declare const reduce: (...args: AnyArgs) => any;
245
+ export declare const reduce: FT.Curry<(fn: Reducer, accum: any, arr: any[]) => FT.Curry<(...p: [
246
+ ] | [
247
+ accum: any
248
+ ]) => any>>;
242
249
  export declare const pickBy: {
243
250
  (a: symbol, b: AnyObject): (a: Cond) => any;
244
251
  (a: Cond, b: symbol): (b: AnyObject) => any;
@@ -260,7 +267,10 @@ export declare const omit: {
260
267
  export declare const fromPairs: (pairs: [
261
268
  string,
262
269
  any
263
- ][]) => any;
270
+ ][]) => FT.Curry<(fn: Reducer, accum: any, arr: any[]) => FT.Curry<(...p: [
271
+ ] | [
272
+ accum: any
273
+ ]) => any>>;
264
274
  export declare const concat: {
265
275
  (a: symbol, b: string | any[]): (a: string | any[]) => string | any[];
266
276
  (a: string | any[], b: symbol): (b: string | any[]) => string | any[];
@@ -285,10 +295,10 @@ export declare const forEach: {
285
295
  (a: (s: any) => any): (b: any[]) => void;
286
296
  (a: (s: any) => any, b: any[]): void;
287
297
  };
288
- export declare const both: (...args: AnyArgs) => any;
298
+ export declare const both: FT.Curry<(cond1: Cond, cond2: Cond, s: any) => boolean>;
289
299
  export declare const isEmpty: (s: any) => boolean | null;
290
300
  export declare const empty: (s: any) => {} | undefined;
291
- export declare const replace: (...args: AnyArgs) => any;
301
+ export declare const replace: FT.Curry<(a: string | RegExp, b: string, where: string) => string>;
292
302
  export declare const filter: any;
293
303
  export declare const memoize: (fn: Function) => () => any;
294
304
  export declare const mergeShallow: {
@@ -298,24 +308,128 @@ export declare const mergeShallow: {
298
308
  (a: AnyObject, b: AnyObject): AnyObject;
299
309
  };
300
310
  export declare const mergeDeep: {
301
- (a: symbol, b: AnyObject): (a: AnyObject) => any;
302
- (a: AnyObject, b: symbol): (b: AnyObject) => any;
303
- (a: AnyObject): (b: AnyObject) => any;
304
- (a: AnyObject, b: AnyObject): any;
311
+ (a: symbol, b: AnyObject): (a: AnyObject) => FT.Curry<(...p: [
312
+ ] | [
313
+ o1: AnyObject,
314
+ o2: AnyObject
315
+ ] | [
316
+ o2: AnyObject
317
+ ] | [
318
+ o1: AnyObject
319
+ ]) => any>;
320
+ (a: AnyObject, b: symbol): (b: AnyObject) => FT.Curry<(...p: [
321
+ ] | [
322
+ o1: AnyObject,
323
+ o2: AnyObject
324
+ ] | [
325
+ o2: AnyObject
326
+ ] | [
327
+ o1: AnyObject
328
+ ]) => any>;
329
+ (a: AnyObject): (b: AnyObject) => FT.Curry<(...p: [
330
+ ] | [
331
+ o1: AnyObject,
332
+ o2: AnyObject
333
+ ] | [
334
+ o2: AnyObject
335
+ ] | [
336
+ o1: AnyObject
337
+ ]) => any>;
338
+ (a: AnyObject, b: AnyObject): FT.Curry<(...p: [
339
+ ] | [
340
+ o1: AnyObject,
341
+ o2: AnyObject
342
+ ] | [
343
+ o2: AnyObject
344
+ ] | [
345
+ o1: AnyObject
346
+ ]) => any>;
305
347
  };
306
348
  export declare const mergeDeepX: {
307
- (a: symbol, b: AnyObject): (a: AnyObject) => any;
308
- (a: AnyObject, b: symbol): (b: AnyObject) => any;
309
- (a: AnyObject): (b: AnyObject) => any;
310
- (a: AnyObject, b: AnyObject): any;
349
+ (a: symbol, b: AnyObject): (a: AnyObject) => FT.Curry<(...p: [
350
+ ] | [
351
+ o1: AnyObject,
352
+ o2: AnyObject
353
+ ] | [
354
+ o2: AnyObject
355
+ ] | [
356
+ o1: AnyObject
357
+ ]) => any>;
358
+ (a: AnyObject, b: symbol): (b: AnyObject) => FT.Curry<(...p: [
359
+ ] | [
360
+ o1: AnyObject,
361
+ o2: AnyObject
362
+ ] | [
363
+ o2: AnyObject
364
+ ] | [
365
+ o1: AnyObject
366
+ ]) => any>;
367
+ (a: AnyObject): (b: AnyObject) => FT.Curry<(...p: [
368
+ ] | [
369
+ o1: AnyObject,
370
+ o2: AnyObject
371
+ ] | [
372
+ o2: AnyObject
373
+ ] | [
374
+ o1: AnyObject
375
+ ]) => any>;
376
+ (a: AnyObject, b: AnyObject): FT.Curry<(...p: [
377
+ ] | [
378
+ o1: AnyObject,
379
+ o2: AnyObject
380
+ ] | [
381
+ o2: AnyObject
382
+ ] | [
383
+ o1: AnyObject
384
+ ]) => any>;
311
385
  };
312
386
  export declare const mergeDeepAdd: {
313
- (a: symbol, b: AnyObject): (a: AnyObject) => any;
314
- (a: AnyObject, b: symbol): (b: AnyObject) => any;
315
- (a: AnyObject): (b: AnyObject) => any;
316
- (a: AnyObject, b: AnyObject): any;
317
- };
318
- export declare const overProp: (...args: AnyArgs) => any;
387
+ (a: symbol, b: AnyObject): (a: AnyObject) => FT.Curry<(...p: [
388
+ ] | [
389
+ o1: AnyObject,
390
+ o2: AnyObject
391
+ ] | [
392
+ o2: AnyObject
393
+ ] | [
394
+ o1: AnyObject
395
+ ]) => any>;
396
+ (a: AnyObject, b: symbol): (b: AnyObject) => FT.Curry<(...p: [
397
+ ] | [
398
+ o1: AnyObject,
399
+ o2: AnyObject
400
+ ] | [
401
+ o2: AnyObject
402
+ ] | [
403
+ o1: AnyObject
404
+ ]) => any>;
405
+ (a: AnyObject): (b: AnyObject) => FT.Curry<(...p: [
406
+ ] | [
407
+ o1: AnyObject,
408
+ o2: AnyObject
409
+ ] | [
410
+ o2: AnyObject
411
+ ] | [
412
+ o1: AnyObject
413
+ ]) => any>;
414
+ (a: AnyObject, b: AnyObject): FT.Curry<(...p: [
415
+ ] | [
416
+ o1: AnyObject,
417
+ o2: AnyObject
418
+ ] | [
419
+ o2: AnyObject
420
+ ] | [
421
+ o1: AnyObject
422
+ ]) => any>;
423
+ };
424
+ export declare const overProp: FT.Curry<(prop: string, pipe: AnyFunc, data: any) => FT.Curry<(...p: [
425
+ ] | [
426
+ v: any,
427
+ obj: AnyObject
428
+ ] | [
429
+ obj: AnyObject
430
+ ] | [
431
+ v: any
432
+ ]) => any>>;
319
433
  /** mapKeys({ a: 'b' }, { a: 44 }) -> { b: 44 } */
320
434
  export declare const mapKeys: {
321
435
  (a: symbol, b: AnyObject): (a: {
@@ -364,11 +478,11 @@ export declare const qappend: {
364
478
  (a: any): (b: any[]) => any[];
365
479
  (a: any, b: any[]): any[];
366
480
  };
367
- export declare const qassoc: (...args: AnyArgs) => any;
368
- export declare const qreduce: (...args: AnyArgs) => any;
369
- export declare const qmergeDeep: any;
370
- export declare const qmergeDeepX: any;
371
- export declare const qmergeDeepAdd: any;
481
+ export declare const qassoc: import("ts-toolbelt/out/Function/Curry").Curry<(prop: string, v: any, obj: AnyObject) => AnyObject>;
482
+ export declare const qreduce: import("ts-toolbelt/out/Function/Curry").Curry<(<T>(fn: Reducer, accum: any, arr: T[]) => any)>;
483
+ export declare const qmergeDeep: import("ts-toolbelt/out/Function/Curry").Curry<(o1: AnyObject, o2: AnyObject) => AnyObject>;
484
+ export declare const qmergeDeepX: import("ts-toolbelt/out/Function/Curry").Curry<(o1: AnyObject, o2: AnyObject) => AnyObject>;
485
+ export declare const qmergeDeepAdd: import("ts-toolbelt/out/Function/Curry").Curry<(o1: AnyObject, o2: AnyObject) => AnyObject>;
372
486
  /** qmapKeys({ a: 'b' }, { a: 44 }) -> { b: 44 } */
373
487
  export declare const qmapKeys: {
374
488
  (a: symbol, b: AnyObject): (a: {
@@ -198,7 +198,7 @@ const equals = curry2((a, b) => {
198
198
  });
199
199
  const ifElse = curry((cond, pipeYes, pipeNo, s) => cond(s) ? pipeYes(s) : pipeNo(s));
200
200
  const when = curry3((cond, pipe, s) => ifElse(cond, pipe, identity, s));
201
- const compose = ((...fns) => (s = __) => {
201
+ const compose = ((...fns) => (s = Symbol()) => {
202
202
  for (let i = length(fns) - 1; i > -1; i--) {
203
203
  s = s === __ ? fns[i]() : fns[i](s);
204
204
  }
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(),n=t.length;let p=n,c=0;for(;p&&c<s;c++)o[c]===e&&(o[c]=t[n-p],p--);for(c=s;p;c++,p--)o[c]=t[n-p];return o},s=(e,o,n)=>{const p=e.length-o.length-r(n);if(p<1)return e(...t(o,n));{const r=(...r)=>s(e,t(o,n),r);return r.$args_left=p,r}},o=e=>(...t)=>e.length>r(t)?s(e,[],t):e(...t),n=r=>function(t){return t===e?r:r(t)};function p(r){return function(t,s){const o=t===e,p=arguments.length;if(1===p&&o)throw new Error("Senseless placeholder usage.");return arguments.length>1?o?n((e=>r(e,s))):r(t,s):e=>r(t,e)}}function c(e){return o(e)}const a=void 0,x=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=p(((e,r)=>(r.push(e),r))),g=c(((e,r,t)=>(t[e]=r,t))),b=c(((e,r,t)=>t.reduce(e,r))),w=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],n=t[s];for(const r in n)o[r]?w(e,o[r],n[r]):o[r]=n[r];break;case 3:r[s].push(...t[s])}else r[s]=t[s];break;case"Object":if("Object"===m(r[s])){w(e,r[s],t[s]);break}default:r[s]=t[s]}return r})),j=w(1),O=w(2),q=w(3),A=p(((e,r)=>{let t,s,o,n;for(t in e)s=e[t],[o,n]=h(s)?s(r):[s,r[t]],r[o]=n,t!==o&&delete r[t];return r})),E=p(((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=p(((e,r)=>r.indexOf(e))),k=p(((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&&k(e[s],r[s])))return!1;return!0}return e===r})),P=o(((e,r,t,s)=>e(s)?r(s):t(s))),v=c(((e,r,t)=>P(e,r,X,t))),D=(...r)=>(t=e)=>{for(let s=K(r)-1;s>-1;s--)t=t===e?r[s]():r[s](t);return t},N=p(((e,r)=>e.bind(r))),B=p(((e,r)=>r[e])),_=p(((e,r)=>{if((e=>"string"===i(e))(r))return r.includes(e);for(const t of r)if(k(t,e))return!0;return!1})),C=c(((e,r,t)=>t.slice(e,u(r)?r:x))),T=B(0),U=C(1,x),$=p(((e,r)=>e+r)),z=p(((e,r)=>r-e)),F=e=>o(((r,t)=>e(t,r))),I=e=>l(e)||(e=>e===a)(e),K=e=>e.length,L=e=>()=>e,X=e=>e,G=e=>!e,H=e=>(...r)=>{const t=e(...r);return h(t)&&t.$args_left?H(t):G(t)},J=e=>Object.entries(e),M=p(((e,r)=>e.test(r))),Q=p(((e,r)=>(e(r),r))),R=p(((e,r)=>[...r,e])),V=p(((e,r)=>r.split(e))),W=L(!0),Y=L(!1),Z=p(((e,r)=>re($(e),r-e))),ee=p(((e,r)=>e.filter(F(_)(r)))),re=p(((e,r)=>[...Array(r)].map(((r,t)=>e(t))))),te=p(((e,r)=>e>r)),se=p(((e,r)=>e<r)),oe=p(((e,r)=>r>=e)),ne=p(((e,r)=>r<=e)),pe=p(((e,r)=>r.sort(e))),ce=p(((e,r)=>r.find(e))),ae=p(((e,r)=>r.findIndex(e))),xe=p(((e,r)=>ae(k(e),r))),ie=p(((e,r)=>{for(const[t,s]of e)if(t(r))return s(r)})),le=c(((e,r,t)=>({...t,[e]:r}))),ue=c(((e,r,t)=>D((s=>{return le(s,K(e)<2?r:ue(C(1,x,e),r,(o=t[s],l(o)||"object"!==i(o)?{}:t[s])),t);var o}),T)(e))),fe=p(((e,r)=>r.every(e))),he=p(((e,r)=>r.some(e))),de=p(((e,r)=>e.every((e=>e(r))))),me=p(((e,r)=>e.some((e=>e(r))))),ye=p(((e,r)=>r[e])),ge=c(((e,r,t)=>k(t[e],r))),be=c(((e,r,t)=>k(r[e],t[e]))),we=c(((e,r,t)=>P(K,(()=>I(t)?e:D(P(I,L(e),(t=>we(e,C(1,x,r),t))),F(ye)(t),T)(r)),L(t),r))),je=we(a),Oe=c(((e,r,t)=>k(je(e,t),r))),qe=c(((e,r,t)=>k(je(e,r),je(e,t)))),Ae=/^(.*?)(8|16|32|64)(Clamped)?Array$/,Ee=(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]:_e(Ee,e);case"Object":if(r)return{...e};const s={};for(let r in e)s[r]=Ee(e[r]);return s;default:return Ae.test(t)?e.constructor.from(e):e}},Se=c(((e,r,t)=>b(e,Ee(r),t))),ke=p(((e,r)=>$e(e,r))),Pe=p(((e,r)=>{const t={};for(const s of e)s in r&&(t[s]=r[s]);return t})),ve=p(((e,r)=>$e(((r,t)=>!_(t,e)),r))),De=e=>Se(((e,r)=>le(...r,e)),{},e),Ne=p(((e,r)=>e.concat(r))),Be=p(((e,r)=>r.join(e))),_e=p(((e,r)=>r.map(e))),Ce=p(((e,r)=>r.forEach(e))),Te=c(((e,r,t)=>r(t)&&e(t))),Ue=c(((e,r,t)=>t.replace(e,r))),$e=p(((e,r)=>f(r)?r.filter(e):D(De,$e((([r,t])=>e(t,r))),J)(r))),ze=p(((e,r)=>Object.assign({},e,r))),Fe=p(((e,r)=>j(Ee(e),Ee(r)))),Ie=p(((e,r)=>O(Ee(e),Ee(r)))),Ke=p(((e,r)=>q(Ee(e),Ee(r)))),Le=c(((e,r,t)=>le(e,r(t[e]),t))),Xe=p(((e,r)=>A(e,Object.assign({},r)))),Ge=(()=>{const e=async(r,t,s)=>{s<t.length&&(await r(t[s]),await e(r,t,++s))};return p(((r,t)=>e(r,t,0)))})(),He=p((async(e,r)=>(await e(r),r))),Je=p(((e,r)=>Promise.all(r.map(e)))),Me=(()=>{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)})(),Qe=X,Re=X,Ve=X;exports.F=Y,exports.T=W,exports.__=e,exports.add=$,exports.all=fe,exports.allPass=de,exports.always=L,exports.any=he,exports.anyPass=me,exports.append=R,exports.assoc=le,exports.assocPath=ue,exports.bind=N,exports.both=Te,exports.clone=Ee,exports.cloneShallow=e=>Ee(e,!0),exports.complement=H,exports.compose=D,exports.composeAsync=Me,exports.concat=Ne,exports.cond=ie,exports.curry=o,exports.curry2=p,exports.curry3=c,exports.echo=Ve,exports.empty=e=>{switch(m(e)){case"String":return"";case"Object":return{};case"Array":return[];default:return a}},exports.equals=k,exports.explore=(e,r="log")=>Q((t=>console[r](e,t))),exports.filter=$e,exports.find=ce,exports.findIndex=ae,exports.flip=F,exports.forEach=Ce,exports.forEachAsync=Je,exports.forEachSerial=Ge,exports.fromPairs=De,exports.genBy=re,exports.getTmpl=e=>{const r=[],t=[],s=e.length;let o,n,p=0,c=0,a=!1;for(p=0;p<s;p++)switch(o=e[p],o){case"{":a=!0,c=p;break;case"}":a=!1,r.push(""),t.push(e.slice(c+1,p));break;default:a||(n=r.length-1,n<0&&(r.push(""),n++),r[n]+=o)}return e=>{const s=[],o=r.length-1;for(const n in r)p=+n,s.push(r[p]),p!==o&&s.push(je(t[p].split("."),e));return s.join("")}},exports.gt=te,exports.gte=oe,exports.head=T,exports.identity=X,exports.ifElse=P,exports.includes=_,exports.indexOf=xe,exports.intersection=ee,exports.isEmpty=e=>{switch(m(e)){case"String":case"Array":return 0==K(e);case"Object":for(const r in e)return!1;return!0;default:return null}},exports.isNil=I,exports.join=Be,exports.keys=e=>Object.keys(e),exports.last=e=>e[K(e)-1],exports.length=K,exports.lt=se,exports.lte=ne,exports.map=_e,exports.mapKeys=Xe,exports.memoize=e=>{let r,t=!1;return()=>t?r:(t=!0,r=e())},exports.mergeDeep=Fe,exports.mergeDeepAdd=Ke,exports.mergeDeepX=Ie,exports.mergeShallow=ze,exports.mirror=Qe,exports.not=G,exports.nth=B,exports.omit=ve,exports.once=e=>{let r,t=!1;return(...s)=>t?r:(t=!0,r=e(...s))},exports.overProp=Le,exports.path=je,exports.pathEq=Oe,exports.pathOr=we,exports.pathsEq=qe,exports.pick=Pe,exports.pickBy=ke,exports.prop=ye,exports.propEq=ge,exports.propsEq=be,exports.qappend=y,exports.qassoc=g,exports.qfilter=E,exports.qindexOf=S,exports.qmapKeys=A,exports.qmergeDeep=j,exports.qmergeDeepAdd=q,exports.qmergeDeepX=O,exports.qreduce=b,exports.range=Z,exports.reduce=Se,exports.reflect=Re,exports.replace=Ue,exports.reverse=e=>D((r=>Se(((t,s,o)=>y(e[r-o],t)),[],e)),$(-1),K)(e),exports.sizeof=e=>{if("Object"===m(e)){let r=0;for(let t in e)r++;return r}return K(e)},exports.slice=C,exports.sort=pe,exports.split=V,exports.subtract=z,exports.tail=U,exports.tap=Q,exports.test=M,exports.toLower=e=>e.toLowerCase(),exports.toPairs=J,exports.toUpper=e=>e.toUpperCase(),exports.trim=e=>e.trim(),exports.type=m,exports.uncurry=e=>(...r)=>b(((e,r)=>e?e(r):e),e,r),exports.uniq=e=>b(((e,r)=>_(r,e)?e:y(r,e)),[],e),exports.values=e=>Object.values(e),exports.waitAll=e=>Promise.all(e),exports.waitTap=He,exports.when=v;
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(),n=t.length;let p=n,c=0;for(;p&&c<s;c++)o[c]===e&&(o[c]=t[n-p],p--);for(c=s;p;c++,p--)o[c]=t[n-p];return o},s=(e,o,n)=>{const p=e.length-o.length-r(n);if(p<1)return e(...t(o,n));{const r=(...r)=>s(e,t(o,n),r);return r.$args_left=p,r}},o=e=>(...t)=>e.length>r(t)?s(e,[],t):e(...t),n=r=>function(t){return t===e?r:r(t)};function p(r){return function(t,s){const o=t===e,p=arguments.length;if(1===p&&o)throw new Error("Senseless placeholder usage.");return arguments.length>1?o?n((e=>r(e,s))):r(t,s):e=>r(t,e)}}function c(e){return o(e)}const a=void 0,x=1/0,l=e=>typeof e,i=e=>null===e,u=e=>"number"==l(e),f=e=>Array.isArray(e),h=e=>"function"===l(e),m={u:"U",b:"B",n:"N",s:"S",f:"F"},d=e=>{const r=l(e);return"object"===r?i(e)?"Null":e.constructor.name:m[r[0]]+r.slice(1)},y=p(((e,r)=>(r.push(e),r))),g=c(((e,r,t)=>(t[e]=r,t))),b=c(((e,r,t)=>t.reduce(e,r))),w=c(((e,r,t)=>{for(let s in t)switch(d(t[s])){case"Array":if(e>1&&"Array"===d(r[s]))switch(e){case 2:const o=r[s],n=t[s];for(const r in n)o[r]?w(e,o[r],n[r]):o[r]=n[r];break;case 3:r[s].push(...t[s])}else r[s]=t[s];break;case"Object":if("Object"===d(r[s])){w(e,r[s],t[s]);break}default:r[s]=t[s]}return r})),j=w(1),O=w(2),q=w(3),A=p(((e,r)=>{let t,s,o,n;for(t in e)s=e[t],[o,n]=h(s)?s(r):[s,r[t]],r[o]=n,t!==o&&delete r[t];return r})),E=p(((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=p(((e,r)=>r.indexOf(e))),k=p(((e,r)=>{const t=d(e);if(t===d(r)&&("Object"===t||"Array"==t)){if(i(e)||i(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&&k(e[s],r[s])))return!1;return!0}return e===r})),P=o(((e,r,t,s)=>e(s)?r(s):t(s))),v=c(((e,r,t)=>P(e,r,X,t))),D=(...r)=>(t=Symbol())=>{for(let s=K(r)-1;s>-1;s--)t=t===e?r[s]():r[s](t);return t},N=p(((e,r)=>e.bind(r))),B=p(((e,r)=>r[e])),_=p(((e,r)=>{if((e=>"string"===l(e))(r))return r.includes(e);for(const t of r)if(k(t,e))return!0;return!1})),C=c(((e,r,t)=>t.slice(e,u(r)?r:x))),T=B(0),U=C(1,x),$=p(((e,r)=>e+r)),z=p(((e,r)=>r-e)),F=e=>o(((r,t)=>e(t,r))),I=e=>i(e)||(e=>e===a)(e),K=e=>e.length,L=e=>()=>e,X=e=>e,G=e=>!e,H=e=>(...r)=>{const t=e(...r);return h(t)&&t.$args_left?H(t):G(t)},J=e=>Object.entries(e),M=p(((e,r)=>e.test(r))),Q=p(((e,r)=>(e(r),r))),R=p(((e,r)=>[...r,e])),V=p(((e,r)=>r.split(e))),W=L(!0),Y=L(!1),Z=p(((e,r)=>re($(e),r-e))),ee=p(((e,r)=>e.filter(F(_)(r)))),re=p(((e,r)=>[...Array(r)].map(((r,t)=>e(t))))),te=p(((e,r)=>e>r)),se=p(((e,r)=>e<r)),oe=p(((e,r)=>r>=e)),ne=p(((e,r)=>r<=e)),pe=p(((e,r)=>r.sort(e))),ce=p(((e,r)=>r.find(e))),ae=p(((e,r)=>r.findIndex(e))),xe=p(((e,r)=>ae(k(e),r))),le=p(((e,r)=>{for(const[t,s]of e)if(t(r))return s(r)})),ie=c(((e,r,t)=>({...t,[e]:r}))),ue=c(((e,r,t)=>D((s=>{return ie(s,K(e)<2?r:ue(C(1,x,e),r,(o=t[s],i(o)||"object"!==l(o)?{}:t[s])),t);var o}),T)(e))),fe=p(((e,r)=>r.every(e))),he=p(((e,r)=>r.some(e))),me=p(((e,r)=>e.every((e=>e(r))))),de=p(((e,r)=>e.some((e=>e(r))))),ye=p(((e,r)=>r[e])),ge=c(((e,r,t)=>k(t[e],r))),be=c(((e,r,t)=>k(r[e],t[e]))),we=c(((e,r,t)=>P(K,(()=>I(t)?e:D(P(I,L(e),(t=>we(e,C(1,x,r),t))),F(ye)(t),T)(r)),L(t),r))),je=we(a),Oe=c(((e,r,t)=>k(je(e,t),r))),qe=c(((e,r,t)=>k(je(e,r),je(e,t)))),Ae=/^(.*?)(8|16|32|64)(Clamped)?Array$/,Ee=(e,r=!1)=>{const t=d(e);switch(t){case"Null":case"String":case"Number":case"Boolean":case"Symbol":return e;case"Array":return r?[...e]:_e(Ee,e);case"Object":if(r)return{...e};const s={};for(let r in e)s[r]=Ee(e[r]);return s;default:return Ae.test(t)?e.constructor.from(e):e}},Se=c(((e,r,t)=>b(e,Ee(r),t))),ke=p(((e,r)=>$e(e,r))),Pe=p(((e,r)=>{const t={};for(const s of e)s in r&&(t[s]=r[s]);return t})),ve=p(((e,r)=>$e(((r,t)=>!_(t,e)),r))),De=e=>Se(((e,r)=>ie(...r,e)),{},e),Ne=p(((e,r)=>e.concat(r))),Be=p(((e,r)=>r.join(e))),_e=p(((e,r)=>r.map(e))),Ce=p(((e,r)=>r.forEach(e))),Te=c(((e,r,t)=>r(t)&&e(t))),Ue=c(((e,r,t)=>t.replace(e,r))),$e=p(((e,r)=>f(r)?r.filter(e):D(De,$e((([r,t])=>e(t,r))),J)(r))),ze=p(((e,r)=>Object.assign({},e,r))),Fe=p(((e,r)=>j(Ee(e),Ee(r)))),Ie=p(((e,r)=>O(Ee(e),Ee(r)))),Ke=p(((e,r)=>q(Ee(e),Ee(r)))),Le=c(((e,r,t)=>ie(e,r(t[e]),t))),Xe=p(((e,r)=>A(e,Object.assign({},r)))),Ge=(()=>{const e=async(r,t,s)=>{s<t.length&&(await r(t[s]),await e(r,t,++s))};return p(((r,t)=>e(r,t,0)))})(),He=p((async(e,r)=>(await e(r),r))),Je=p(((e,r)=>Promise.all(r.map(e)))),Me=(()=>{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)})(),Qe=X,Re=X,Ve=X;exports.F=Y,exports.T=W,exports.__=e,exports.add=$,exports.all=fe,exports.allPass=me,exports.always=L,exports.any=he,exports.anyPass=de,exports.append=R,exports.assoc=ie,exports.assocPath=ue,exports.bind=N,exports.both=Te,exports.clone=Ee,exports.cloneShallow=e=>Ee(e,!0),exports.complement=H,exports.compose=D,exports.composeAsync=Me,exports.concat=Ne,exports.cond=le,exports.curry=o,exports.curry2=p,exports.curry3=c,exports.echo=Ve,exports.empty=e=>{switch(d(e)){case"String":return"";case"Object":return{};case"Array":return[];default:return a}},exports.equals=k,exports.explore=(e,r="log")=>Q((t=>console[r](e,t))),exports.filter=$e,exports.find=ce,exports.findIndex=ae,exports.flip=F,exports.forEach=Ce,exports.forEachAsync=Je,exports.forEachSerial=Ge,exports.fromPairs=De,exports.genBy=re,exports.getTmpl=e=>{const r=[],t=[],s=e.length;let o,n,p=0,c=0,a=!1;for(p=0;p<s;p++)switch(o=e[p],o){case"{":a=!0,c=p;break;case"}":a=!1,r.push(""),t.push(e.slice(c+1,p));break;default:a||(n=r.length-1,n<0&&(r.push(""),n++),r[n]+=o)}return e=>{const s=[],o=r.length-1;for(const n in r)p=+n,s.push(r[p]),p!==o&&s.push(je(t[p].split("."),e));return s.join("")}},exports.gt=te,exports.gte=oe,exports.head=T,exports.identity=X,exports.ifElse=P,exports.includes=_,exports.indexOf=xe,exports.intersection=ee,exports.isEmpty=e=>{switch(d(e)){case"String":case"Array":return 0==K(e);case"Object":for(const r in e)return!1;return!0;default:return null}},exports.isNil=I,exports.join=Be,exports.keys=e=>Object.keys(e),exports.last=e=>e[K(e)-1],exports.length=K,exports.lt=se,exports.lte=ne,exports.map=_e,exports.mapKeys=Xe,exports.memoize=e=>{let r,t=!1;return()=>t?r:(t=!0,r=e())},exports.mergeDeep=Fe,exports.mergeDeepAdd=Ke,exports.mergeDeepX=Ie,exports.mergeShallow=ze,exports.mirror=Qe,exports.not=G,exports.nth=B,exports.omit=ve,exports.once=e=>{let r,t=!1;return(...s)=>t?r:(t=!0,r=e(...s))},exports.overProp=Le,exports.path=je,exports.pathEq=Oe,exports.pathOr=we,exports.pathsEq=qe,exports.pick=Pe,exports.pickBy=ke,exports.prop=ye,exports.propEq=ge,exports.propsEq=be,exports.qappend=y,exports.qassoc=g,exports.qfilter=E,exports.qindexOf=S,exports.qmapKeys=A,exports.qmergeDeep=j,exports.qmergeDeepAdd=q,exports.qmergeDeepX=O,exports.qreduce=b,exports.range=Z,exports.reduce=Se,exports.reflect=Re,exports.replace=Ue,exports.reverse=e=>D((r=>Se(((t,s,o)=>y(e[r-o],t)),[],e)),$(-1),K)(e),exports.sizeof=e=>{if("Object"===d(e)){let r=0;for(let t in e)r++;return r}return K(e)},exports.slice=C,exports.sort=pe,exports.split=V,exports.subtract=z,exports.tail=U,exports.tap=Q,exports.test=M,exports.toLower=e=>e.toLowerCase(),exports.toPairs=J,exports.toUpper=e=>e.toUpperCase(),exports.trim=e=>e.trim(),exports.type=d,exports.uncurry=e=>(...r)=>b(((e,r)=>e?e(r):e),e,r),exports.uniq=e=>b(((e,r)=>_(r,e)?e:y(r,e)),[],e),exports.values=e=>Object.values(e),exports.waitAll=e=>Promise.all(e),exports.waitTap=He,exports.when=v;
package/dist/es/safe.js CHANGED
@@ -26,7 +26,7 @@ export const equals = curry2((a, b) => {
26
26
  });
27
27
  export const ifElse = curry((cond, pipeYes, pipeNo, s) => cond(s) ? pipeYes(s) : pipeNo(s));
28
28
  export const when = curry3((cond, pipe, s) => ifElse(cond, pipe, identity, s));
29
- export const compose = ((...fns) => (s = __) => {
29
+ export const compose = ((...fns) => (s = Symbol()) => {
30
30
  for (let i = length(fns) - 1; i > -1; i--) {
31
31
  s = s === __ ? fns[i]() : fns[i](s);
32
32
  }
package/package.json CHANGED
@@ -40,7 +40,7 @@
40
40
  "prod": "npm run gentypes && npm run prod:es && npm run prod:cjs",
41
41
  "all": "npm run dev && npm run prod"
42
42
  },
43
- "version": "0.13.0b7",
43
+ "version": "0.13.0-beta10",
44
44
  "ava": {
45
45
  "files": [
46
46
  "./test/specs/*.ts"
package/src/curry.ts CHANGED
@@ -46,11 +46,11 @@ const _curry = (fn: Function, args: AnyArgs, new_args: AnyArgs) => {
46
46
  }
47
47
 
48
48
  export const curry = (
49
- /*<Func extends AnyFunc>*/(fn: AnyFunc) => (
49
+ <Func extends AnyFunc>(fn: AnyFunc) => (
50
50
  (...args: AnyArgs) => fn.length>countArgs(args)
51
51
  ? _curry(fn, [], args)
52
52
  : fn(...args)
53
- )// as FT.Curry<Func>
53
+ ) as FT.Curry<Func>
54
54
  )
55
55
  const endlessph = <Func extends FT.Function>(fn: Func) => {
56
56
  type ReturnT = ReturnType<Func>
@@ -93,5 +93,5 @@ export function curry3<Func extends Func3>(fn: Func) {
93
93
  // type p2 = Parameters<Func>[2]
94
94
  // type ReturnT = ReturnType<Func>
95
95
  // TODO: optimize.
96
- return curry(fn)// as FT.Curry<Func>
96
+ return curry(fn) as FT.Curry<Func>
97
97
  }
package/src/safe.ts CHANGED
@@ -3,7 +3,7 @@ import { isNum, isUndef, undef, isNull, isArray, isFunc, isStr, isObj, inf } fro
3
3
  import { qmergeDeep, qreduce, qappend, qmapKeys, qmergeDeepX, qmergeDeepAdd } from './quick'
4
4
  import { AnyFunc, Cond, AnyObject, Reducer } from './types'
5
5
  import { type } from './common'
6
- import { F as FT, U } from 'ts-toolbelt'
6
+ import { F as FT } from 'ts-toolbelt'
7
7
  // over, lensProp
8
8
 
9
9
  export const equals = curry2((a: any, b: any) => {
@@ -44,13 +44,14 @@ export const when = curry3(
44
44
  s: any
45
45
  ) => ifElse(cond, pipe, identity, s)
46
46
  )
47
- export const compose: FT.Compose = (
48
- (...fns: AnyFunc[]) =>
49
- (s: any = __) => {
47
+ type Composed<TIn, TOut> = (x: TIn) => TOut
48
+ export const compose = (
49
+ <TIn = any, TOut = any>(...fns: AnyFunc[]): Composed<TIn, TOut> =>
50
+ (s: TIn = Symbol() as any) => {
50
51
  for(let i = length(fns)-1; i>-1; i--) {
51
52
  s = s===__ ? fns[i]() : fns[i](s)
52
53
  }
53
- return s
54
+ return s as any as TOut
54
55
  }
55
56
  )
56
57
 
@@ -139,7 +140,7 @@ export const once = <Func extends AnyFunc>(fn: Func) => {
139
140
  }
140
141
  }
141
142
  export const reverse = (xs: any[]) => compose(
142
- <T>(ln: number) => reduce(
143
+ <T>(ln: number) => reduce<any>(
143
144
  (nxs: T[], _: any, i: number) => qappend(xs[ln-i], nxs),
144
145
  [], xs
145
146
  ),
@@ -269,7 +270,7 @@ export const omit = curry2(
269
270
  o
270
271
  )
271
272
  )
272
- export const fromPairs = (pairs: [string, any][]) => reduce(
273
+ export const fromPairs = (pairs: [string, any][]) => reduce<any>(
273
274
  (o: AnyObject, pair: [string, any]) => assoc(...pair, o),
274
275
  {}, pairs
275
276
  )
@@ -384,7 +385,7 @@ export const composeAsync = (() => {
384
385
  ~i ? await pipe(fns, await fns[i](data), --i) : data
385
386
  return <T = any>(...fns: AnyFunc[]) =>
386
387
  (data?: any) => pipe(fns, data, fns.length-1) as Promise<T>
387
- })() as FT.Compose<'async'>
388
+ })()// as FT.Compose<'async'>
388
389
 
389
390
  // ALIASES
390
391
  export const mirror = identity
package/src/uncurry.ts CHANGED
@@ -6,6 +6,6 @@ export const uncurry = <
6
6
  Args extends any[] = any[],
7
7
  ReturnT = any
8
8
  >(fn: Curried<Args>): AnyFunc =>
9
- (...args: Args) => qreduce(
9
+ (...args: Args) => qreduce<any>(
10
10
  ((fn: Curried<Args>, arg: any) => fn ? fn(arg) : fn), fn, args
11
11
  ) as ReturnT