pepka 0.13.0-b1 → 0.13.0-b2

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
@@ -1,28 +1,74 @@
1
- // Generated by dts-bundle-generator v5.9.0
1
+ import {F as FT} from 'ts-toolbelt'
2
2
 
3
- export declare type Args = any[];
4
- declare const __: () => void;
5
- export declare const curry: (fn: Function) => (...args: Args) => any;
6
- export declare const toLower: (s: string) => string;
7
- export declare const toUpper: (s: string) => string;
8
- export declare const type: (s: any) => any;
3
+ // Generated by dts-bundle-generator v7.1.0
4
+
5
+ export type Cond = (...xs: any[]) => boolean;
9
6
  export interface AnyObject {
10
7
  [k: string]: any;
11
8
  }
12
- export declare type AnyFunc = (...args: any[]) => any;
13
- export declare const equals: (...args: any[]) => any;
14
- export declare const ifElse: (...args: any[]) => any;
15
- export declare const when: (...args: any[]) => any;
16
- export declare const compose: (...fns: Function[]) => (s?: any) => any;
17
- export declare const bind: (...args: any[]) => any;
18
- export declare const nth: (...args: any[]) => any;
19
- export declare const includes: (...args: any[]) => any;
20
- export declare const slice: (...args: any[]) => any;
21
- export declare const head: any;
22
- export declare const tail: any;
23
- export declare const add: (...args: any[]) => any;
24
- export declare const subtract: (...args: any[]) => any;
25
- export declare const flip: (fn: Function) => (...args: any[]) => any;
9
+ export type AnyArgs = any[];
10
+ export type Curried<Args extends AnyArgs = AnyArgs, ReturnT = any> = (arg: Args[number]) => Curried<Args> | ReturnT;
11
+ export type Reducer = <T = any>(accum: T, cur: any, index: number) => T;
12
+ export type AnyFunc<ReturnT = any, Args extends AnyArgs = AnyArgs> = (...args: Args) => ReturnT;
13
+ declare const __: unique symbol;
14
+ export type Placeholder = typeof __;
15
+ export declare const curry: <Func extends AnyFunc<any, AnyArgs>>(fn: AnyFunc) => FT.Curry<Func>;
16
+ export type Func2 = (a: any, b: any) => any;
17
+ export declare function curry2<Func extends Func2>(fn: Func): {
18
+ (a: Parameters<Func>[0]): (b: Parameters<Func>[1]) => ReturnType<Func>;
19
+ (a: Parameters<Func>[0], b: Parameters<Func>[1]): ReturnType<Func>;
20
+ (a: Placeholder, b: Parameters<Func>[1]): (a: Parameters<Func>[0]) => ReturnType<Func>;
21
+ (a: Parameters<Func>[0], b: Placeholder): (b: Parameters<Func>[1]) => ReturnType<Func>;
22
+ };
23
+ export type Func3 = (a: any, b: any, c: any) => any;
24
+ export declare function curry3<Func extends Func3>(fn: Func): FT.Curry<Func>;
25
+ export declare const uncurry: <Args extends any[] = any[], ReturnT = any>(fn: Curried<Args, any>) => AnyFunc;
26
+ export declare const toLower: (s: string) => string;
27
+ export declare const toUpper: (s: string) => string;
28
+ export declare const type: (s: any) => any;
29
+ export declare const equals: {
30
+ (a: any): (b: any) => boolean;
31
+ (a: any, b: any): boolean;
32
+ (a: typeof __, b: any): (a: any) => boolean;
33
+ (a: any, b: typeof __): (b: any) => boolean;
34
+ };
35
+ export declare const ifElse: FT.Curry<AnyFunc<any, AnyArgs>>;
36
+ export declare const when: FT.Curry<(cond: (s: any) => boolean, pipe: (s: any) => any, s: any) => any>;
37
+ export declare const compose: FT.Compose;
38
+ export declare const bind: {
39
+ (a: any): (b: any) => any;
40
+ (a: any, b: any): any;
41
+ (a: typeof __, b: any): (a: any) => any;
42
+ (a: any, b: typeof __): (b: any) => any;
43
+ };
44
+ export declare const nth: {
45
+ (a: number): (b: unknown[]) => unknown;
46
+ (a: number, b: unknown[]): unknown;
47
+ (a: typeof __, b: unknown[]): (a: number) => unknown;
48
+ (a: number, b: typeof __): (b: unknown[]) => unknown;
49
+ };
50
+ export declare const includes: {
51
+ (a: unknown): (b: unknown[]) => boolean;
52
+ (a: unknown, b: unknown[]): boolean;
53
+ (a: typeof __, b: unknown[]): (a: unknown) => boolean;
54
+ (a: unknown, b: typeof __): (b: unknown[]) => boolean;
55
+ };
56
+ export declare const slice: FT.Curry<(from: number, to: number, o: any[] | string) => string | any[]>;
57
+ export declare const head: (b: unknown[]) => unknown;
58
+ export declare const tail: FT.Curry<(o: string | any[]) => string | any[]>;
59
+ export declare const add: {
60
+ (a: number): (b: number) => number;
61
+ (a: number, b: number): number;
62
+ (a: typeof __, b: number): (a: number) => number;
63
+ (a: number, b: typeof __): (b: number) => number;
64
+ };
65
+ export declare const subtract: {
66
+ (a: number): (b: number) => number;
67
+ (a: number, b: number): number;
68
+ (a: typeof __, b: number): (a: number) => number;
69
+ (a: number, b: typeof __): (b: number) => number;
70
+ };
71
+ export declare const flip: (fn: Function) => FT.Curry<AnyFunc<any, AnyArgs>>;
26
72
  export declare const isNil: (s: any) => boolean;
27
73
  export declare const length: (s: any[] | string) => number;
28
74
  export declare const always: <T = any>(s: T) => () => T;
@@ -37,91 +83,436 @@ export declare const toPairs: (o: AnyObject | any[]) => [
37
83
  string,
38
84
  any
39
85
  ][];
40
- export declare const test: (...args: any[]) => any;
41
- export declare const tap: (...args: any[]) => any;
42
- export declare const append: (...args: any[]) => any;
43
- export declare const split: (...args: any[]) => any;
86
+ export declare const test: {
87
+ (a: RegExp): (b: string) => boolean;
88
+ (a: RegExp, b: string): boolean;
89
+ (a: typeof __, b: string): (a: RegExp) => boolean;
90
+ (a: RegExp, b: typeof __): (b: string) => boolean;
91
+ };
92
+ export declare const tap: {
93
+ (a: Function): (b: any) => any;
94
+ (a: Function, b: any): any;
95
+ (a: typeof __, b: any): (a: Function) => any;
96
+ (a: Function, b: typeof __): (b: any) => any;
97
+ };
98
+ export declare const append: {
99
+ (a: any): (b: any[]) => any[];
100
+ (a: any, b: any[]): any[];
101
+ (a: typeof __, b: any[]): (a: any) => any[];
102
+ (a: any, b: typeof __): (b: any[]) => any[];
103
+ };
104
+ export declare const split: {
105
+ (a: string): (b: string) => string[];
106
+ (a: string, b: string): string[];
107
+ (a: typeof __, b: string): (a: string) => string[];
108
+ (a: string, b: typeof __): (b: string) => string[];
109
+ };
44
110
  export declare const T: (...args: any[]) => true;
45
111
  export declare const F: (...args: any[]) => false;
46
112
  export declare const sizeof: (s: any[] | string | AnyObject) => number;
47
- export declare const range: (...args: any[]) => any;
113
+ export declare const range: {
114
+ (a: number): (b: number) => any[];
115
+ (a: number, b: number): any[];
116
+ (a: typeof __, b: number): (a: number) => any[];
117
+ (a: number, b: typeof __): (b: number) => any[];
118
+ };
48
119
  export declare const uniq: (xs: any[]) => any;
