pepka 0.13.0-b7 → 0.13.0-b9
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 +152 -38
- package/package.json +1 -1
- package/src/curry.ts +3 -3
- package/src/safe.ts +6 -4
- package/src/uncurry.ts +1 -1
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:
|
|
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):
|
|
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:
|
|
36
|
-
export declare const when: (
|
|
37
|
-
export
|
|
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 = any, TOut = any>(x: TIn) => TOut;
|
|
39
|
+
export declare const compose: (...fns: AnyFunc[]) => Composed;
|
|
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: (
|
|
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) =>
|
|
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: (
|
|
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: (
|
|
234
|
-
export declare const propsEq: (
|
|
235
|
-
export declare const pathOr: (
|
|
236
|
-
export declare const path: any
|
|
237
|
-
export declare const pathEq: (
|
|
238
|
-
export declare const pathsEq: (
|
|
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: (
|
|
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: (
|
|
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: (
|
|
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) =>
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
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) =>
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
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) =>
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
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: (
|
|
368
|
-
export declare const qreduce: (
|
|
369
|
-
export declare const qmergeDeep:
|
|
370
|
-
export declare const qmergeDeepX:
|
|
371
|
-
export declare const qmergeDeepAdd:
|
|
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: {
|
package/package.json
CHANGED
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
|
-
|
|
49
|
+
<Func extends AnyFunc>(fn: AnyFunc) => (
|
|
50
50
|
(...args: AnyArgs) => fn.length>countArgs(args)
|
|
51
51
|
? _curry(fn, [], args)
|
|
52
52
|
: fn(...args)
|
|
53
|
-
)
|
|
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)
|
|
96
|
+
return curry(fn) as FT.Curry<Func>
|
|
97
97
|
}
|
package/src/safe.ts
CHANGED
|
@@ -44,8 +44,10 @@ export const when = curry3(
|
|
|
44
44
|
s: any
|
|
45
45
|
) => ifElse(cond, pipe, identity, s)
|
|
46
46
|
)
|
|
47
|
-
|
|
48
|
-
|
|
47
|
+
/*: FT.Compose*/
|
|
48
|
+
type Composed = <TIn = any, TOut = any>(x: TIn) => TOut
|
|
49
|
+
export const compose = (
|
|
50
|
+
(...fns: AnyFunc[]): Composed =>
|
|
49
51
|
(s: any = __) => {
|
|
50
52
|
for(let i = length(fns)-1; i>-1; i--) {
|
|
51
53
|
s = s===__ ? fns[i]() : fns[i](s)
|
|
@@ -139,7 +141,7 @@ export const once = <Func extends AnyFunc>(fn: Func) => {
|
|
|
139
141
|
}
|
|
140
142
|
}
|
|
141
143
|
export const reverse = (xs: any[]) => compose(
|
|
142
|
-
<T>(ln: number) => reduce(
|
|
144
|
+
<T>(ln: number) => reduce<any>(
|
|
143
145
|
(nxs: T[], _: any, i: number) => qappend(xs[ln-i], nxs),
|
|
144
146
|
[], xs
|
|
145
147
|
),
|
|
@@ -269,7 +271,7 @@ export const omit = curry2(
|
|
|
269
271
|
o
|
|
270
272
|
)
|
|
271
273
|
)
|
|
272
|
-
export const fromPairs = (pairs: [string, any][]) => reduce(
|
|
274
|
+
export const fromPairs = (pairs: [string, any][]) => reduce<any>(
|
|
273
275
|
(o: AnyObject, pair: [string, any]) => assoc(...pair, o),
|
|
274
276
|
{}, pairs
|
|
275
277
|
)
|
package/src/uncurry.ts
CHANGED