pepka 0.14.0-beta10 → 0.14.0-beta12
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 +23 -40
- package/package.json +10 -8
- package/src/curry.ts +8 -9
- package/src/safe.ts +2 -3
- package/src/uncurry.ts +1 -1
package/dist/bundle.d.ts
CHANGED
|
@@ -9,11 +9,10 @@ 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;
|
|
13
12
|
export type AnyFunc<ReturnT = any, Args extends AnyArgs = AnyArgs> = (...args: Args) => ReturnT;
|
|
14
13
|
export type Placeholder = symbol;
|
|
15
14
|
declare const __: Placeholder;
|
|
16
|
-
export declare const curry:
|
|
15
|
+
export declare const curry: (fn: AnyFunc) => (...args: AnyArgs) => any;
|
|
17
16
|
export type Func2 = (a: any, b: any) => any;
|
|
18
17
|
export declare function curry2<Func extends Func2>(fn: Func): {
|
|
19
18
|
(a: Placeholder, b: Parameters<Func>[1]): (a: Parameters<Func>[0]) => ReturnType<Func>;
|
|
@@ -22,7 +21,7 @@ export declare function curry2<Func extends Func2>(fn: Func): {
|
|
|
22
21
|
(a: Parameters<Func>[0], b: Parameters<Func>[1]): ReturnType<Func>;
|
|
23
22
|
};
|
|
24
23
|
export type Func3 = (a: any, b: any, c: any) => any;
|
|
25
|
-
export declare function curry3<Func extends Func3>(fn: Func):
|
|
24
|
+
export declare function curry3<Func extends Func3>(fn: Func): (...args: AnyArgs) => any;
|
|
26
25
|
export declare const uncurry: <Args extends any[] = any[], ReturnT = any>(fn: Curried<Args, any>) => AnyFunc;
|
|
27
26
|
export declare const toLower: (s: string) => string;
|
|
28
27
|
export declare const toUpper: (s: string) => string;
|
|
@@ -40,8 +39,8 @@ export declare const equals: {
|
|
|
40
39
|
(a: any): (b: any) => boolean;
|
|
41
40
|
(a: any, b: any): boolean;
|
|
42
41
|
};
|
|
43
|
-
export declare const ifElse:
|
|
44
|
-
export declare const when:
|
|
42
|
+
export declare const ifElse: (...args: AnyArgs) => any;
|
|
43
|
+
export declare const when: (...args: AnyArgs) => any;
|
|
45
44
|
export type Composed<TIn extends any[], TOut> = (...xs: TIn) => TOut;
|
|
46
45
|
export declare const compose: <TIn extends any[] = any[], TOut = any>(...fns: AnyFunc[]) => Composed<TIn, TOut>;
|
|
47
46
|
export declare const bind: {
|
|
@@ -62,7 +61,7 @@ export declare const includes: {
|
|
|
62
61
|
(a: unknown): (b: unknown[]) => boolean;
|
|
63
62
|
(a: unknown, b: unknown[]): boolean;
|
|
64
63
|
};
|
|
65
|
-
export declare const slice:
|
|
64
|
+
export declare const slice: (...args: AnyArgs) => any;
|
|
66
65
|
export declare const flip: <T extends AnyFunc<any, AnyArgs>>(fn: T) => {
|
|
67
66
|
(a: symbol, b: Parameters<T>[0]): (a: Parameters<T>[1]) => any;
|
|
68
67
|
(a: Parameters<T>[1], b: symbol): (b: Parameters<T>[0]) => any;
|
|
@@ -70,7 +69,7 @@ export declare const flip: <T extends AnyFunc<any, AnyArgs>>(fn: T) => {
|
|
|
70
69
|
(a: Parameters<T>[1], b: Parameters<T>[0]): any;
|
|
71
70
|
};
|
|
72
71
|
export declare const head: (b: string | unknown[]) => unknown;
|
|
73
|
-
export declare const tail:
|
|
72
|
+
export declare const tail: any;
|
|
74
73
|
export declare const add: {
|
|
75
74
|
(a: symbol, b: number): (a: number) => number;
|
|
76
75
|
(a: number, b: symbol): (b: number) => number;
|
|
@@ -224,9 +223,7 @@ export declare const cond: {
|
|
|
224
223
|
Function
|
|
225
224
|
][], b: any): any;
|
|
226
225
|
};
|
|
227
|
-
export declare const assoc:
|
|
228
|
-
[x: string]: any;
|
|
229
|
-
}>;
|
|
226
|
+
export declare const assoc: (...args: AnyArgs) => any;
|
|
230
227
|
export declare const assocPath: any;
|
|
231
228
|
export declare const all: {
|
|
232
229
|
(a: symbol, b: any[]): (a: Cond) => boolean;
|
|
@@ -258,18 +255,15 @@ export declare const prop: {
|
|
|
258
255
|
(a: string): (b: AnyObject) => any;
|
|
259
256
|
(a: string, b: AnyObject): any;
|
|
260
257
|
};
|
|
261
|
-
export declare const propEq:
|
|
262
|
-
export declare const propsEq:
|
|
263
|
-
export declare const pathOr:
|
|
264
|
-
export declare const path:
|
|
265
|
-
export declare const pathEq:
|
|
266
|
-
export declare const pathsEq:
|
|
258
|
+
export declare const propEq: (...args: AnyArgs) => any;
|
|
259
|
+
export declare const propsEq: (...args: AnyArgs) => any;
|
|
260
|
+
export declare const pathOr: (...args: AnyArgs) => any;
|
|
261
|
+
export declare const path: any;
|
|
262
|
+
export declare const pathEq: (...args: AnyArgs) => any;
|
|
263
|
+
export declare const pathsEq: (...args: AnyArgs) => any;
|
|
267
264
|
export declare const clone: (s: any, shallow?: boolean) => any;
|
|
268
265
|
export declare const cloneShallow: (s: any) => any;
|
|
269
|
-
export declare const reduce:
|
|
270
|
-
] | [
|
|
271
|
-
accum: any
|
|
272
|
-
]) => any>)>;
|
|
266
|
+
export declare const reduce: (...args: AnyArgs) => any;
|
|
273
267
|
export declare const pickBy: {
|
|
274
268
|
(a: symbol, b: AnyObject): (a: Cond) => any;
|
|
275
269
|
(a: Cond, b: symbol): (b: AnyObject) => any;
|
|
@@ -291,10 +285,7 @@ export declare const omit: {
|
|
|
291
285
|
export declare const fromPairs: (pairs: [
|
|
292
286
|
string,
|
|
293
287
|
any
|
|
294
|
-
][]) =>
|
|
295
|
-
] | [
|
|
296
|
-
accum: any
|
|
297
|
-
]) => any>>;
|
|
288
|
+
][]) => any;
|
|
298
289
|
export declare const concat: {
|
|
299
290
|
(a: symbol, b: string | any[]): (a: string | any[]) => string | any[];
|
|
300
291
|
(a: string | any[], b: symbol): (b: string | any[]) => string | any[];
|
|
@@ -319,10 +310,10 @@ export declare const forEach: {
|
|
|
319
310
|
(a: (s: any) => any): (b: any[]) => void;
|
|
320
311
|
(a: (s: any) => any, b: any[]): void;
|
|
321
312
|
};
|
|
322
|
-
export declare const both:
|
|
313
|
+
export declare const both: (...args: AnyArgs) => any;
|
|
323
314
|
export declare const isEmpty: (s: any) => boolean | null;
|
|
324
315
|
export declare const empty: (s: any) => {} | undefined;
|
|
325
|
-
export declare const replace:
|
|
316
|
+
export declare const replace: (...args: AnyArgs) => any;
|
|
326
317
|
export declare const filter: any;
|
|
327
318
|
export declare const memoize: (fn: Function) => () => any;
|
|
328
319
|
export declare const mergeShallow: {
|
|
@@ -349,15 +340,7 @@ export declare const mergeDeepAdd: {
|
|
|
349
340
|
(a: AnyObject): (b: AnyObject) => AnyObject;
|
|
350
341
|
(a: AnyObject, b: AnyObject): AnyObject;
|
|
351
342
|
};
|
|
352
|
-
export declare const overProp:
|
|
353
|
-
] | [
|
|
354
|
-
v: any,
|
|
355
|
-
obj: AnyObject
|
|
356
|
-
] | [
|
|
357
|
-
obj: AnyObject
|
|
358
|
-
] | [
|
|
359
|
-
v: any
|
|
360
|
-
]) => any>>;
|
|
343
|
+
export declare const overProp: (...args: AnyArgs) => any;
|
|
361
344
|
/** mapKeys({ a: 'b' }, { a: 44 }) -> { b: 44 } */
|
|
362
345
|
export declare const mapKeys: {
|
|
363
346
|
(a: symbol, b: AnyObject): (a: {
|
|
@@ -406,11 +389,11 @@ export declare const qappend: {
|
|
|
406
389
|
(a: any): (b: any[]) => any[];
|
|
407
390
|
(a: any, b: any[]): any[];
|
|
408
391
|
};
|
|
409
|
-
export declare const qassoc:
|
|
410
|
-
export declare const qreduce:
|
|
411
|
-
export declare const qmergeDeep:
|
|
412
|
-
export declare const qmergeDeepX:
|
|
413
|
-
export declare const qmergeDeepAdd:
|
|
392
|
+
export declare const qassoc: (...args: AnyArgs) => any;
|
|
393
|
+
export declare const qreduce: (...args: AnyArgs) => any;
|
|
394
|
+
export declare const qmergeDeep: any;
|
|
395
|
+
export declare const qmergeDeepX: any;
|
|
396
|
+
export declare const qmergeDeepAdd: any;
|
|
414
397
|
/** qmapKeys({ a: 'b' }, { a: 44 }) -> { b: 44 } */
|
|
415
398
|
export declare const qmapKeys: {
|
|
416
399
|
(a: symbol, b: AnyObject): (a: {
|
package/package.json
CHANGED
|
@@ -5,7 +5,6 @@
|
|
|
5
5
|
"bugs": {
|
|
6
6
|
"url": "https://github.com/houd1ni/pepka/issues"
|
|
7
7
|
},
|
|
8
|
-
"bundleDependencies": [],
|
|
9
8
|
"deprecated": false,
|
|
10
9
|
"description": "An ultra lightweight or unsafe-speedy ramda alternative.",
|
|
11
10
|
"homepage": "https://houd1ni.github.io/pepka/",
|
|
@@ -44,16 +43,19 @@
|
|
|
44
43
|
"prod": "npm run gentypes && npm run prod:es && npm run prod:cjs",
|
|
45
44
|
"all": "npm run dev && npm run prod"
|
|
46
45
|
},
|
|
47
|
-
"version": "0.14.0-
|
|
46
|
+
"version": "0.14.0-beta12",
|
|
48
47
|
"ava": {
|
|
49
|
-
"files": [
|
|
48
|
+
"files": [
|
|
49
|
+
"./test/specs/*.ts"
|
|
50
|
+
],
|
|
50
51
|
"failFast": true,
|
|
51
52
|
"timeout": "2m",
|
|
52
|
-
"extensions": [
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
53
|
+
"extensions": [
|
|
54
|
+
"ts"
|
|
55
|
+
],
|
|
56
|
+
"require": [
|
|
57
|
+
"ts-node/register"
|
|
58
|
+
]
|
|
57
59
|
},
|
|
58
60
|
"devDependencies": {
|
|
59
61
|
"@rollup/plugin-commonjs": "^23.0.3",
|
package/src/curry.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { A, F as FT } from 'ts-toolbelt'
|
|
2
1
|
import { AnyFunc, AnyArgs } from "./types"
|
|
3
2
|
|
|
4
3
|
type Placeholder = symbol
|
|
@@ -45,14 +44,12 @@ const _curry = (fn: Function, args: AnyArgs, new_args: AnyArgs) => {
|
|
|
45
44
|
}
|
|
46
45
|
}
|
|
47
46
|
|
|
48
|
-
export const curry = (
|
|
49
|
-
|
|
50
|
-
(
|
|
51
|
-
|
|
52
|
-
: fn(...args)
|
|
53
|
-
) as FT.Curry<Func>
|
|
47
|
+
export const curry = (fn: AnyFunc) => (
|
|
48
|
+
(...args: AnyArgs) => fn.length>countArgs(args)
|
|
49
|
+
? _curry(fn, [], args)
|
|
50
|
+
: fn(...args)
|
|
54
51
|
)
|
|
55
|
-
const endlessph = <Func extends
|
|
52
|
+
const endlessph = <Func extends AnyFunc>(fn: Func) => {
|
|
56
53
|
type ReturnT = ReturnType<Func>
|
|
57
54
|
type p0 = Parameters<Func>[0]
|
|
58
55
|
function _endlessph(a: p0): ReturnT
|
|
@@ -93,5 +90,7 @@ export function curry3<Func extends Func3>(fn: Func) {
|
|
|
93
90
|
// type p2 = Parameters<Func>[2]
|
|
94
91
|
// type ReturnT = ReturnType<Func>
|
|
95
92
|
// TODO: optimize.
|
|
96
|
-
|
|
93
|
+
// Cannot use ts-toolbelt due to this error:
|
|
94
|
+
// Excessive stack depth comparing types 'GapsOf<?, L2>' and 'GapsOf<?, L2>'
|
|
95
|
+
return curry(fn)
|
|
97
96
|
}
|
package/src/safe.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { F as FT } from 'ts-toolbelt'
|
|
2
1
|
import { __, curry, curry2, curry3 } from './curry'
|
|
3
2
|
import { isNum, isUndef, undef, isNull, isArray, isFunc, isStr, isObj, inf } from './utils'
|
|
4
3
|
import { qmergeDeep, qreduce, qappend, qmapKeys, qmergeDeepX, qmergeDeepAdd } from './quick'
|
|
@@ -152,7 +151,7 @@ export const once = <Func extends AnyFunc>(fn: Func) => {
|
|
|
152
151
|
}
|
|
153
152
|
}
|
|
154
153
|
export const reverse = (xs: any[]) => compose(
|
|
155
|
-
<T>(ln: number) => reduce
|
|
154
|
+
<T>(ln: number) => reduce(
|
|
156
155
|
(nxs: T[], _: any, i: number) => qappend(xs[ln-i], nxs),
|
|
157
156
|
[], xs
|
|
158
157
|
),
|
|
@@ -282,7 +281,7 @@ export const omit = curry2(
|
|
|
282
281
|
o
|
|
283
282
|
)
|
|
284
283
|
)
|
|
285
|
-
export const fromPairs = (pairs: [string, any][]) => reduce
|
|
284
|
+
export const fromPairs = (pairs: [string, any][]) => reduce(
|
|
286
285
|
(o: AnyObject, pair: [string, any]) => assoc(...pair, o),
|
|
287
286
|
{}, pairs
|
|
288
287
|
)
|
package/src/uncurry.ts
CHANGED