49
- export declare const intersection: (...args: any[]) => any;
50
- export declare const genBy: (...args: any[]) => any;
51
- export declare const once: <Func extends AnyFunc>(fn: Func) => (...args: Parameters<Func>) => any;
52
- export declare const reverse: (xs: any[]) => any;
53
- export declare const gt: (...args: any[]) => any;
54
- export declare const lt: (...args: any[]) => any;
55
- export declare const gte: (...args: any[]) => any;
56
- export declare const lte: (...args: any[]) => any;
57
- export declare const sort: (...args: any[]) => any;
58
- export declare const find: (...args: any[]) => any;
59
- export declare const findIndex: (...args: any[]) => any;
60
- export declare const indexOf: (...args: any[]) => any;
61
- export declare const explore: (caption: string, level?: string) => any;
62
- export declare const cond: (...args: any[]) => any;
63
- export declare const assoc: (...args: any[]) => any;
64
- export declare const assocPath: (...args: any[]) => any;
65
- export declare const all: (...args: any[]) => any;
66
- export declare const any: (...args: any[]) => any;
67
- export declare const allPass: (...args: any[]) => any;
68
- export declare const anyPass: (...args: any[]) => any;
69
- export declare const prop: (...args: any[]) => any;
70
- export declare const propEq: (...args: any[]) => any;
71
- export declare const propsEq: (...args: any[]) => any;
72
- export declare const pathOr: (...args: any[]) => any;
73
- export declare const path: any;
74
- export declare const pathEq: (...args: any[]) => any;
75
- export declare const pathsEq: (...args: any[]) => any;
76
- export declare const clone: (s: any) => any;
77
- export declare const reduce: (...args: any[]) => any;
78
- export declare const pickBy: (...args: any[]) => any;
79
- export declare const pick: (...args: any[]) => any;
80
- export declare const omit: (...args: any[]) => any;
120
+ export declare const intersection: {
121
+ (a: any[]): (b: any[]) => any[];
122
+ (a: any[], b: any[]): any[];
123
+ (a: typeof __, b: any[]): (a: any[]) => any[];
124
+ (a: any[], b: typeof __): (b: any[]) => any[];
125
+ };
126
+ export declare const genBy: {
127
+ (a: (i: number) => any): (b: number) => any[];
128
+ (a: (i: number) => any, b: number): any[];
129
+ (a: typeof __, b: number): (a: (i: number) => any) => any[];
130
+ (a: (i: number) => any, b: typeof __): (b: number) => any[];
131
+ };
132
+ export declare const once: <Func extends AnyFunc<any, AnyArgs>>(fn: Func) => (...args: Parameters<Func>) => any;
133
+ export declare const reverse: (xs: any[]) => FT.Curry<(fn: Reducer, accum: any, arr: any[]) => FT.Curry<(...p: [
134
+ ] | [
135
+ accum: any
136
+ ]) => any>>;
137
+ export declare const gt: {
138
+ (a: number): (b: number) => boolean;
139
+ (a: number, b: number): boolean;
140
+ (a: typeof __, b: number): (a: number) => boolean;
141
+ (a: number, b: typeof __): (b: number) => boolean;
142
+ };
143
+ export declare const lt: {
144
+ (a: number): (b: number) => boolean;
145
+ (a: number, b: number): boolean;
146
+ (a: typeof __, b: number): (a: number) => boolean;
147
+ (a: number, b: typeof __): (b: number) => boolean;
148
+ };
149
+ export declare const gte: {
150
+ (a: number): (b: number) => boolean;
151
+ (a: number, b: number): boolean;
152
+ (a: typeof __, b: number): (a: number) => boolean;
153
+ (a: number, b: typeof __): (b: number) => boolean;
154
+ };
155
+ export declare const lte: {
156
+ (a: number): (b: number) => boolean;
157
+ (a: number, b: number): boolean;
158
+ (a: typeof __, b: number): (a: number) => boolean;
159
+ (a: number, b: typeof __): (b: number) => boolean;
160
+ };
161
+ export declare const sort: {
162
+ (a: any): (b: any[]) => any[];
163
+ (a: any, b: any[]): any[];
164
+ (a: typeof __, b: any[]): (a: any) => any[];
165
+ (a: any, b: typeof __): (b: any[]) => any[];
166
+ };
167
+ export declare const find: {
168
+ (a: Cond): (b: any[]) => any;
169
+ (a: Cond, b: any[]): any;
170
+ (a: typeof __, b: any[]): (a: Cond) => any;
171
+ (a: Cond, b: typeof __): (b: any[]) => any;
172
+ };
173
+ export declare const findIndex: {
174
+ (a: Cond): (b: any[]) => number;
175
+ (a: Cond, b: any[]): number;
176
+ (a: typeof __, b: any[]): (a: Cond) => number;
177
+ (a: Cond, b: typeof __): (b: any[]) => number;
178
+ };
179
+ export declare const indexOf: {
180
+ (a: any): (b: any[]) => number;
181
+ (a: any, b: any[]): number;
182
+ (a: typeof __, b: any[]): (a: any) => number;
183
+ (a: any, b: typeof __): (b: any[]) => number;
184
+ };
185
+ export declare const explore: (caption: string, level?: string) => (b: any) => any;
186
+ export declare const cond: {
187
+ (a: [
188
+ Cond,
189
+ Function
190
+ ][]): (b: any) => any;
191
+ (a: [
192
+ Cond,
193
+ Function
194
+ ][], b: any): any;
195
+ (a: typeof __, b: any): (a: [
196
+ Cond,
197
+ Function
198
+ ][]) => any;
199
+ (a: [
200
+ Cond,
201
+ Function
202
+ ][], b: typeof __): (b: any) => any;
203
+ };
204
+ export declare const assoc: FT.Curry<(prop: string, v: any, obj: AnyObject) => {
205
+ [x: string]: any;
206
+ }>;
207
+ export declare const assocPath: any;
208
+ export declare const all: {
209
+ (a: Cond): (b: any[]) => boolean;
210
+ (a: Cond, b: any[]): boolean;
211
+ (a: typeof __, b: any[]): (a: Cond) => boolean;
212
+ (a: Cond, b: typeof __): (b: any[]) => boolean;
213
+ };
214
+ export declare const any: {
215
+ (a: Cond): (b: any[]) => boolean;
216
+ (a: Cond, b: any[]): boolean;
217
+ (a: typeof __, b: any[]): (a: Cond) => boolean;
218
+ (a: Cond, b: typeof __): (b: any[]) => boolean;
219
+ };
220
+ export declare const allPass: {
221
+ (a: Cond[]): (b: any) => boolean;
222
+ (a: Cond[], b: any): boolean;
223
+ (a: typeof __, b: any): (a: Cond[]) => boolean;
224
+ (a: Cond[], b: typeof __): (b: any) => boolean;
225
+ };
226
+ export declare const anyPass: {
227
+ (a: Cond[]): (b: any) => boolean;
228
+ (a: Cond[], b: any): boolean;
229
+ (a: typeof __, b: any): (a: Cond[]) => boolean;
230
+ (a: Cond[], b: typeof __): (b: any) => boolean;
231
+ };
232
+ export declare const prop: {
233
+ (a: string): (b: AnyObject) => any;
234
+ (a: string, b: AnyObject): any;
235
+ (a: typeof __, b: AnyObject): (a: string) => any;
236
+ (a: string, b: typeof __): (b: AnyObject) => any;
237
+ };
238
+ export declare const propEq: FT.Curry<(key: string, value: any, o: AnyObject) => boolean>;
239
+ export declare const propsEq: FT.Curry<(key: string, o1: any, o2: AnyObject) => boolean>;
240
+ export declare const pathOr: FT.Curry<(_default: any, path: string[], o: any) => any>;
241
+ export declare const path: FT.Curry<(path: string[], o: any) => any>;
242
+ export declare const pathEq: FT.Curry<(_path: string[], value: any, o: AnyObject) => boolean>;
243
+ export declare const pathsEq: FT.Curry<(_path: string[], o1: AnyObject, o2: AnyObject) => boolean>;
244
+ export declare const clone: (s: any, shallow?: boolean) => any;
245
+ export declare const cloneShallow: (s: any) => any;
246
+ export declare const reduce: FT.Curry<(fn: Reducer, accum: any, arr: any[]) => FT.Curry<(...p: [
247
+ ] | [
248
+ accum: any
249
+ ]) => any>>;
250
+ export declare const pickBy: {
251
+ (a: Cond): (b: AnyObject) => any;
252
+ (a: Cond, b: AnyObject): any;
253
+ (a: typeof __, b: AnyObject): (a: Cond) => any;
254
+ (a: Cond, b: typeof __): (b: AnyObject) => any;
255
+ };
256
+ export declare const pick: {
257
+ (a: string[]): (b: AnyObject) => {};
258
+ (a: string[], b: AnyObject): {};
259
+ (a: typeof __, b: AnyObject): (a: string[]) => {};
260
+ (a: string[], b: typeof __): (b: AnyObject) => {};
261
+ };
262
+ export declare const omit: {
263
+ (a: string[]): (b: AnyObject) => any;
264
+ (a: string[], b: AnyObject): any;
265
+ (a: typeof __, b: AnyObject): (a: string[]) => any;
266
+ (a: string[], b: typeof __): (b: AnyObject) => any;
267
+ };
81
268
  export declare const fromPairs: (pairs: [
82
269
  string,
83
270
  any
84
- ][]) => any;
85
- export declare const concat: (...args: any[]) => any;
86
- export declare const join: (...args: any[]) => any;
87
- export declare const map: (...args: any[]) => any;
88
- export declare const forEach: (...args: any[]) => any;
89
- export declare const both: (...args: any[]) => any;
271
+ ][]) => FT.Curry<(fn: Reducer, accum: any, arr: any[]) => FT.Curry<(...p: [
272
+ ] | [
273
+ accum: any
274
+ ]) => any>>;
275
+ export declare const concat: {
276
+ (a: string | any[]): (b: string | any[]) => string | any[];
277
+ (a: string | any[], b: string | any[]): string | any[];
278
+ (a: typeof __, b: string | any[]): (a: string | any[]) => string | any[];
279
+ (a: string | any[], b: typeof __): (b: string | any[]) => string | any[];
280
+ };
281
+ export declare const join: {
282
+ (a: string): (b: string[]) => string;
283
+ (a: string, b: string[]): string;
284
+ (a: typeof __, b: string[]): (a: string) => string;
285
+ (a: string, b: typeof __): (b: string[]) => string;
286
+ };
287
+ export declare const map: {
288
+ (a: (s: any) => any): (b: any[]) => any[];
289
+ (a: (s: any) => any, b: any[]): any[];
290
+ (a: typeof __, b: any[]): (a: (s: any) => any) => any[];
291
+ (a: (s: any) => any, b: typeof __): (b: any[]) => any[];
292
+ };
293
+ export declare const forEach: {
294
+ (a: (s: any) => any): (b: any[]) => void;
295
+ (a: (s: any) => any, b: any[]): void;
296
+ (a: typeof __, b: any[]): (a: (s: any) => any) => void;
297
+ (a: (s: any) => any, b: typeof __): (b: any[]) => void;
298
+ };
299
+ export declare const both: FT.Curry<(cond1: Cond, cond2: Cond, s: any) => boolean>;
90
300
  export declare const isEmpty: (s: any) => boolean | null;
