pepka 0.13.0-b1 → 0.13.0-b3
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 +477 -85
- package/dist/bundle.dev.js +5 -7
- package/dist/bundle.js +1 -1
- package/dist/es/curry.js +29 -1
- package/dist/es/index.js +2 -0
- package/dist/es/quick.js +8 -8
- package/dist/es/safe.js +69 -65
- package/dist/es/uncurry.js +3 -0
- package/dist/es/utils.js +1 -0
- package/dts-fix.js +11 -0
- package/package.json +7 -3
- package/src/curry.ts +9 -11
- package/src/index.ts +2 -1
- package/src/quick.ts +2 -2
- package/src/safe.ts +12 -12
- package/src/types.ts +1 -1
- package/src/uncurry.ts +1 -1
- package/src/utils.ts +1 -0
package/dist/bundle.d.ts
CHANGED
|
@@ -1,28 +1,75 @@
|
|
|
1
|
-
|
|
1
|
+
import {F as FT} from 'ts-toolbelt'
|
|
2
|
+
export { __ }
|
|
2
3
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
export
|
|
6
|
-
export declare const toLower: (s: string) => string;
|
|
7
|
-
export declare const toUpper: (s: string) => string;
|
|
8
|
-
export declare const type: (s: any) => any;
|
|
4
|
+
// Generated by dts-bundle-generator v7.1.0
|
|
5
|
+
|
|
6
|
+
export type Cond = (...xs: any[]) => boolean;
|
|
9
7
|
export interface AnyObject {
|
|
10
8
|
[k: string]: any;
|
|
11
9
|
}
|
|
12
|
-
export
|
|
13
|
-
export
|
|
14
|
-
export
|
|
15
|
-
export
|
|
16
|
-
export
|
|
17
|
-
|
|
18
|
-
export declare const
|
|
19
|
-
export
|
|
20
|
-
export declare
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
10
|
+
export type AnyArgs = any[];
|
|
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
|
+
export type AnyFunc<ReturnT = any, Args extends AnyArgs = AnyArgs> = (...args: Args) => ReturnT;
|
|
14
|
+
export type Placeholder = symbol;
|
|
15
|
+
declare const __: Placeholder;
|
|
16
|
+
export declare const curry: <Func extends AnyFunc<any, AnyArgs>>(fn: AnyFunc) => FT.Curry<Func>;
|
|
17
|
+
export type Func2 = (a: any, b: any) => any;
|
|
18
|
+
export declare function curry2<Func extends Func2>(fn: Func): {
|
|
19
|
+
(a: Parameters<Func>[0]): (b: Parameters<Func>[1]) => ReturnType<Func>;
|
|
20
|
+
(a: Parameters<Func>[0], b: Parameters<Func>[1]): ReturnType<Func>;
|
|
21
|
+
(a: Placeholder, b: Parameters<Func>[1]): (a: Parameters<Func>[0]) => ReturnType<Func>;
|
|
22
|
+
(a: Parameters<Func>[0], b: Placeholder): (b: Parameters<Func>[1]) => ReturnType<Func>;
|
|
23
|
+
};
|
|
24
|
+
export type Func3 = (a: any, b: any, c: any) => any;
|
|
25
|
+
export declare function curry3<Func extends Func3>(fn: Func): FT.Curry<Func>;
|
|
26
|
+
export declare const uncurry: <Args extends any[] = any[], ReturnT = any>(fn: Curried<Args, any>) => AnyFunc;
|
|
27
|
+
export declare const toLower: (s: string) => string;
|
|
28
|
+
export declare const toUpper: (s: string) => string;
|
|
29
|
+
export declare const type: (s: any) => any;
|
|
30
|
+
export declare const equals: {
|
|
31
|
+
(a: any): (b: any) => boolean;
|
|
32
|
+
(a: any, b: any): boolean;
|
|
33
|
+
(a: symbol, b: any): (a: any) => boolean;
|
|
34
|
+
(a: any, b: symbol): (b: any) => boolean;
|
|
35
|
+
};
|
|
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 declare const compose: FT.Compose;
|
|
39
|
+
export declare const bind: {
|
|
40
|
+
(a: any): (b: any) => any;
|
|
41
|
+
(a: any, b: any): any;
|
|
42
|
+
(a: symbol, b: any): (a: any) => any;
|
|
43
|
+
(a: any, b: symbol): (b: any) => any;
|
|
44
|
+
};
|
|
45
|
+
export declare const nth: {
|
|
46
|
+
(a: number): (b: unknown[]) => unknown;
|
|
47
|
+
(a: number, b: unknown[]): unknown;
|
|
48
|
+
(a: symbol, b: unknown[]): (a: number) => unknown;
|
|
49
|
+
(a: number, b: symbol): (b: unknown[]) => unknown;
|
|
50
|
+
};
|
|
51
|
+
export declare const includes: {
|
|
52
|
+
(a: unknown): (b: unknown[]) => boolean;
|
|
53
|
+
(a: unknown, b: unknown[]): boolean;
|
|
54
|
+
(a: symbol, b: unknown[]): (a: unknown) => boolean;
|
|
55
|
+
(a: unknown, b: symbol): (b: unknown[]) => boolean;
|
|
56
|
+
};
|
|
57
|
+
export declare const slice: FT.Curry<(from: number, to: number, o: any[] | string) => string | any[]>;
|
|
58
|
+
export declare const head: (b: unknown[]) => unknown;
|
|
59
|
+
export declare const tail: FT.Curry<(o: string | any[]) => string | any[]>;
|
|
60
|
+
export declare const add: {
|
|
61
|
+
(a: number): (b: number) => number;
|
|
62
|
+
(a: number, b: number): number;
|
|
63
|
+
(a: symbol, b: number): (a: number) => number;
|
|
64
|
+
(a: number, b: symbol): (b: number) => number;
|
|
65
|
+
};
|
|
66
|
+
export declare const subtract: {
|
|
67
|
+
(a: number): (b: number) => number;
|
|
68
|
+
(a: number, b: number): number;
|
|
69
|
+
(a: symbol, b: number): (a: number) => number;
|
|
70
|
+
(a: number, b: symbol): (b: number) => number;
|
|
71
|
+
};
|
|
72
|
+
export declare const flip: (fn: Function) => FT.Curry<AnyFunc<any, AnyArgs>>;
|
|
26
73
|
export declare const isNil: (s: any) => boolean;
|
|
27
74
|
export declare const length: (s: any[] | string) => number;
|
|
28
75
|
export declare const always: <T = any>(s: T) => () => T;
|
|
@@ -37,91 +84,436 @@ export declare const toPairs: (o: AnyObject | any[]) => [
|
|
|
37
84
|
string,
|
|
38
85
|
any
|
|
39
86
|
][];
|
|
40
|
-
export declare const test:
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
87
|
+
export declare const test: {
|
|
88
|
+
(a: RegExp): (b: string) => boolean;
|
|
89
|
+
(a: RegExp, b: string): boolean;
|
|
90
|
+
(a: symbol, b: string): (a: RegExp) => boolean;
|
|
91
|
+
(a: RegExp, b: symbol): (b: string) => boolean;
|
|
92
|
+
};
|
|
93
|
+
export declare const tap: {
|
|
94
|
+
(a: Function): (b: any) => any;
|
|
95
|
+
(a: Function, b: any): any;
|
|
96
|
+
(a: symbol, b: any): (a: Function) => any;
|
|
97
|
+
(a: Function, b: symbol): (b: any) => any;
|
|
98
|
+
};
|
|
99
|
+
export declare const append: {
|
|
100
|
+
(a: any): (b: any[]) => any[];
|
|
101
|
+
(a: any, b: any[]): any[];
|
|
102
|
+
(a: symbol, b: any[]): (a: any) => any[];
|
|
103
|
+
(a: any, b: symbol): (b: any[]) => any[];
|
|
104
|
+
};
|
|
105
|
+
export declare const split: {
|
|
106
|
+
(a: string): (b: string) => string[];
|
|
107
|
+
(a: string, b: string): string[];
|
|
108
|
+
(a: symbol, b: string): (a: string) => string[];
|
|
109
|
+
(a: string, b: symbol): (b: string) => string[];
|
|
110
|
+
};
|
|
44
111
|
export declare const T: (...args: any[]) => true;
|
|
45
112
|
export declare const F: (...args: any[]) => false;
|
|
46
113
|
export declare const sizeof: (s: any[] | string | AnyObject) => number;
|
|
47
|
-
export declare const range:
|
|
114
|
+
export declare const range: {
|
|
115
|
+
(a: number): (b: number) => any[];
|
|
116
|
+
(a: number, b: number): any[];
|
|
117
|
+
(a: symbol, b: number): (a: number) => any[];
|
|
118
|
+
(a: number, b: symbol): (b: number) => any[];
|
|
119
|
+
};
|
|
48
120
|
export declare const uniq: (xs: any[]) => any;
|
|
49
|
-
export declare const intersection:
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
export declare const
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
export declare const
|
|
62
|
-
export declare const
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
export declare const
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
export declare const
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
export declare const
|
|
79
|
-
|
|
80
|
-
|
|
121
|
+
export declare const intersection: {
|
|
122
|
+
(a: any[]): (b: any[]) => any[];
|
|
123
|
+
(a: any[], b: any[]): any[];
|
|
124
|
+
(a: symbol, b: any[]): (a: any[]) => any[];
|
|
125
|
+
(a: any[], b: symbol): (b: any[]) => any[];
|
|
126
|
+
};
|
|
127
|
+
export declare const genBy: {
|
|
128
|
+
(a: (i: number) => any): (b: number) => any[];
|
|
129
|
+
(a: (i: number) => any, b: number): any[];
|
|
130
|
+
(a: symbol, b: number): (a: (i: number) => any) => any[];
|
|
131
|
+
(a: (i: number) => any, b: symbol): (b: number) => any[];
|
|
132
|
+
};
|
|
133
|
+
export declare const once: <Func extends AnyFunc<any, AnyArgs>>(fn: Func) => (...args: Parameters<Func>) => any;
|
|
134
|
+
export declare const reverse: (xs: any[]) => FT.Curry<(fn: Reducer, accum: any, arr: any[]) => FT.Curry<(...p: [
|
|
135
|
+
] | [
|
|
136
|
+
accum: any
|
|
137
|
+
]) => any>>;
|
|
138
|
+
export declare const gt: {
|
|
139
|
+
(a: number): (b: number) => boolean;
|
|
140
|
+
(a: number, b: number): boolean;
|
|
141
|
+
(a: symbol, b: number): (a: number) => boolean;
|
|
142
|
+
(a: number, b: symbol): (b: number) => boolean;
|
|
143
|
+
};
|
|
144
|
+
export declare const lt: {
|
|
145
|
+
(a: number): (b: number) => boolean;
|
|
146
|
+
(a: number, b: number): boolean;
|
|
147
|
+
(a: symbol, b: number): (a: number) => boolean;
|
|
148
|
+
(a: number, b: symbol): (b: number) => boolean;
|
|
149
|
+
};
|
|
150
|
+
export declare const gte: {
|
|
151
|
+
(a: number): (b: number) => boolean;
|
|
152
|
+
(a: number, b: number): boolean;
|
|
153
|
+
(a: symbol, b: number): (a: number) => boolean;
|
|
154
|
+
(a: number, b: symbol): (b: number) => boolean;
|
|
155
|
+
};
|
|
156
|
+
export declare const lte: {
|
|
157
|
+
(a: number): (b: number) => boolean;
|
|
158
|
+
(a: number, b: number): boolean;
|
|
159
|
+
(a: symbol, b: number): (a: number) => boolean;
|
|
160
|
+
(a: number, b: symbol): (b: number) => boolean;
|
|
161
|
+
};
|
|
162
|
+
export declare const sort: {
|
|
163
|
+
(a: any): (b: any[]) => any[];
|
|
164
|
+
(a: any, b: any[]): any[];
|
|
165
|
+
(a: symbol, b: any[]): (a: any) => any[];
|
|
166
|
+
(a: any, b: symbol): (b: any[]) => any[];
|
|
167
|
+
};
|
|
168
|
+
export declare const find: {
|
|
169
|
+
(a: Cond): (b: any[]) => any;
|
|
170
|
+
(a: Cond, b: any[]): any;
|
|
171
|
+
(a: symbol, b: any[]): (a: Cond) => any;
|
|
172
|
+
(a: Cond, b: symbol): (b: any[]) => any;
|
|
173
|
+
};
|
|
174
|
+
export declare const findIndex: {
|
|
175
|
+
(a: Cond): (b: any[]) => number;
|
|
176
|
+
(a: Cond, b: any[]): number;
|
|
177
|
+
(a: symbol, b: any[]): (a: Cond) => number;
|
|
178
|
+
(a: Cond, b: symbol): (b: any[]) => number;
|
|
179
|
+
};
|
|
180
|
+
export declare const indexOf: {
|
|
181
|
+
(a: any): (b: any[]) => number;
|
|
182
|
+
(a: any, b: any[]): number;
|
|
183
|
+
(a: symbol, b: any[]): (a: any) => number;
|
|
184
|
+
(a: any, b: symbol): (b: any[]) => number;
|
|
185
|
+
};
|
|
186
|
+
export declare const explore: (caption: string, level?: string) => (b: any) => any;
|
|
187
|
+
export declare const cond: {
|
|
188
|
+
(a: [
|
|
189
|
+
Cond,
|
|
190
|
+
Function
|
|
191
|
+
][]): (b: any) => any;
|
|
192
|
+
(a: [
|
|
193
|
+
Cond,
|
|
194
|
+
Function
|
|
195
|
+
][], b: any): any;
|
|
196
|
+
(a: symbol, b: any): (a: [
|
|
197
|
+
Cond,
|
|
198
|
+
Function
|
|
199
|
+
][]) => any;
|
|
200
|
+
(a: [
|
|
201
|
+
Cond,
|
|
202
|
+
Function
|
|
203
|
+
][], b: symbol): (b: any) => any;
|
|
204
|
+
};
|
|
205
|
+
export declare const assoc: FT.Curry<(prop: string, v: any, obj: AnyObject) => {
|
|
206
|
+
[x: string]: any;
|
|
207
|
+
}>;
|
|
208
|
+
export declare const assocPath: any;
|
|
209
|
+
export declare const all: {
|
|
210
|
+
(a: Cond): (b: any[]) => boolean;
|
|
211
|
+
(a: Cond, b: any[]): boolean;
|
|
212
|
+
(a: symbol, b: any[]): (a: Cond) => boolean;
|
|
213
|
+
(a: Cond, b: symbol): (b: any[]) => boolean;
|
|
214
|
+
};
|
|
215
|
+
export declare const any: {
|
|
216
|
+
(a: Cond): (b: any[]) => boolean;
|
|
217
|
+
(a: Cond, b: any[]): boolean;
|
|
218
|
+
(a: symbol, b: any[]): (a: Cond) => boolean;
|
|
219
|
+
(a: Cond, b: symbol): (b: any[]) => boolean;
|
|
220
|
+
};
|
|
221
|
+
export declare const allPass: {
|
|
222
|
+
(a: Cond[]): (b: any) => boolean;
|
|
223
|
+
(a: Cond[], b: any): boolean;
|
|
224
|
+
(a: symbol, b: any): (a: Cond[]) => boolean;
|
|
225
|
+
(a: Cond[], b: symbol): (b: any) => boolean;
|
|
226
|
+
};
|
|
227
|
+
export declare const anyPass: {
|
|
228
|
+
(a: Cond[]): (b: any) => boolean;
|
|
229
|
+
(a: Cond[], b: any): boolean;
|
|
230
|
+
(a: symbol, b: any): (a: Cond[]) => boolean;
|
|
231
|
+
(a: Cond[], b: symbol): (b: any) => boolean;
|
|
232
|
+
};
|
|
233
|
+
export declare const prop: {
|
|
234
|
+
(a: string): (b: AnyObject) => any;
|
|
235
|
+
(a: string, b: AnyObject): any;
|
|
236
|
+
(a: symbol, b: AnyObject): (a: string) => any;
|
|
237
|
+
(a: string, b: symbol): (b: AnyObject) => any;
|
|
238
|
+
};
|
|
239
|
+
export declare const propEq: FT.Curry<(key: string, value: any, o: AnyObject) => boolean>;
|
|
240
|
+
export declare const propsEq: FT.Curry<(key: string, o1: any, o2: AnyObject) => boolean>;
|
|
241
|
+
export declare const pathOr: FT.Curry<(_default: any, path: string[], o: any) => any>;
|
|
242
|
+
export declare const path: FT.Curry<(path: string[], o: any) => any>;
|
|
243
|
+
export declare const pathEq: FT.Curry<(_path: string[], value: any, o: AnyObject) => boolean>;
|
|
244
|
+
export declare const pathsEq: FT.Curry<(_path: string[], o1: AnyObject, o2: AnyObject) => boolean>;
|
|
245
|
+
export declare const clone: (s: any, shallow?: boolean) => any;
|
|
246
|
+
export declare const cloneShallow: (s: any) => any;
|
|
247
|
+
export declare const reduce: FT.Curry<(fn: Reducer, accum: any, arr: any[]) => FT.Curry<(...p: [
|
|
248
|
+
] | [
|
|
249
|
+
accum: any
|
|
250
|
+
]) => any>>;
|
|
251
|
+
export declare const pickBy: {
|
|
252
|
+
(a: Cond): (b: AnyObject) => any;
|
|
253
|
+
(a: Cond, b: AnyObject): any;
|
|
254
|
+
(a: symbol, b: AnyObject): (a: Cond) => any;
|
|
255
|
+
(a: Cond, b: symbol): (b: AnyObject) => any;
|
|
256
|
+
};
|
|
257
|
+
export declare const pick: {
|
|
258
|
+
(a: string[]): (b: AnyObject) => {};
|
|
259
|
+
(a: string[], b: AnyObject): {};
|
|
260
|
+
(a: symbol, b: AnyObject): (a: string[]) => {};
|
|
261
|
+
(a: string[], b: symbol): (b: AnyObject) => {};
|
|
262
|
+
};
|
|
263
|
+
export declare const omit: {
|
|
264
|
+
(a: string[]): (b: AnyObject) => any;
|
|
265
|
+
(a: string[], b: AnyObject): any;
|
|
266
|
+
(a: symbol, b: AnyObject): (a: string[]) => any;
|
|
267
|
+
(a: string[], b: symbol): (b: AnyObject) => any;
|
|
268
|
+
};
|
|
81
269
|
export declare const fromPairs: (pairs: [
|
|
82
270
|
string,
|
|
83
271
|
any
|
|
84
|
-
][]) => any
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
export declare const
|
|
89
|
-
|
|
272
|
+
][]) => FT.Curry<(fn: Reducer, accum: any, arr: any[]) => FT.Curry<(...p: [
|
|
273
|
+
] | [
|
|
274
|
+
accum: any
|
|
275
|
+
]) => any>>;
|
|
276
|
+
export declare const concat: {
|
|
277
|
+
(a: string | any[]): (b: string | any[]) => string | any[];
|
|
278
|
+
(a: string | any[], b: string | any[]): string | any[];
|
|
279
|
+
(a: symbol, b: string | any[]): (a: string | any[]) => string | any[];
|
|
280
|
+
(a: string | any[], b: symbol): (b: string | any[]) => string | any[];
|
|
281
|
+
};
|
|
282
|
+
export declare const join: {
|
|
283
|
+
(a: string): (b: string[]) => string;
|
|
284
|
+
(a: string, b: string[]): string;
|
|
285
|
+
(a: symbol, b: string[]): (a: string) => string;
|
|
286
|
+
(a: string, b: symbol): (b: string[]) => string;
|
|
287
|
+
};
|
|
288
|
+
export declare const map: {
|
|
289
|
+
(a: (s: any) => any): (b: any[]) => any[];
|
|
290
|
+
(a: (s: any) => any, b: any[]): any[];
|
|
291
|
+
(a: symbol, b: any[]): (a: (s: any) => any) => any[];
|
|
292
|
+
(a: (s: any) => any, b: symbol): (b: any[]) => any[];
|
|
293
|
+
};
|
|
294
|
+
export declare const forEach: {
|
|
295
|
+
(a: (s: any) => any): (b: any[]) => void;
|
|
296
|
+
(a: (s: any) => any, b: any[]): void;
|
|
297
|
+
(a: symbol, b: any[]): (a: (s: any) => any) => void;
|
|
298
|
+
(a: (s: any) => any, b: symbol): (b: any[]) => void;
|
|
299
|
+
};
|
|
300
|
+
export declare const both: FT.Curry<(cond1: Cond, cond2: Cond, s: any) => boolean>;
|
|
90
301
|
export declare const isEmpty: (s: any) => boolean | null;
|
|
91
302
|
export declare const empty: (s: any) => {} | undefined;
|
|
92
|
-
export declare const replace: (
|
|
93
|
-
export declare const filter:
|
|
303
|
+
export declare const replace: FT.Curry<(a: string | RegExp, b: string, where: string) => string>;
|
|
304
|
+
export declare const filter: any;
|
|
94
305
|
export declare const memoize: (fn: Function) => () => any;
|
|
95
|
-
export declare const mergeShallow:
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
306
|
+
export declare const mergeShallow: {
|
|
307
|
+
(a: AnyObject): (b: AnyObject) => AnyObject;
|
|
308
|
+
(a: AnyObject, b: AnyObject): AnyObject;
|
|
309
|
+
(a: symbol, b: AnyObject): (a: AnyObject) => AnyObject;
|
|
310
|
+
(a: AnyObject, b: symbol): (b: AnyObject) => AnyObject;
|
|
311
|
+
};
|
|
312
|
+
export declare const mergeDeep: {
|
|
313
|
+
(a: AnyObject): (b: AnyObject) => FT.Curry<(...p: [
|
|
314
|
+
] | [
|
|
315
|
+
o1: AnyObject,
|
|
316
|
+
o2: AnyObject
|
|
317
|
+
] | [
|
|
318
|
+
o2: AnyObject
|
|
319
|
+
] | [
|
|
320
|
+
o1: AnyObject
|
|
321
|
+
]) => any>;
|
|
322
|
+
(a: AnyObject, b: AnyObject): FT.Curry<(...p: [
|
|
323
|
+
] | [
|
|
324
|
+
o1: AnyObject,
|
|
325
|
+
o2: AnyObject
|
|
326
|
+
] | [
|
|
327
|
+
o2: AnyObject
|
|
328
|
+
] | [
|
|
329
|
+
o1: AnyObject
|
|
330
|
+
]) => any>;
|
|
331
|
+
(a: symbol, b: AnyObject): (a: AnyObject) => FT.Curry<(...p: [
|
|
332
|
+
] | [
|
|
333
|
+
o1: AnyObject,
|
|
334
|
+
o2: AnyObject
|
|
335
|
+
] | [
|
|
336
|
+
o2: AnyObject
|
|
337
|
+
] | [
|
|
338
|
+
o1: AnyObject
|
|
339
|
+
]) => any>;
|
|
340
|
+
(a: AnyObject, b: symbol): (b: AnyObject) => FT.Curry<(...p: [
|
|
341
|
+
] | [
|
|
342
|
+
o1: AnyObject,
|
|
343
|
+
o2: AnyObject
|
|
344
|
+
] | [
|
|
345
|
+
o2: AnyObject
|
|
346
|
+
] | [
|
|
347
|
+
o1: AnyObject
|
|
348
|
+
]) => any>;
|
|
349
|
+
};
|
|
350
|
+
export declare const mergeDeepX: {
|
|
351
|
+
(a: AnyObject): (b: AnyObject) => FT.Curry<(...p: [
|
|
352
|
+
] | [
|
|
353
|
+
o1: AnyObject,
|
|
354
|
+
o2: AnyObject
|
|
355
|
+
] | [
|
|
356
|
+
o2: AnyObject
|
|
357
|
+
] | [
|
|
358
|
+
o1: AnyObject
|
|
359
|
+
]) => any>;
|
|
360
|
+
(a: AnyObject, b: AnyObject): FT.Curry<(...p: [
|
|
361
|
+
] | [
|
|
362
|
+
o1: AnyObject,
|
|
363
|
+
o2: AnyObject
|
|
364
|
+
] | [
|
|
365
|
+
o2: AnyObject
|
|
366
|
+
] | [
|
|
367
|
+
o1: AnyObject
|
|
368
|
+
]) => any>;
|
|
369
|
+
(a: symbol, b: AnyObject): (a: AnyObject) => FT.Curry<(...p: [
|
|
370
|
+
] | [
|
|
371
|
+
o1: AnyObject,
|
|
372
|
+
o2: AnyObject
|
|
373
|
+
] | [
|
|
374
|
+
o2: AnyObject
|
|
375
|
+
] | [
|
|
376
|
+
o1: AnyObject
|
|
377
|
+
]) => any>;
|
|
378
|
+
(a: AnyObject, b: symbol): (b: AnyObject) => FT.Curry<(...p: [
|
|
379
|
+
] | [
|
|
380
|
+
o1: AnyObject,
|
|
381
|
+
o2: AnyObject
|
|
382
|
+
] | [
|
|
383
|
+
o2: AnyObject
|
|
384
|
+
] | [
|
|
385
|
+
o1: AnyObject
|
|
386
|
+
]) => any>;
|
|
387
|
+
};
|
|
388
|
+
export declare const mergeDeepAdd: {
|
|
389
|
+
(a: AnyObject): (b: AnyObject) => FT.Curry<(...p: [
|
|
390
|
+
] | [
|
|
391
|
+
o1: AnyObject,
|
|
392
|
+
o2: AnyObject
|
|
393
|
+
] | [
|
|
394
|
+
o2: AnyObject
|
|
395
|
+
] | [
|
|
396
|
+
o1: AnyObject
|
|
397
|
+
]) => any>;
|
|
398
|
+
(a: AnyObject, b: AnyObject): FT.Curry<(...p: [
|
|
399
|
+
] | [
|
|
400
|
+
o1: AnyObject,
|
|
401
|
+
o2: AnyObject
|
|
402
|
+
] | [
|
|
403
|
+
o2: AnyObject
|
|
404
|
+
] | [
|
|
405
|
+
o1: AnyObject
|
|
406
|
+
]) => any>;
|
|
407
|
+
(a: symbol, b: AnyObject): (a: AnyObject) => FT.Curry<(...p: [
|
|
408
|
+
] | [
|
|
409
|
+
o1: AnyObject,
|
|
410
|
+
o2: AnyObject
|
|
411
|
+
] | [
|
|
412
|
+
o2: AnyObject
|
|
413
|
+
] | [
|
|
414
|
+
o1: AnyObject
|
|
415
|
+
]) => any>;
|
|
416
|
+
(a: AnyObject, b: symbol): (b: AnyObject) => FT.Curry<(...p: [
|
|
417
|
+
] | [
|
|
418
|
+
o1: AnyObject,
|
|
419
|
+
o2: AnyObject
|
|
420
|
+
] | [
|
|
421
|
+
o2: AnyObject
|
|
422
|
+
] | [
|
|
423
|
+
o1: AnyObject
|
|
424
|
+
]) => any>;
|
|
425
|
+
};
|
|
426
|
+
export declare const overProp: FT.Curry<(prop: string, pipe: AnyFunc, data: any) => FT.Curry<(...p: [
|
|
427
|
+
] | [
|
|
428
|
+
v: any,
|
|
429
|
+
obj: AnyObject
|
|
430
|
+
] | [
|
|
431
|
+
obj: AnyObject
|
|
432
|
+
] | [
|
|
433
|
+
v: any
|
|
434
|
+
]) => any>>;
|
|
100
435
|
/** mapKeys({ a: 'b' }, { a: 44 }) -> { b: 44 } */
|
|
101
|
-
export declare const mapKeys:
|
|
436
|
+
export declare const mapKeys: {
|
|
437
|
+
(a: {
|
|
438
|
+
[oldKey: string]: string;
|
|
439
|
+
}): (b: AnyObject) => AnyObject;
|
|
440
|
+
(a: {
|
|
441
|
+
[oldKey: string]: string;
|
|
442
|
+
}, b: AnyObject): AnyObject;
|
|
443
|
+
(a: symbol, b: AnyObject): (a: {
|
|
444
|
+
[oldKey: string]: string;
|
|
445
|
+
}) => AnyObject;
|
|
446
|
+
(a: {
|
|
447
|
+
[oldKey: string]: string;
|
|
448
|
+
}, b: symbol): (b: AnyObject) => AnyObject;
|
|
449
|
+
};
|
|
102
450
|
/** One promise waits for another. */
|
|
103
|
-
export declare const forEachSerial:
|
|
451
|
+
export declare const forEachSerial: {
|
|
452
|
+
(a: AnyFunc<any, AnyArgs>): (b: any[]) => Promise<void>;
|
|
453
|
+
(a: AnyFunc<any, AnyArgs>, b: any[]): Promise<void>;
|
|
454
|
+
(a: symbol, b: any[]): (a: AnyFunc<any, AnyArgs>) => Promise<void>;
|
|
455
|
+
(a: AnyFunc<any, AnyArgs>, b: symbol): (b: any[]) => Promise<void>;
|
|
456
|
+
};
|
|
104
457
|
/** Promise.all wrapper for functional pipelining. */
|
|
105
458
|
export declare const waitAll: (promises: Promise<any>[]) => Promise<any[]>;
|
|
459
|
+
export declare const waitTap: {
|
|
460
|
+
(a: Function): (b: any) => Promise<any>;
|
|
461
|
+
(a: Function, b: any): Promise<any>;
|
|
462
|
+
(a: symbol, b: any): (a: Function) => Promise<any>;
|
|
463
|
+
(a: Function, b: symbol): (b: any) => Promise<any>;
|
|
464
|
+
};
|
|
106
465
|
/** Waits for all promises mapped by the fn. */
|
|
107
|
-
export declare const forEachAsync:
|
|
466
|
+
export declare const forEachAsync: {
|
|
467
|
+
(a: (item: any) => Promise<any>): (b: any[]) => Promise<any[]>;
|
|
468
|
+
(a: (item: any) => Promise<any>, b: any[]): Promise<any[]>;
|
|
469
|
+
(a: symbol, b: any[]): (a: (item: any) => Promise<any>) => Promise<any[]>;
|
|
470
|
+
(a: (item: any) => Promise<any>, b: symbol): (b: any[]) => Promise<any[]>;
|
|
471
|
+
};
|
|
108
472
|
/** The same as compose, but waits for promises in chains and returns a Promise. */
|
|
109
|
-
export declare const composeAsync:
|
|
473
|
+
export declare const composeAsync: import("ts-toolbelt/out/Function/Compose/Multi/Async").ComposeMultiAsync;
|
|
110
474
|
export declare const mirror: (s: any) => any;
|
|
111
475
|
export declare const reflect: (s: any) => any;
|
|
112
476
|
export declare const echo: (s: any) => any;
|
|
113
|
-
export declare const qappend:
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
477
|
+
export declare const qappend: {
|
|
478
|
+
(a: any): (b: any[]) => any[];
|
|
479
|
+
(a: any, b: any[]): any[];
|
|
480
|
+
(a: symbol, b: any[]): (a: any) => any[];
|
|
481
|
+
(a: any, b: symbol): (b: any[]) => any[];
|
|
482
|
+
};
|
|
483
|
+
export declare const qassoc: import("ts-toolbelt/out/Function/Curry").Curry<(prop: string, v: any, obj: AnyObject) => AnyObject>;
|
|
484
|
+
export declare const qreduce: import("ts-toolbelt/out/Function/Curry").Curry<(<T>(fn: Reducer, accum: any, arr: T[]) => any)>;
|
|
485
|
+
export declare const qmergeDeep: import("ts-toolbelt/out/Function/Curry").Curry<(o1: AnyObject, o2: AnyObject) => AnyObject>;
|
|
486
|
+
export declare const qmergeDeepX: import("ts-toolbelt/out/Function/Curry").Curry<(o1: AnyObject, o2: AnyObject) => AnyObject>;
|
|
487
|
+
export declare const qmergeDeepAdd: import("ts-toolbelt/out/Function/Curry").Curry<(o1: AnyObject, o2: AnyObject) => AnyObject>;
|
|
119
488
|
/** qmapKeys({ a: 'b' }, { a: 44 }) -> { b: 44 } */
|
|
120
|
-
export declare const qmapKeys:
|
|
121
|
-
|
|
489
|
+
export declare const qmapKeys: {
|
|
490
|
+
(a: {
|
|
491
|
+
[oldKey: string]: string;
|
|
492
|
+
}): (b: AnyObject) => AnyObject;
|
|
493
|
+
(a: {
|
|
494
|
+
[oldKey: string]: string;
|
|
495
|
+
}, b: AnyObject): AnyObject;
|
|
496
|
+
(a: symbol, b: AnyObject): (a: {
|
|
497
|
+
[oldKey: string]: string;
|
|
498
|
+
}) => AnyObject;
|
|
499
|
+
(a: {
|
|
500
|
+
[oldKey: string]: string;
|
|
501
|
+
}, b: symbol): (b: AnyObject) => AnyObject;
|
|
502
|
+
};
|
|
503
|
+
export declare const qfilter: {
|
|
504
|
+
(a: (v: any, k: string | number) => boolean): (b: any[] | AnyObject) => any[] | AnyObject;
|
|
505
|
+
(a: (v: any, k: string | number) => boolean, b: any[] | AnyObject): any[] | AnyObject;
|
|
506
|
+
(a: symbol, b: any[] | AnyObject): (a: (v: any, k: string | number) => boolean) => any[] | AnyObject;
|
|
507
|
+
(a: (v: any, k: string | number) => boolean, b: symbol): (b: any[] | AnyObject) => any[] | AnyObject;
|
|
508
|
+
};
|
|
122
509
|
/** @deprecated */
|
|
123
|
-
export declare const qindexOf:
|
|
124
|
-
|
|
510
|
+
export declare const qindexOf: {
|
|
511
|
+
(a: any): (b: any[]) => number;
|
|
512
|
+
(a: any, b: any[]): number;
|
|
513
|
+
(a: symbol, b: any[]): (a: any) => number;
|
|
514
|
+
(a: any, b: symbol): (b: any[]) => number;
|
|
515
|
+
};
|
|
516
|
+
export type StrTmpl = ((data: AnyObject) => string);
|
|
125
517
|
export declare const getTmpl: (tmpl: string) => StrTmpl;
|
|
126
518
|
|
|
127
519
|
export {};
|
package/dist/bundle.dev.js
CHANGED
|
@@ -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 :
|
|
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,
|
|
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,
|
|
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,
|
|
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";
|
|
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 __ = (
|
|
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
package/dist/es/quick.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { curry2, curry3 } from "./curry";
|
|
2
2
|
import { type } from "./common";
|
|
3
3
|
import { isFunc, isArray } from "./utils";
|
|
4
|
-
export const qappend =
|
|
5
|
-
export const qassoc =
|
|
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 =
|
|
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 =
|
|
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 =
|
|
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 =
|
|
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 =
|
|
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,
|
|
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 =
|
|
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 =
|
|
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
|
-
});
|
|
35
|
-
export const bind =
|
|
36
|
-
|
|
37
|
-
export const
|
|
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 =
|
|
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,
|
|
53
|
-
export const add =
|
|
54
|
-
export const subtract =
|
|
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 =
|
|
71
|
-
export const tap =
|
|
72
|
-
export const append =
|
|
73
|
-
export const split =
|
|
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 =
|
|
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 =
|
|
89
|
-
export const genBy =
|
|
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 =
|
|
104
|
-
export const lt =
|
|
105
|
-
export const gte =
|
|
106
|
-
export const lte =
|
|
107
|
-
|
|
108
|
-
export const
|
|
109
|
-
export const
|
|
110
|
-
export const
|
|
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 =
|
|
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 =
|
|
120
|
+
export const assoc = curry3((prop, v, obj) => ({
|
|
121
121
|
...obj,
|
|
122
122
|
[prop]: v
|
|
123
123
|
}));
|
|
124
|
-
export const assocPath =
|
|
124
|
+
export const assocPath = curry3((_path, v, o) => compose((first) => assoc(first, length(_path) < 2
|
|
125
125
|
? v
|
|
126
|
-
: assocPath(slice(1,
|
|
127
|
-
export const all =
|
|
128
|
-
export const any =
|
|
129
|
-
export const allPass =
|
|
130
|
-
export const anyPass =
|
|
131
|
-
export const prop =
|
|
132
|
-
export const propEq =
|
|
133
|
-
export const propsEq =
|
|
134
|
-
export const pathOr =
|
|
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,
|
|
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 =
|
|
139
|
-
export const pathsEq =
|
|
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) ?
|
|
160
|
+
return typed_arr_re.test(t) ? s.constructor.from(s) : s;
|
|
159
161
|
}
|
|
160
162
|
};
|
|
161
|
-
export const
|
|
162
|
-
export const
|
|
163
|
-
export const
|
|
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 =
|
|
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 =
|
|
175
|
-
export const join =
|
|
176
|
-
export const map =
|
|
177
|
-
export const forEach =
|
|
178
|
-
export const both =
|
|
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 =
|
|
199
|
-
export const filter =
|
|
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 =
|
|
208
|
-
export const mergeDeep =
|
|
209
|
-
export const mergeDeepX =
|
|
210
|
-
export const mergeDeepAdd =
|
|
211
|
-
export const overProp =
|
|
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 =
|
|
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
|
|
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 =
|
|
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;
|
package/dist/es/utils.js
CHANGED
package/dts-fix.js
ADDED
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
|
-
"
|
|
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.
|
|
43
|
+
"version": "0.13.0b3",
|
|
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
|
|
1
|
+
import { F as FT } from 'ts-toolbelt'
|
|
2
2
|
import { AnyFunc, AnyArgs } from "./types"
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
type Placeholder = symbol
|
|
5
|
+
export const __: Placeholder = Symbol('Placeholder')
|
|
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:
|
|
62
|
-
function _endlessph(a: p0 |
|
|
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:
|
|
76
|
-
function curried2( a: p0, b:
|
|
77
|
-
function curried2( a: p0 |
|
|
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/index.ts
CHANGED
package/src/quick.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
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:
|
|
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:
|
|
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
|
|
80
|
-
o.slice(from, (isNum(to)?to:
|
|
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,
|
|
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
|
|
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:
|
|
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,
|
|
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,
|
|
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