91
301
  export declare const empty: (s: any) => {} | undefined;
92
- export declare const replace: (...args: any[]) => any;
93
- export declare const filter: (...args: any[]) => any;
302
+ export declare const replace: FT.Curry<(a: string | RegExp, b: string, where: string) => string>;
303
+ export declare const filter: any;
94
304
  export declare const memoize: (fn: Function) => () => any;
95
- export declare const mergeShallow: (...args: any[]) => any;
96
- export declare const mergeDeep: (...args: any[]) => any;
97
- export declare const mergeDeepX: (...args: any[]) => any;
98
- export declare const mergeDeepAdd: (...args: any[]) => any;
99
- export declare const overProp: (...args: any[]) => any;
305
+ export declare const mergeShallow: {
306
+ (a: AnyObject): (b: AnyObject) => AnyObject;
307
+ (a: AnyObject, b: AnyObject): AnyObject;
308
+ (a: typeof __, b: AnyObject): (a: AnyObject) => AnyObject;
309
+ (a: AnyObject, b: typeof __): (b: AnyObject) => AnyObject;
310
+ };
311
+ export declare const mergeDeep: {
312
+ (a: AnyObject): (b: AnyObject) => FT.Curry<(...p: [
313
+ ] | [
314
+ o1: AnyObject,
315
+ o2: AnyObject
316
+ ] | [
317
+ o2: AnyObject
318
+ ] | [
319
+ o1: AnyObject
320
+ ]) => any>;
321
+ (a: AnyObject, b: AnyObject): FT.Curry<(...p: [
322
+ ] | [
323
+ o1: AnyObject,
324
+ o2: AnyObject
325
+ ] | [
326
+ o2: AnyObject
327
+ ] | [
328
+ o1: AnyObject
329
+ ]) => any>;
330
+ (a: typeof __, b: AnyObject): (a: AnyObject) => FT.Curry<(...p: [
331
+ ] | [
332
+ o1: AnyObject,
333
+ o2: AnyObject
334
+ ] | [
335
+ o2: AnyObject
336
+ ] | [
337
+ o1: AnyObject
338
+ ]) => any>;
339
+ (a: AnyObject, b: typeof __): (b: AnyObject) => FT.Curry<(...p: [
340
+ ] | [
341
+ o1: AnyObject,
342
+ o2: AnyObject
343
+ ] | [
344
+ o2: AnyObject
345
+ ] | [
346
+ o1: AnyObject
347
+ ]) => any>;
348
+ };
349
+ export declare const mergeDeepX: {
350
+ (a: AnyObject): (b: AnyObject) => FT.Curry<(...p: [
351
+ ] | [
352
+ o1: AnyObject,
353
+ o2: AnyObject
354
+ ] | [
355
+ o2: AnyObject
356
+ ] | [
357
+ o1: AnyObject
358
+ ]) => any>;
359
+ (a: AnyObject, b: AnyObject): FT.Curry<(...p: [
360
+ ] | [
361
+ o1: AnyObject,
362
+ o2: AnyObject
363
+ ] | [
364
+ o2: AnyObject
365
+ ] | [
366
+ o1: AnyObject
367
+ ]) => any>;
368
+ (a: typeof __, b: AnyObject): (a: AnyObject) => FT.Curry<(...p: [
369
+ ] | [
370
+ o1: AnyObject,
371
+ o2: AnyObject
372
+ ] | [
373
+ o2: AnyObject
374
+ ] | [
375
+ o1: AnyObject
376
+ ]) => any>;
377
+ (a: AnyObject, b: typeof __): (b: AnyObject) => FT.Curry<(...p: [
378
+ ] | [
379
+ o1: AnyObject,
380
+ o2: AnyObject
381
+ ] | [
382
+ o2: AnyObject
383
+ ] | [
384
+ o1: AnyObject
385
+ ]) => any>;
386
+ };
387
+ export declare const mergeDeepAdd: {
388
+ (a: AnyObject): (b: AnyObject) => FT.Curry<(...p: [
389
+ ] | [
390
+ o1: AnyObject,
391
+ o2: AnyObject
392
+ ] | [
393
+ o2: AnyObject
394
+ ] | [
395
+ o1: AnyObject
396
+ ]) => any>;
397
+ (a: AnyObject, b: AnyObject): FT.Curry<(...p: [
398
+ ] | [
399
+ o1: AnyObject,
400
+ o2: AnyObject
401
+ ] | [
402
+ o2: AnyObject
403
+ ] | [
404
+ o1: AnyObject
405
+ ]) => any>;
406
+ (a: typeof __, b: AnyObject): (a: AnyObject) => FT.Curry<(...p: [
407
+ ] | [
408
+ o1: AnyObject,
409
+ o2: AnyObject
410
+ ] | [
411
+ o2: AnyObject
412
+ ] | [
413
+ o1: AnyObject
414
+ ]) => any>;
415
+ (a: AnyObject, b: typeof __): (b: AnyObject) => FT.Curry<(...p: [
416
+ ] | [
417
+ o1: AnyObject,
418
+ o2: AnyObject
419
+ ] | [
420
+ o2: AnyObject
421
+ ] | [
422
+ o1: AnyObject
423
+ ]) => any>;
424
+ };
425
+ export declare const overProp: FT.Curry<(prop: string, pipe: AnyFunc, data: any) => FT.Curry<(...p: [
426
+ ] | [
427
+ v: any,
428
+ obj: AnyObject
429
+ ] | [
430
+ obj: AnyObject
431
+ ] | [
432
+ v: any
433
+ ]) => any>>;
100
434
  /** mapKeys({ a: 'b' }, { a: 44 }) -> { b: 44 } */
101
- export declare const mapKeys: (...args: any[]) => any;
435
+ export declare const mapKeys: {
436
+ (a: {
437
+ [oldKey: string]: string;
438
+ }): (b: AnyObject) => AnyObject;
439
+ (a: {
440
+ [oldKey: string]: string;
441
+ }, b: AnyObject): AnyObject;
442
+ (a: typeof __, b: AnyObject): (a: {
443
+ [oldKey: string]: string;
444
+ }) => AnyObject;
445
+ (a: {
446
+ [oldKey: string]: string;
447
+ }, b: typeof __): (b: AnyObject) => AnyObject;
448
+ };
102
449
  /** One promise waits for another. */
103
- export declare const forEachSerial: (...args: any[]) => any;
450
+ export declare const forEachSerial: {
451
+ (a: AnyFunc<any, AnyArgs>): (b: any[]) => Promise<void>;
452
+ (a: AnyFunc<any, AnyArgs>, b: any[]): Promise<void>;
453
+ (a: typeof __, b: any[]): (a: AnyFunc<any, AnyArgs>) => Promise<void>;
454
+ (a: AnyFunc<any, AnyArgs>, b: typeof __): (b: any[]) => Promise<void>;
455
+ };
104
456
  /** Promise.all wrapper for functional pipelining. */
105
457
  export declare const waitAll: (promises: Promise<any>[]) => Promise<any[]>;
458
+ export declare const waitTap: {
459
+ (a: Function): (b: any) => Promise<any>;
460
+ (a: Function, b: any): Promise<any>;
461
+ (a: typeof __, b: any): (a: Function) => Promise<any>;
462
+ (a: Function, b: typeof __): (b: any) => Promise<any>;
463
+ };
106
464
  /** Waits for all promises mapped by the fn. */
107
- export declare const forEachAsync: (...args: any[]) => any;
465
+ export declare const forEachAsync: {
466
+ (a: (item: any) => Promise<any>): (b: any[]) => Promise<any[]>;
467
+ (a: (item: any) => Promise<any>, b: any[]): Promise<any[]>;
468
+ (a: typeof __, b: any[]): (a: (item: any) => Promise<any>) => Promise<any[]>;
469
+ (a: (item: any) => Promise<any>, b: typeof __): (b: any[]) => Promise<any[]>;
470
+ };
108
471
  /** The same as compose, but waits for promises in chains and returns a Promise. */
109
- export declare const composeAsync: <T = any>(...fns: AnyFunc[]) => (data?: any) => Promise<T>;
472
+ export declare const composeAsync: import("ts-toolbelt/out/Function/Compose/Multi/Async").ComposeMultiAsync;
110
473
  export declare const mirror: (s: any) => any;
111
474
  export declare const reflect: (s: any) => any;
112
475
  export declare const echo: (s: any) => any;
113
- export declare const qappend: (...args: any[]) => any;
114
- export declare const qassoc: (...args: any[]) => any;
115
- export declare const qreduce: (...args: any[]) => any;
116
- export declare const qmergeDeep: any;
117
- export declare const qmergeDeepX: any;
118
- export declare const qmergeDeepAdd: any;
476
+ export declare const qappend: {
477
+ (a: any): (b: any[]) => any[];
478
+ (a: any, b: any[]): any[];
479
+ (a: typeof __, b: any[]): (a: any) => any[];
480
+ (a: any, b: typeof __): (b: any[]) => any[];
481
+ };
482
+ export declare const qassoc: import("ts-toolbelt/out/Function/Curry").Curry<(prop: string, v: any, obj: AnyObject) => AnyObject>;
483
+ export declare const qreduce: import("ts-toolbelt/out/Function/Curry").Curry<(<T>(fn: Reducer, accum: any, arr: T[]) => any)>;
484
+ export declare const qmergeDeep: import("ts-toolbelt/out/Function/Curry").Curry<(o1: AnyObject, o2: AnyObject) => AnyObject>;
485
+ export declare const qmergeDeepX: import("ts-toolbelt/out/Function/Curry").Curry<(o1: AnyObject, o2: AnyObject) => AnyObject>;
486
+ export declare const qmergeDeepAdd: import("ts-toolbelt/out/Function/Curry").Curry<(o1: AnyObject, o2: AnyObject) => AnyObject>;
119
487
  /** qmapKeys({ a: 'b' }, { a: 44 }) -> { b: 44 } */
120
- export declare const qmapKeys: (...args: any[]) => any;
121
- export declare const qfilter: (...args: any[]) => any;
488
+ export declare const qmapKeys: {
489
+ (a: {
490
+ [oldKey: string]: string;
491
+ }): (b: AnyObject) => AnyObject;
492
+ (a: {
493
+ [oldKey: string]: string;
494
+ }, b: AnyObject): AnyObject;
495
+ (a: typeof __, b: AnyObject): (a: {
496
+ [oldKey: string]: string;
497
+ }) => AnyObject;
498
+ (a: {
499
+ [oldKey: string]: string;
500
+ }, b: typeof __): (b: AnyObject) => AnyObject;
501
+ };
502
+ export declare const qfilter: {
503
+ (a: (v: any, k: string | number) => boolean): (b: any[] | AnyObject) => any[] | AnyObject;
504
+ (a: (v: any, k: string | number) => boolean, b: any[] | AnyObject): any[] | AnyObject;
505
+ (a: typeof __, b: any[] | AnyObject): (a: (v: any, k: string | number) => boolean) => any[] | AnyObject;
506
+ (a: (v: any, k: string | number) => boolean, b: typeof __): (b: any[] | AnyObject) => any[] | AnyObject;
507
+ };
122
508
  /** @deprecated */
123
- export declare const qindexOf: (...args: any[]) => any;
124
- export declare type StrTmpl = ((data: AnyObject) => string);
509
+ export declare const qindexOf: {
510
+ (a: any): (b: any[]) => number;
511
+ (a: any, b: any[]): number;
512
+ (a: typeof __, b: any[]): (a: any) => number;
513
+ (a: any, b: typeof __): (b: any[]) => number;
514
+ };
515
+ export type StrTmpl = ((data: AnyObject) => string);
125
516
  export declare const getTmpl: (tmpl: string) => StrTmpl;
126
517
 
127
518
  export {};
@@ -38,9 +38,6 @@ const _curry = (fn, args, new_args) => {
38
38
  const curry = ((fn) => ((...args) => fn.length > countArgs(args)
39
39
  ? _curry(fn, [], args)
40
40
  : fn(...args)));
41
- // type EndlessPh<Func extends FT.Function, ArgT> =
42
- // (a: ArgT) => ReturnType<Func>
43
- // | ((a: A.x) => EndlessPh<Func, ArgT>)
44
41
  const endlessph = (fn) => {
45
42
  function _endlessph(a) {
46
43
  return a === __ ? fn : fn(a);
@@ -72,6 +69,7 @@ function curry3(fn) {
72
69
 
73
70
  const undef = undefined;
74
71
  const nul = null;
72
+ const inf = Infinity;
75
73
  const to = (s) => typeof s;
76
74
  const isNull = (s) => s === nul;
77
75
  const isUndef = (s) => s === undef;
@@ -222,9 +220,9 @@ const includes = curry2((s, ss) => {
222
220
  return false;
223
221
  }
224
222
  });
225
- const slice = curry3((from, to, o) => o.slice(from, (isNum(to) ? to : Infinity)));
223
+ const slice = curry3((from, to, o) => o.slice(from, (isNum(to) ? to : inf)));
226
224
  const head = nth(0);
227
- const tail = slice(1, nul);
225
+ const tail = slice(1, inf); // typeshit.
228
226
  const add = curry2((n, m) => n + m);
229
227
  const subtract = curry2((n, m) => m - n);
230
228
  const flip = (fn) => curry((b, a) => fn(a, b));
@@ -297,7 +295,7 @@ const assoc = curry3((prop, v, obj) => ({
297
295
  }));
298
296
  const assocPath = curry3((_path, v, o) => compose((first) => assoc(first, length(_path) < 2
299
297
  ? v
300
- : assocPath(slice(1, null, _path), v, isObj(o[first]) ? o[first] : {}), o), head)(_path));
298
+ : assocPath(slice(1, inf, _path), v, isObj(o[first]) ? o[first] : {}), o), head)(_path));
301
299
  const all = curry2((pred, xs) => xs.every(pred));
302
300
  const any = curry2((pred, xs) => xs.some(pred));
303
301
  const allPass = curry2((preds, x) => preds.every((pred) => pred(x)));
@@ -307,7 +305,7 @@ const propEq = curry3((key, value, o) => equals(o[key], value));
307
305
  const propsEq = curry3((key, o1, o2) => equals(o1[key], o2[key]));
308
306
  const pathOr = curry3((_default, path, o) => ifElse(length, () => isNil(o)
309
307
  ? _default
310
- : compose(ifElse(isNil, always(_default), (o) => pathOr(_default, slice(1, nul, path), o)), flip(prop)(o), head)(path), always(o), path));
308
+ : compose(ifElse(isNil, always(_default), (o) => pathOr(_default, slice(1, inf, path), o)), flip(prop)(o), head)(path), always(o), path));
311
309
  const path = pathOr(undef);
312
310
  const pathEq = curry3((_path, value, o) => equals(path(_path, o), value));
313
311
  const pathsEq = curry3((_path, o1, o2) => equals(path(_path, o1), path(_path, o2)));
package/dist/bundle.js CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});const e=function(){},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=e=>typeof e,n=e=>null===e,c=e=>"number"==p(e),x=e=>Array.isArray(e),a=e=>"function"===p(e),l={u:"U",b:"B",n:"N",s:"S",f:"F"},i=e=>{const r=p(e);return"object"===r?n(e)?"Null":e.constructor.name:l[r[0]]+r.slice(1)},u=o(((e,r)=>(r.push(e),r))),f=o(((e,r,t)=>(t[e]=r,t))),d=o(((e,r,t)=>t.reduce(e,r))),h=o(((e,r,t)=>{for(let s in t)switch(i(t[s])){case"Array":if(e>1&&"Array"===i(r[s]))switch(e){case 2:const o=r[s],p=t[s];for(const r in p)o[r]?h(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"===i(r[s])){h(e,r[s],t[s]);break}default:r[s]=t[s]}return r})),m=h(1),g=h(2),y=h(3),b=o(((e,r)=>{let t,s,o,p;for(t in e)s=e[t],[o,p]=a(s)?s(r):[s,r[t]],r[o]=p,t!==o&&delete r[t];return r})),j=o(((e,r)=>{const t=x(r);for(let s in r)e(r[s],s)||(t?r.splice(s,1):delete r[s]);return r})),O=o(((e,r)=>r.indexOf(e))),w=o(((e,r)=>{const t=i(e);if(t===i(r)&&("Object"===t||"Array"==t)){if(n(e)||n(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&&w(e[s],r[s])))return!1;return!0}return e===r})),q=o(((e,r,t,s)=>e(s)?r(s):t(s))),A=o(((e,r,t)=>q(e,r,F,t))),E=(...r)=>(t=e)=>{for(let s=$(r)-1;s>-1;s--)t=t===e?r[s]():r[s](t);return t},k=o(((e,r)=>e.bind(r))),v=o(((e,r)=>r[e])),P=o(((e,r)=>{if((e=>"string"===p(e))(r))return r.includes(e);for(const t of r)if(w(t,e))return!0;return!1})),S=o(((e,r,t)=>t.slice(e,c(r)?r:1/0))),D=v(0),_=S(1,null),N=o(((e,r)=>e+r)),B=o(((e,r)=>r-e)),C=e=>o(((r,t)=>e(t,r))),U=e=>n(e)||(e=>void 0===e)(e),$=e=>e.length,z=e=>()=>e,F=e=>e,I=e=>!e,K=e=>(...r)=>{const t=e(...r);return a(t)&&t.$args_left?K(t):I(t)},L=e=>Object.entries(e),T=o(((e,r)=>e.test(r))),X=o(((e,r)=>(e(r),r))),M=o(((e,r)=>[...r,e])),G=o(((e,r)=>r.split(e))),H=z(!0),J=z(!1),Q=o(((e,r)=>V(N(e),r-e))),R=o(((e,r)=>e.filter(C(P)(r)))),V=o(((e,r)=>[...Array(r)].map(((r,t)=>e(t))))),W=o(((e,r)=>e>r)),Y=o(((e,r)=>e<r)),Z=o(((e,r)=>r>=e)),ee=o(((e,r)=>r<=e)),re=o(((e,r)=>r.sort(e))),te=o(((e,r)=>r.find(e))),se=o(((e,r)=>r.findIndex(e))),oe=o(((e,r)=>se(w(e),r))),pe=o(((e,r)=>{for(const[t,s]of e)if(t(r))return s(r)})),ne=o(((e,r,t)=>({...t,[e]:r}))),ce=o(((e,r,t)=>E((s=>{return ne(s,$(e)<2?r:ce(S(1,null,e),r,(o=t[s],n(o)||"object"!==p(o)?{}:t[s])),t);var o}),D)(e))),xe=o(((e,r)=>r.every(e))),ae=o(((e,r)=>r.some(e))),le=o(((e,r)=>e.every((e=>e(r))))),ie=o(((e,r)=>e.some((e=>e(r))))),ue=o(((e,r)=>r[e])),fe=o(((e,r,t)=>w(t[e],r))),de=o(((e,r,t)=>w(r[e],t[e]))),he=o(((e,r,t)=>q($,(()=>U(t)?e:E(q(U,z(e),(t=>he(e,S(1,null,r),t))),C(ue)(t),D)(r)),z(t),r))),me=he(undefined),ge=o(((e,r,t)=>w(me(e,t),r))),ye=o(((e,r,t)=>w(me(e,r),me(e,t)))),be=/^(.*?)(8|16|32|64)(Clamped)?Array$/,je=e=>{const r=i(e);switch(r){case"Null":return e;case"Array":return Pe(je,e);case"Object":const t={};for(let r in e)t[r]=je(e[r]);return t;case"String":case"Number":case"Boolean":case"Symbol":return e;default:return be.test(r)?Pe(je,e):e}},Oe=o(((e,r,t)=>d(e,je(r),t))),we=o(((e,r)=>Ne(e,r))),qe=o(((e,r)=>{const t={};for(const s of e)s in r&&(t[s]=r[s]);return t})),Ae=o(((e,r)=>Ne(((r,t)=>!P(t,e)),r))),Ee=e=>Oe(((e,r)=>ne(...r,e)),{},e),ke=o(((e,r)=>e.concat(r))),ve=o(((e,r)=>r.join(e))),Pe=o(((e,r)=>r.map(e))),Se=o(((e,r)=>r.forEach(e))),De=o(((e,r,t)=>r(t)&&e(t))),_e=o(((e,r,t)=>t.replace(e,r))),Ne=o(((e,r)=>x(r)?r.filter(e):E(Ee,Ne((([r,t])=>e(t,r))),L)(r))),Be=o(((e,r)=>Object.assign({},e,r))),Ce=o(((e,r)=>m(je(e),je(r)))),Ue=o(((e,r)=>g(je(e),je(r)))),$e=o(((e,r)=>y(je(e),je(r)))),ze=o(((e,r,t)=>ne(e,r(t[e]),t))),Fe=o(((e,r)=>b(e,Object.assign({},r)))),Ie=(()=>{const e=async(r,t,s)=>{s<t.length&&(await r(t[s]),await e(r,t,++s))};return o(((r,t)=>e(r,t,0)))})(),Ke=o(((e,r)=>Promise.all(r.map(e)))),Le=(()=>{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)})(),Te=F,Xe=F,Me=F;exports.F=J,exports.T=H,exports.__=e,exports.add=N,exports.all=xe,exports.allPass=le,exports.always=z,exports.any=ae,exports.anyPass=ie,exports.append=M,exports.assoc=ne,exports.assocPath=ce,exports.bind=k,exports.both=De,exports.clone=je,exports.complement=K,exports.compose=E,exports.composeAsync=Le,exports.concat=ke,exports.cond=pe,exports.curry=o,exports.echo=Me,exports.empty=e=>{switch(i(e)){case"String":return"";case"Object":return{};case"Array":return[];default:return}},exports.equals=w,exports.explore=(e,r="log")=>X((t=>console[r](e,t))),exports.filter=Ne,exports.find=te,exports.findIndex=se,exports.flip=C,exports.forEach=Se,exports.forEachAsync=Ke,exports.forEachSerial=Ie,exports.fromPairs=Ee,exports.genBy=V,exports.getTmpl=e=>{const r=[],t=[],s=e.length;let o,p,n=0,c=0,x=!1;for(n=0;n<s;n++)switch(o=e[n],o){case"{":x=!0,c=n;break;case"}":x=!1,r.push(""),t.push(e.slice(c+1,n));break;default:x||(p=r.length-1,p<0&&(r.push(""),p++),r[p]+=o)}return e=>{const s=[],o=r.length-1;for(const p in r)n=+p,s.push(r[n]),n!==o&&s.push(me(t[n].split("."),e));return s.join("")}},exports.gt=W,exports.gte=Z,exports.head=D,exports.identity=F,exports.ifElse=q,exports.includes=P,exports.indexOf=oe,exports.intersection=R,exports.isEmpty=e=>{switch(i(e)){case"String":case"Array":return 0==$(e);case"Object":for(const r in e)return!1;return!0;default:return null}},exports.isNil=U,exports.join=ve,exports.keys=e=>Object.keys(e),exports.last=e=>e[$(e)-1],exports.length=$,exports.lt=Y,exports.lte=ee,exports.map=Pe,exports.mapKeys=Fe,exports.memoize=e=>{let r,t=!1;return()=>t?r:(t=!0,r=e())},exports.mergeDeep=Ce,exports.mergeDeepAdd=$e,exports.mergeDeepX=Ue,exports.mergeShallow=Be,exports.mirror=Te,exports.not=I,exports.nth=v,exports.omit=Ae,exports.once=e=>{let r,t=!1;return(...s)=>t?r:(t=!0,r=e(...s))},exports.overProp=ze,exports.path=me,exports.pathEq=ge,exports.pathOr=he,exports.pathsEq=ye,exports.pick=qe,exports.pickBy=we,exports.prop=ue,exports.propEq=fe,exports.propsEq=de,exports.qappend=u,exports.qassoc=f,exports.qfilter=j,exports.qindexOf=O,exports.qmapKeys=b,exports.qmergeDeep=m,exports.qmergeDeepAdd=y,exports.qmergeDeepX=g,exports.qreduce=d,exports.range=Q,exports.reduce=Oe,exports.reflect=Xe,exports.replace=_e,exports.reverse=e=>E((r=>Oe(((t,s,o)=>u(e[r-o],t)),[],e)),N(-1),$)(e),exports.sizeof=e=>{if("Object"===i(e)){let r=0;for(let t in e)r++;return r}return $(e)},exports.slice=S,exports.sort=re,exports.split=G,exports.subtract=B,exports.tail=_,exports.tap=X,exports.test=T,exports.toLower=e=>e.toLowerCase(),exports.toPairs=L,exports.toUpper=e=>e.toUpperCase(),exports.trim=e=>e.trim(),exports.type=i,exports.uniq=e=>d(((e,r)=>P(r,e)?e:u(r,e)),[],e),exports.values=e=>Object.values(e),exports.waitAll=e=>Promise.all(e),exports.when=A;
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;
package/dist/es/curry.js CHANGED
@@ -1,4 +1,4 @@
1
- export const __ = (function Placeholder() { });
1
+ export const __ = Symbol('Placeholder');
2
2
  const countArgs = (s) => {
3
3
  let i = 0;
4
4
  for (const v of s)
@@ -38,3 +38,31 @@ const _curry = (fn, args, new_args) => {
38
38
  export const curry = ((fn) => ((...args) => fn.length > countArgs(args)
39
39
  ? _curry(fn, [], args)
40
40
  : fn(...args)));
41
+ const endlessph = (fn) => {
42
+ function _endlessph(a) {
43
+ return a === __ ? fn : fn(a);
44
+ }
45
+ return _endlessph;
46
+ };
47
+ export function curry2(fn) {
48
+ function curried2(a, b) {
49
+ const withPlaceholder1 = a === __;
50
+ const aln = arguments.length;
51
+ if (aln === 1 && withPlaceholder1)
52
+ throw new Error('Senseless placeholder usage.');
53
+ return arguments.length > 1
54
+ ? withPlaceholder1
55
+ ? endlessph((a) => fn(a, b))
56
+ : fn(a, b)
57
+ : (b) => fn(a, b);
58
+ }
59
+ return curried2;
60
+ }
61
+ export function curry3(fn) {
62
+ // type p0 = Parameters<Func>[0]
63
+ // type p1 = Parameters<Func>[1]
64
+ // type p2 = Parameters<Func>[2]
65
+ // type ReturnT = ReturnType<Func>
66
+ // TODO: optimize.
67
+ return curry(fn);
68
+ }
package/dist/es/index.js CHANGED
@@ -1,4 +1,5 @@
1
1
  export * from './curry';
2
+ export * from './uncurry';
2
3
  export * from './common';
3
4
  export * from './safe';
4
5
  export * from './quick';
package/dist/es/quick.js CHANGED
@@ -1,14 +1,14 @@
1
- import { curry } from "./curry";
1
+ import { curry2, curry3 } from "./curry";
2
2
  import { type } from "./common";
3
3
  import { isFunc, isArray } from "./utils";
4
- export const qappend = curry((s, xs) => { xs.push(s); return xs; });
5
- export const qassoc = curry((prop, v, obj) => {
4
+ export const qappend = curry2((s, xs) => { xs.push(s); return xs; });
5
+ export const qassoc = curry3((prop, v, obj) => {
6
6
  obj[prop] = v;
7
7
  return obj;
8
8
  });
9
- export const qreduce = curry((fn, accum, arr) => arr.reduce(fn, accum));
9
+ export const qreduce = curry3((fn, accum, arr) => arr.reduce(fn, accum));
10
10
  // strategy is for arrays: 1->clean, 2->merge, 3->push.
11
- const mergeDeep = curry((strategy, o1, o2) => {
11
+ const mergeDeep = curry3((strategy, o1, o2) => {
12
12
  for (let k in o2) {
13
13
  switch (type(o2[k])) {
14
14
  case 'Array':
@@ -49,7 +49,7 @@ export const qmergeDeep = mergeDeep(1);
49
49
  export const qmergeDeepX = mergeDeep(2);
50
50
  export const qmergeDeepAdd = mergeDeep(3);
51
51
  /** qmapKeys({ a: 'b' }, { a: 44 }) -> { b: 44 } */
52
- export const qmapKeys = curry((keyMap, o) => {
52
+ export const qmapKeys = curry2((keyMap, o) => {
53
53
  let k, mapped, newKey, newValue;
54
54
  for (k in keyMap) {
55
55
  mapped = keyMap[k];
@@ -63,7 +63,7 @@ export const qmapKeys = curry((keyMap, o) => {
63
63
  }
64
64
  return o;
65
65
  });
66
- export const qfilter = curry((cond, data) => {
66
+ export const qfilter = curry2((cond, data) => {
67
67
  const isArr = isArray(data);
68
68
  for (let k in data) {
69
69
  if (!cond(data[k], k)) {
@@ -79,4 +79,4 @@ export const qfilter = curry((cond, data) => {
79
79
  return data;
80
80
  });
81
81
  /** @deprecated */
82
- export const qindexOf = curry((x, xs) => xs.indexOf(x));
82
+ export const qindexOf = curry2((x, xs) => xs.indexOf(x));
package/dist/es/safe.js CHANGED
@@ -1,9 +1,9 @@
1
- import { __, curry } from './curry';
2
- import { isNum, nul, isUndef, undef, isNull, isArray, isFunc, isStr, isObj } from './utils';
1
+ import { __, curry, curry2, curry3 } from './curry';
2
+ import { isNum, isUndef, undef, isNull, isArray, isFunc, isStr, isObj, inf } from './utils';
3
3
  import { qmergeDeep, qreduce, qappend, qmapKeys, qmergeDeepX, qmergeDeepAdd } from './quick';
4
4
  import { type } from './common';
5
5
  // over, lensProp
6
- export const equals = curry((a, b) => {
6
+ export const equals = curry2((a, b) => {
7
7
  const typea = type(a);
8
8
  if (typea === type(b) && (typea === 'Object' || typea == 'Array')) {
9
9
  if (isNull(a) || isNull(b)) {
@@ -25,16 +25,17 @@ export const equals = curry((a, b) => {
25
25
  return a === b;
26
26
  });
27
27
  export const ifElse = curry((cond, pipeYes, pipeNo, s) => cond(s) ? pipeYes(s) : pipeNo(s));
28
- export const when = curry((cond, pipe, s) => ifElse(cond, pipe, identity, s));
28
+ export const when = curry3((cond, pipe, s) => ifElse(cond, pipe, identity, s));
29
29
  export const compose = ((...fns) => (s = __) => {
30
30
  for (let i = length(fns) - 1; i > -1; i--) {
31
31
  s = s === __ ? fns[i]() : fns[i](s);
32
32
  }
33
33
  return s;
34
- }); // as F.Compose
35
- export const bind = curry((fn, context) => fn.bind(context));
36
- export const nth = curry((i, data) => data[i]);
37
- export const includes = curry((s, ss) => {
34
+ });
35
+ export const bind = curry2((fn, context) => fn.bind(context));
36
+ const _nth = (i, data) => data[i];
37
+ export const nth = curry2(_nth);
38
+ export const includes = curry2((s, ss) => {
38
39
  if (isStr(ss)) {
39
40
  return ss.includes(s);
40
41
  }
@@ -47,11 +48,11 @@ export const includes = curry((s, ss) => {
47
48
  return false;
48
49
  }
49
50
  });
50
- export const slice = curry((from, to, o) => o.slice(from, (isNum(to) ? to : Infinity)));
51
+ export const slice = curry3((from, to, o) => o.slice(from, (isNum(to) ? to : inf)));
51
52
  export const head = nth(0);
52
- export const tail = slice(1, nul);
53
- export const add = curry((n, m) => n + m);
54
- export const subtract = curry((n, m) => m - n);
53
+ export const tail = slice(1, inf); // typeshit.
54
+ export const add = curry2((n, m) => n + m);
55
+ export const subtract = curry2((n, m) => m - n);
55
56
  export const flip = (fn) => curry((b, a) => fn(a, b));
56
57
  export const isNil = (s) => isNull(s) || isUndef(s);
57
58
  export const length = (s) => s.length;
@@ -67,10 +68,10 @@ export const complement = (fn) => (...args) => {
67
68
  export const keys = (o) => Object.keys(o);
68
69
  export const values = (o) => Object.values(o);
69
70
  export const toPairs = (o) => Object.entries(o);
70
- export const test = curry((re, s) => re.test(s));
71
- export const tap = curry((fn, s) => { fn(s); return s; });
72
- export const append = curry((s, xs) => [...xs, s]);
73
- export const split = curry((s, xs) => xs.split(s));
71
+ export const test = curry2((re, s) => re.test(s));
72
+ export const tap = curry2((fn, s) => { fn(s); return s; });
73
+ export const append = curry2((s, xs) => [...xs, s]);
74
+ export const split = curry2((s, xs) => xs.split(s));
74
75
  export const T = always(true);
75
76
  export const F = always(false);
76
77
  export const sizeof = (s) => {
@@ -83,10 +84,10 @@ export const sizeof = (s) => {
83
84
  else
84
85
  return length(s);
85
86
  };
86
- export const range = curry((from, to) => genBy(add(from), to - from));
87
+ export const range = curry2((from, to) => genBy(add(from), to - from));
87
88
  export const uniq = (xs) => qreduce((accum, x) => includes(x, accum) ? accum : qappend(x, accum), [], xs);
88
- export const intersection = curry((xs1, xs2) => xs1.filter(flip(includes)(xs2)));
89
- export const genBy = curry((generator, length) => [...Array(length)].map((_, i) => generator(i)));
89
+ export const intersection = curry2((xs1, xs2) => xs1.filter(flip(includes)(xs2)));
90
+ export const genBy = curry2((generator, length) => [...Array(length)].map((_, i) => generator(i)));
90
91
  export const once = (fn) => {
91
92
  let done = false, cache;
92
93
  return (...args) => {
@@ -100,50 +101,51 @@ export const once = (fn) => {
100
101
  };
101
102
  };
102
103
  export const reverse = (xs) => compose((ln) => reduce((nxs, _, i) => qappend(xs[ln - i], nxs), [], xs), add(-1), length)(xs);
103
- export const gt = curry((a, b) => a > b);
104
- export const lt = curry((a, b) => a < b);
105
- export const gte = curry((a, b) => b >= a);
106
- export const lte = curry((a, b) => b <= a);
107
- // : <U=any>(sortFn: (v: U)=>-1|1, xs: U[]) => U[]
108
- export const sort = curry((sortFn, xs) => xs.sort(sortFn));
109
- export const find = curry((fn, s) => s.find(fn));
110
- export const findIndex = curry((fn, s) => s.findIndex(fn));
111
- export const indexOf = curry((x, xs) => findIndex(equals(x), xs));
104
+ export const gt = curry2((a, b) => a > b);
105
+ export const lt = curry2((a, b) => a < b);
106
+ export const gte = curry2((a, b) => b >= a);
107
+ export const lte = curry2((a, b) => b <= a);
108
+ export const sort = curry2((sortFn, xs) => xs.sort(sortFn));
109
+ export const find = curry2((fn, s) => s.find(fn));
110
+ export const findIndex = curry2((fn, s) => s.findIndex(fn));
111
+ export const indexOf = curry2((x, xs) => findIndex(equals(x), xs));
112
112
  export const explore = (caption, level = 'log') => tap((v) => console[level](caption, v));
113
- export const cond = curry((pairs, s) => {
113
+ export const cond = curry2((pairs, s) => {
114
114
  for (const [cond, fn] of pairs) {
115
115
  if (cond(s)) {
116
116
  return fn(s);
117
117
  }
118
118
  }
119
119
  });
120
- export const assoc = curry((prop, v, obj) => ({
120
+ export const assoc = curry3((prop, v, obj) => ({
121
121
  ...obj,
122
122
  [prop]: v
123
123
  }));
124
- export const assocPath = curry((_path, v, o) => compose((first) => assoc(first, length(_path) < 2
124
+ export const assocPath = curry3((_path, v, o) => compose((first) => assoc(first, length(_path) < 2
125
125
  ? v
126
- : assocPath(slice(1, null, _path), v, isObj(o[first]) ? o[first] : {}), o), head)(_path));
127
- export const all = curry((pred, xs) => xs.every(pred));
128
- export const any = curry((pred, xs) => xs.some(pred));
129
- export const allPass = curry((preds, x) => preds.every((pred) => pred(x)));
130
- export const anyPass = curry((preds, x) => preds.some((pred) => pred(x)));
131
- export const prop = curry((key, o) => o[key]);
132
- export const propEq = curry((key, value, o) => equals(o[key], value));
133
- export const propsEq = curry((key, o1, o2) => equals(o1[key], o2[key]));
134
- export const pathOr = curry((_default, path, o) => ifElse(length, () => isNil(o)
126
+ : assocPath(slice(1, inf, _path), v, isObj(o[first]) ? o[first] : {}), o), head)(_path));
127
+ export const all = curry2((pred, xs) => xs.every(pred));
128
+ export const any = curry2((pred, xs) => xs.some(pred));
129
+ export const allPass = curry2((preds, x) => preds.every((pred) => pred(x)));
130
+ export const anyPass = curry2((preds, x) => preds.some((pred) => pred(x)));
131
+ export const prop = curry2((key, o) => o[key]);
132
+ export const propEq = curry3((key, value, o) => equals(o[key], value));
133
+ export const propsEq = curry3((key, o1, o2) => equals(o1[key], o2[key]));
134
+ export const pathOr = curry3((_default, path, o) => ifElse(length, () => isNil(o)
135
135
  ? _default
136
- : compose(ifElse(isNil, always(_default), (o) => pathOr(_default, slice(1, nul, path), o)), flip(prop)(o), head)(path), always(o), path));
136
+ : compose(ifElse(isNil, always(_default), (o) => pathOr(_default, slice(1, inf, path), o)), flip(prop)(o), head)(path), always(o), path));
137
137
  export const path = pathOr(undef);
138
- export const pathEq = curry((_path, value, o) => equals(path(_path, o), value));
139
- export const pathsEq = curry((_path, o1, o2) => equals(path(_path, o1), path(_path, o2)));
138
+ export const pathEq = curry3((_path, value, o) => equals(path(_path, o), value));
139
+ export const pathsEq = curry3((_path, o1, o2) => equals(path(_path, o1), path(_path, o2)));
140
140
  const typed_arr_re = /^(.*?)(8|16|32|64)(Clamped)?Array$/;
141
- export const clone = (s) => {
141
+ export const clone = (s, shallow = false) => {
142
142
  const t = type(s);
143
143
  switch (t) {
144
144
  case 'Null': return s;
145
- case 'Array': return map(clone, s);
145
+ case 'Array': return shallow ? [...s] : map(clone, s);
146
146
  case 'Object':
147
+ if (shallow)
148
+ return { ...s };
147
149
  const out = {};
148
150
  for (let k in s) {
149
151
  out[k] = clone(s[k]);
@@ -155,12 +157,13 @@ export const clone = (s) => {
155
157
  case 'Symbol':
156
158
  return s;
157
159
  default:
158
- return typed_arr_re.test(t) ? map(clone, s) : s;
160
+ return typed_arr_re.test(t) ? s.constructor.from(s) : s;
159
161
  }
160
162
  };
161
- export const reduce = curry((fn, accum, arr) => qreduce(fn, clone(accum), arr));
162
- export const pickBy = curry((cond, o) => filter(cond, o));
163
- export const pick = curry((props, o) => {
163
+ export const cloneShallow = (s) => clone(s, true);
164
+ export const reduce = curry3((fn, accum, arr) => qreduce(fn, clone(accum), arr));
165
+ export const pickBy = curry2((cond, o) => filter(cond, o));
166
+ export const pick = curry2((props, o) => {
164
167
  const out = {};
165
168
  for (const p of props) {
166
169
  if (p in o) {
@@ -169,13 +172,13 @@ export const pick = curry((props, o) => {
169
172
  }
170
173
  return out;
171
174
  });
172
- export const omit = curry((props, o) => filter((_, k) => !includes(k, props), o));
175
+ export const omit = curry2((props, o) => filter((_, k) => !includes(k, props), o));
173
176
  export const fromPairs = (pairs) => reduce((o, pair) => assoc(...pair, o), {}, pairs);
174
- export const concat = curry(((a, b) => a.concat(b)));
175
- export const join = curry((delimeter, arr) => arr.join(delimeter));
176
- export const map = curry((pipe, arr) => arr.map(pipe));
177
- export const forEach = curry((pipe, arr) => arr.forEach(pipe));
178
- export const both = curry((cond1, cond2, s) => cond2(s) && cond1(s));
177
+ export const concat = curry2(((a, b) => a.concat(b)));
178
+ export const join = curry2((delimeter, arr) => arr.join(delimeter));
179
+ export const map = curry2((pipe, arr) => arr.map(pipe));
180
+ export const forEach = curry2((pipe, arr) => arr.forEach(pipe));
181
+ export const both = curry3((cond1, cond2, s) => cond2(s) && cond1(s));
179
182
  export const isEmpty = (s) => {
180
183
  switch (type(s)) {
181
184
  case 'String':
@@ -195,8 +198,8 @@ export const empty = (s) => {
195
198
  default: return undef;
196
199
  }
197
200
  };
198
- export const replace = curry((a, b, where) => where.replace(a, b));
199
- export const filter = curry((cond, data) => isArray(data)
201
+ export const replace = curry3((a, b, where) => where.replace(a, b));
202
+ export const filter = curry2((cond, data) => isArray(data)
200
203
  ? data.filter(cond)
201
204
  : compose(fromPairs, filter(([k, v]) => cond(v, k)), toPairs)(data));
202
205
  export const memoize = (fn) => {
@@ -204,13 +207,13 @@ export const memoize = (fn) => {
204
207
  let cached = false;
205
208
  return () => cached ? cache : (cached = true, cache = fn());
206
209
  };
207
- export const mergeShallow = curry((o1, o2) => Object.assign({}, o1, o2));
208
- export const mergeDeep = curry((a, b) => qmergeDeep(clone(a), clone(b)));
209
- export const mergeDeepX = curry((a, b) => qmergeDeepX(clone(a), clone(b)));
210
- export const mergeDeepAdd = curry((a, b) => qmergeDeepAdd(clone(a), clone(b)));
211
- export const overProp = curry((prop, pipe, data) => assoc(prop, pipe(data[prop]), data));
210
+ export const mergeShallow = curry2((o1, o2) => Object.assign({}, o1, o2));
211
+ export const mergeDeep = curry2((a, b) => qmergeDeep(clone(a), clone(b)));
212
+ export const mergeDeepX = curry2((a, b) => qmergeDeepX(clone(a), clone(b)));
213
+ export const mergeDeepAdd = curry2((a, b) => qmergeDeepAdd(clone(a), clone(b)));
214
+ export const overProp = curry3((prop, pipe, data) => assoc(prop, pipe(data[prop]), data));
212
215
  /** mapKeys({ a: 'b' }, { a: 44 }) -> { b: 44 } */
213
- export const mapKeys = curry((keyMap, o) => qmapKeys(keyMap, Object.assign({}, o)));
216
+ export const mapKeys = curry2((keyMap, o) => qmapKeys(keyMap, Object.assign({}, o)));
214
217
  // ASYNCS
215
218
  /** One promise waits for another. */
216
219
  export const forEachSerial = (() => {
@@ -220,12 +223,13 @@ export const forEachSerial = (() => {
220
223
  await pipe(fn, items, ++i);
221
224
  }
222
225
  };
223
- return curry((fn, items) => pipe(fn, items, 0));
226
+ return curry2((fn, items) => pipe(fn, items, 0));
224
227
  })();
225
228
  /** Promise.all wrapper for functional pipelining. */
226
229
  export const waitAll = (promises) => Promise.all(promises);
230
+ export const waitTap = curry2(async (fn, s) => { await fn(s); return s; });
227
231
  /** Waits for all promises mapped by the fn. */
228
- export const forEachAsync = curry((fn, items) => Promise.all(items.map(fn)));
232
+ export const forEachAsync = curry2((fn, items) => Promise.all(items.map(fn)));
229
233
  /** The same as compose, but waits for promises in chains and returns a Promise. */
230
234
  export const composeAsync = (() => {
231
235
  const pipe = async (fns, data, i) => ~i ? await pipe(fns, await fns[i](data), --i) : data;
@@ -0,0 +1,3 @@
1
+ import { qreduce } from "./quick";
2
+ // TODO: possibly introduce a second argument limiting unfolding.
3
+ export const uncurry = (fn) => (...args) => qreduce(((fn, arg) => fn ? fn(arg) : fn), fn, args);
package/dist/es/utils.js CHANGED
@@ -1,5 +1,6 @@
1
1
  export const undef = undefined;
2
2
  export const nul = null;
3
+ export const inf = Infinity;
3
4
  export const to = (s) => typeof s;
4
5
  export const isNull = (s) => s === nul;
5
6
  export const isUndef = (s) => s === undef;
package/dts-fix.js ADDED
@@ -0,0 +1,8 @@
1
+ import prepend from 'prepend'
2
+  
3
+ const s = "import {F as FT} from 'ts-toolbelt' \n"
4
+
5
+ prepend('./dist/bundle.d.ts', s, function(error) {
6
+     if (error)
7
+         console.error(error.message)
8
+ })
package/package.json CHANGED
@@ -32,14 +32,15 @@
32
32
  "test": "npm run gentypes && npm run prod:cjs && ava",
33
33
  "test:report": "nyc npm test && nyc report --reporter=text-lcov > coverage.lcov && codecov",
34
34
  "test:lazy": "ava",
35
- "gentypes": "dts-bundle-generator -o dist/bundle.d.ts src/index.ts",
35
+ "dts-fix": "node dts-fix.js",
36
+ "gentypes": "dts-bundle-generator --no-check -o dist/bundle.d.ts src/index.ts && npm run dts-fix",
36
37
  "dev": "cross-env NODE_ENV=development BUILD=es rollup -c",
37
38
  "prod:cjs": "cross-env NODE_ENV=production BUILD=cjs rollup -c",
38
39
  "prod:es": "cross-env NODE_ENV=production tsc",
39
40
  "prod": "npm run gentypes && npm run prod:es && npm run prod:cjs",
40
41
  "all": "npm run dev && npm run prod"
41
42
  },
42
- "version": "0.13.0b1",
43
+ "version": "0.13.0b2",
43
44
  "ava": {
44
45
  "files": [
45
46
  "./test/specs/*.ts"
@@ -53,6 +54,9 @@
53
54
  "ts-node/register"
54
55
  ]
55
56
  },
57
+ "dependencies": {
58
+ "ts-toolbelt": "^9.6.0"
59
+ },
56
60
  "devDependencies": {
57
61
  "@types/node": "^18.11.10",
58
62
  "ava": "^5.1.0",
@@ -60,6 +64,7 @@
60
64
  "cross-env": "^7.0.3",
61
65
  "dts-bundle-generator": "^7.1.0",
62
66
  "nyc": "^15.1.0",
67
+ "prepend": "^1.0.2",
63
68
  "rollup": "^3.5.1",
64
69
  "rollup-plugin-commonjs": "^10.1.0",
65
70
  "rollup-plugin-node-resolve": "^5.2.0",
@@ -68,7 +73,6 @@
68
73
  "rollup-plugin-terser": "^7.0.2",
69
74
  "rollup-plugin-typescript2": "^0.34.1",
70
75
  "ts-node": "^10.9.1",
71
- "ts-toolbelt": "^9.6.0",
72
76
  "tslint": "^6.1.0",
73
77
  "typescript": "^4.9.3"
74
78
  },
package/src/curry.ts CHANGED
@@ -1,7 +1,8 @@
1
- import { F as FT, A } from 'ts-toolbelt'
1
+ import { F as FT } from 'ts-toolbelt'
2
2
  import { AnyFunc, AnyArgs } from "./types"
3
3
 
4
- export const __ = Symbol('Placeholder') as A.x
4
+ export const __ = Symbol('Placeholder')
5
+ type Placeholder = typeof __
5
6
 
6
7
  const countArgs = (s: AnyArgs) => {
7
8
  let i = 0
@@ -51,15 +52,12 @@ export const curry = (
51
52
  : fn(...args)
52
53
  ) as FT.Curry<Func>
53
54
  )
54
- // type EndlessPh<Func extends FT.Function, ArgT> =
55
- // (a: ArgT) => ReturnType<Func>
56
- // | ((a: A.x) => EndlessPh<Func, ArgT>)
57
55
  const endlessph = <Func extends FT.Function>(fn: Func) => {
58
56
  type ReturnT = ReturnType<Func>
59
57
  type p0 = Parameters<Func>[0]
60
58
  function _endlessph(a: p0): ReturnT
61
- function _endlessph(a: A.x): Func
62
- function _endlessph(a: p0 | A.x) {
59
+ function _endlessph(a: Placeholder): Func
60
+ function _endlessph(a: p0 | Placeholder) {
63
61
  return a===__ ? fn : fn(a)
64
62
  }
65
63
  return _endlessph
@@ -72,9 +70,9 @@ export function curry2<Func extends Func2>(fn: Func) {
72
70
  type ReturnT = ReturnType<Func>
73
71
  function curried2( a: p0 ): (b: p1) => ReturnT
74
72
  function curried2( a: p0, b: p1 ): ReturnT
75
- function curried2( a: A.x, b: p1 ): (a: p0) => ReturnT
76
- function curried2( a: p0, b: A.x ): (b: p1) => ReturnT
77
- function curried2( a: p0 | A.x, b?: p1 ) {
73
+ function curried2( a: Placeholder, b: p1 ): (a: p0) => ReturnT
74
+ function curried2( a: p0, b: Placeholder ): (b: p1) => ReturnT
75
+ function curried2( a: p0 | Placeholder, b?: p1 ) {
78
76
  const withPlaceholder1 = a===__
79
77
  const aln = arguments.length
80
78
  if(aln === 1 && withPlaceholder1)
@@ -95,5 +93,5 @@ export function curry3<Func extends Func3>(fn: Func) {
95
93
  // type p2 = Parameters<Func>[2]
96
94
  // type ReturnT = ReturnType<Func>
97
95
  // TODO: optimize.
98
- return curry(fn)
96
+ return curry(fn) as FT.Curry<Func>
99
97
  }
package/src/quick.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { curry, curry2, curry3 } from "./curry"
1
+ import { curry2, curry3 } from "./curry"
2
2
  import { type } from "./common"
3
3
  import { AnyObject, Reducer, AnyFunc } from "./types"
4
4
  import { isFunc, isArray } from "./utils"
@@ -11,7 +11,7 @@ export const qassoc = curry3(
11
11
  }
12
12
  )
13
13
  export const qreduce = curry3(
14
- (fn: Reducer, accum: any, arr: any[]) =>
14
+ <T>(fn: Reducer, accum: any, arr: T[]) =>
15
15
  arr.reduce(fn, accum)
16
16
  )
17
17
  // strategy is for arrays: 1->clean, 2->merge, 3->push.
package/src/safe.ts CHANGED
@@ -1,9 +1,9 @@
1
1
  import { __, curry, curry2, curry3 } from './curry'
2
- import { isNum, nul, isUndef, undef, isNull, isArray, isFunc, isStr, isObj } from './utils'
2
+ import { isNum, nul, isUndef, undef, isNull, isArray, isFunc, isStr, isObj, inf } from './utils'
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 } from 'ts-toolbelt'
6
+ import { F as FT, U } from 'ts-toolbelt'
7
7
  // over, lensProp
8
8
 
9
9
  export const equals = curry2((a: any, b: any) => {
@@ -62,7 +62,7 @@ const _nth = <T=any>(i: number, data: T[]) => data[i]
62
62
  export const nth = curry2(_nth)
63
63
 
64
64
  export const includes = curry2(
65
- (s: any, ss: any[]) => {
65
+ <T>(s: T, ss: T[]) => {
66
66
  if(isStr(ss)) {
67
67
  return ss.includes(s)
68
68
  } else {
@@ -76,11 +76,11 @@ export const includes = curry2(
76
76
  }
77
77
  )
78
78
  export const slice = curry3(
79
- (from: number, to: number|null, o: any[] | string) =>
80
- o.slice(from, (isNum(to)?to:Infinity) as number)
79
+ (from: number, to: number, o: any[] | string) =>
80
+ o.slice(from, (isNum(to)?to:inf) as number)
81
81
  )
82
82
  export const head = nth(0)
83
- export const tail = slice(1, nul)
83
+ export const tail = slice(1, inf) // typeshit.
84
84
  export const add = curry2((n: number, m: number) => n+m)
85
85
  export const subtract = curry2((n: number, m: number) => m-n)
86
86
  export const flip = (fn: Function) => curry((b: any, a: any) => fn(a, b))
@@ -115,7 +115,7 @@ export const range = curry2((from: number, to: number) =>
115
115
  genBy(add(from), to-from)
116
116
  )
117
117
  export const uniq = (xs: any[]) => qreduce(
118
- (accum: any[], x: any) =>
118
+ <T>(accum: any, x: T) =>
119
119
  includes(x, accum) ? accum : qappend(x, accum),
120
120
  [], xs)
121
121
  export const intersection = curry2(
@@ -139,8 +139,8 @@ export const once = <Func extends AnyFunc>(fn: Func) => {
139
139
  }
140
140
  }
141
141
  export const reverse = (xs: any[]) => compose(
142
- (ln: number) => reduce(
143
- (nxs: any[], _: any, i: number) => qappend(xs[ln-i], nxs),
142
+ <T>(ln: number) => reduce<any>(
143
+ (nxs: T[], _: any, i: number) => qappend(xs[ln-i], nxs),
144
144
  [], xs
145
145
  ),
146
146
  add(-1),
@@ -178,7 +178,7 @@ export const assocPath = curry3(
178
178
  first,
179
179
  length(_path)<2
180
180
  ? v
181
- : assocPath(slice(1, null, _path), v, isObj(o[first]) ? o[first] : {}),
181
+ : assocPath(slice(1, inf, _path), v, isObj(o[first]) ? o[first] : {}),
182
182
  o
183
183
  ),
184
184
  head
@@ -207,7 +207,7 @@ export const pathOr = curry3(
207
207
  : compose(
208
208
  ifElse(isNil,
209
209
  always(_default),
210
- (o: any) => pathOr(_default, slice(1, nul, path), o)
210
+ (o: any) => pathOr(_default, slice(1, inf, path), o)
211
211
  ),
212
212
  flip(prop)(o),
213
213
  head
@@ -269,7 +269,7 @@ export const omit = curry2(
269
269
  o
270
270
  )
271
271
  )
272
- export const fromPairs = (pairs: [string, any][]) => reduce(
272
+ export const fromPairs = (pairs: [string, any][]) => reduce<any>(
273
273
  (o: AnyObject, pair: [string, any]) => assoc(...pair, o),
274
274
  {}, pairs
275
275
  )
package/src/types.ts CHANGED
@@ -7,7 +7,7 @@ export type Curried<
7
7
  Args extends AnyArgs = AnyArgs,
8
8
  ReturnT = any
9
9
  > = (arg: Args[number]) => Curried<Args> | ReturnT
10
- export type Reducer = <T>(accum: T, cur: any, index: number) => T
10
+ export type Reducer = <T=any>(accum: T, cur: any, index: number) => T
11
11
  export type AnyFunc<
12
12
  ReturnT = any,
13
13
  Args extends AnyArgs = AnyArgs
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
package/src/utils.ts CHANGED
@@ -2,6 +2,7 @@
2
2
 
3
3
  export const undef = undefined
4
4
  export const nul = null
5
+ export const inf = Infinity
5
6
  export const to = (s: any) => typeof s
6
7
  export const isNull = (s: any) => s===nul
7
8
  export const isUndef = (s: any) => s===undef