pepka 0.14.0-beta8 → 0.14.0
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.cjs +1 -1
- package/dist/bundle.d.ts +69 -154
- package/dist/bundle.dev.js +625 -0
- package/dist/bundle.mjs +1 -1
- package/dts-fix.js +5 -8
- package/package.json +80 -78
- package/src/curry.ts +8 -9
- package/src/safe.ts +38 -11
- package/src/uncurry.ts +1 -1
package/package.json
CHANGED
|
@@ -1,78 +1,80 @@
|
|
|
1
|
-
{
|
|
2
|
-
"author": {
|
|
3
|
-
"name": "Michael houd1ni Akiliev"
|
|
4
|
-
},
|
|
5
|
-
"bugs": {
|
|
6
|
-
"url": "https://github.com/houd1ni/pepka/issues"
|
|
7
|
-
},
|
|
8
|
-
"
|
|
9
|
-
"
|
|
10
|
-
"
|
|
11
|
-
"
|
|
12
|
-
|
|
13
|
-
"
|
|
14
|
-
"
|
|
15
|
-
"
|
|
16
|
-
"
|
|
17
|
-
"
|
|
18
|
-
"
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
"
|
|
22
|
-
"
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
"
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
"
|
|
30
|
-
|
|
31
|
-
"
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
"
|
|
36
|
-
"test": "npm
|
|
37
|
-
"test:
|
|
38
|
-
"
|
|
39
|
-
"
|
|
40
|
-
"
|
|
41
|
-
"
|
|
42
|
-
"prod:
|
|
43
|
-
"prod
|
|
44
|
-
"
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
"
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
"
|
|
52
|
-
"
|
|
53
|
-
"
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
"
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
"@rollup/plugin-
|
|
62
|
-
"@rollup/plugin-
|
|
63
|
-
"@
|
|
64
|
-
"
|
|
65
|
-
"
|
|
66
|
-
"
|
|
67
|
-
"
|
|
68
|
-
"
|
|
69
|
-
"
|
|
70
|
-
"
|
|
71
|
-
"
|
|
72
|
-
"
|
|
73
|
-
"
|
|
74
|
-
"
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
1
|
+
{
|
|
2
|
+
"author": {
|
|
3
|
+
"name": "Michael houd1ni Akiliev"
|
|
4
|
+
},
|
|
5
|
+
"bugs": {
|
|
6
|
+
"url": "https://github.com/houd1ni/pepka/issues"
|
|
7
|
+
},
|
|
8
|
+
"deprecated": false,
|
|
9
|
+
"description": "An ultra lightweight, async or unsafe-speedy ramda alternative.",
|
|
10
|
+
"homepage": "https://houd1ni.github.io/pepka/",
|
|
11
|
+
"keywords": [
|
|
12
|
+
"ramda",
|
|
13
|
+
"functional",
|
|
14
|
+
"fp",
|
|
15
|
+
"pure",
|
|
16
|
+
"strongly-typed",
|
|
17
|
+
"typescript",
|
|
18
|
+
"d.ts"
|
|
19
|
+
],
|
|
20
|
+
"license": "MIT",
|
|
21
|
+
"type": "module",
|
|
22
|
+
"exports": {
|
|
23
|
+
".": {
|
|
24
|
+
"import": "./dist/bundle.mjs",
|
|
25
|
+
"require": "./dist/bundle.cjs"
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
"name": "pepka",
|
|
29
|
+
"repository": {
|
|
30
|
+
"type": "git",
|
|
31
|
+
"url": "git+https://github.com/houd1ni/pepka.git"
|
|
32
|
+
},
|
|
33
|
+
"scripts": {
|
|
34
|
+
"lint": "tslint src/*.ts",
|
|
35
|
+
"test": "npm run gentypes && npm run prod:cjs && ava",
|
|
36
|
+
"test:report": "nyc npm test && nyc report --reporter=text-lcov > coverage.lcov && codecov",
|
|
37
|
+
"test:lazy": "ava",
|
|
38
|
+
"dts-fix": "node dts-fix.js",
|
|
39
|
+
"gentypes": "dts-bundle-generator --no-check -o dist/bundle.d.ts src/index.ts && npm run dts-fix",
|
|
40
|
+
"dev": "cross-env NODE_ENV=development BUILD=es rollup -c",
|
|
41
|
+
"prod:cjs": "cross-env NODE_ENV=production BUILD=cjs rollup -c",
|
|
42
|
+
"prod:es": "cross-env NODE_ENV=production BUILD=es rollup -c",
|
|
43
|
+
"prod": "npm run gentypes && npm run prod:es && npm run prod:cjs",
|
|
44
|
+
"all": "npm run dev && npm run prod"
|
|
45
|
+
},
|
|
46
|
+
"version": "0.14.0",
|
|
47
|
+
"ava": {
|
|
48
|
+
"files": [
|
|
49
|
+
"./test/specs/*.ts"
|
|
50
|
+
],
|
|
51
|
+
"failFast": true,
|
|
52
|
+
"timeout": "2m",
|
|
53
|
+
"extensions": [
|
|
54
|
+
"ts"
|
|
55
|
+
],
|
|
56
|
+
"require": [
|
|
57
|
+
"ts-node/register"
|
|
58
|
+
]
|
|
59
|
+
},
|
|
60
|
+
"devDependencies": {
|
|
61
|
+
"@rollup/plugin-commonjs": "^23.0.3",
|
|
62
|
+
"@rollup/plugin-node-resolve": "^15.0.1",
|
|
63
|
+
"@rollup/plugin-replace": "^5.0.1",
|
|
64
|
+
"@rollup/plugin-terser": "^0.1.0",
|
|
65
|
+
"@types/node": "^18.11.11",
|
|
66
|
+
"ava": "^5.1.0",
|
|
67
|
+
"codecov": "^3.8.2",
|
|
68
|
+
"cross-env": "^7.0.3",
|
|
69
|
+
"dts-bundle-generator": "^7.1.0",
|
|
70
|
+
"nyc": "^15.1.0",
|
|
71
|
+
"prepend": "^1.0.2",
|
|
72
|
+
"rollup": "^3.6.0",
|
|
73
|
+
"rollup-plugin-typescript2": "^0.34.1",
|
|
74
|
+
"ts-node": "^10.9.1",
|
|
75
|
+
"tslint": "^6.1.0",
|
|
76
|
+
"typescript": "^4.9.4"
|
|
77
|
+
},
|
|
78
|
+
"types": "./dist/bundle.d.ts",
|
|
79
|
+
"sideEffects": false
|
|
80
|
+
}
|
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,10 +1,9 @@
|
|
|
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'
|
|
5
|
-
import { AnyFunc, Cond, AnyObject, Reducer
|
|
4
|
+
import { AnyFunc, Cond, AnyObject, Reducer } from './types'
|
|
6
5
|
import { type } from './common'
|
|
7
|
-
//
|
|
6
|
+
// over, lensProp
|
|
8
7
|
|
|
9
8
|
export const take = (argN: number) => (...args: any[]) => args[argN]
|
|
10
9
|
export const equals = curry2((a: any, b: any) => {
|
|
@@ -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
|
),
|
|
@@ -179,6 +178,11 @@ export const cond = curry2(
|
|
|
179
178
|
}
|
|
180
179
|
}
|
|
181
180
|
)
|
|
181
|
+
/** Assigns a prop to an object.
|
|
182
|
+
* @param prop string
|
|
183
|
+
* @param value any
|
|
184
|
+
* @param object AnyObject
|
|
185
|
+
*/
|
|
182
186
|
export const assoc = curry3(
|
|
183
187
|
(prop: string, v: any, obj: AnyObject) => ({
|
|
184
188
|
...obj,
|
|
@@ -258,9 +262,14 @@ export const clone = (s: any, shallow = false) => {
|
|
|
258
262
|
}
|
|
259
263
|
export const cloneShallow = (s: any) => clone(s, true)
|
|
260
264
|
|
|
265
|
+
/** types T1, T2
|
|
266
|
+
* @param reducer (accum: T1, current: T2, index: number) => newAccum: T1
|
|
267
|
+
* @param accum T1
|
|
268
|
+
* @param array T2[]
|
|
269
|
+
*/
|
|
261
270
|
export const reduce = curry3(
|
|
262
|
-
<T = any>(
|
|
263
|
-
qreduce(
|
|
271
|
+
<T = any>(reducer: Reducer<T>, accum: T, arr: any[]) =>
|
|
272
|
+
qreduce(reducer, clone(accum), arr)
|
|
264
273
|
)
|
|
265
274
|
export const pickBy = curry2(
|
|
266
275
|
(cond: Cond, o: AnyObject) => filter(cond, o)
|
|
@@ -282,7 +291,7 @@ export const omit = curry2(
|
|
|
282
291
|
o
|
|
283
292
|
)
|
|
284
293
|
)
|
|
285
|
-
export const fromPairs = (pairs: [string, any][]) => reduce
|
|
294
|
+
export const fromPairs = (pairs: [string, any][]) => reduce(
|
|
286
295
|
(o: AnyObject, pair: [string, any]) => assoc(...pair, o),
|
|
287
296
|
{}, pairs
|
|
288
297
|
)
|
|
@@ -295,7 +304,7 @@ export const join = curry2(
|
|
|
295
304
|
(delimeter: string, arr: string[]) => arr.join(delimeter)
|
|
296
305
|
)
|
|
297
306
|
export const map = curry2(
|
|
298
|
-
|
|
307
|
+
(pipe: (s: any, i?: number, list?: any[]) => any, arr: any[]) => arr.map(pipe)
|
|
299
308
|
)
|
|
300
309
|
export const forEach = curry2(
|
|
301
310
|
(pipe: (s: any) => any, arr: any[]) => arr.forEach(pipe)
|
|
@@ -350,13 +359,13 @@ export const mergeShallow = curry2(
|
|
|
350
359
|
Object.assign({}, o1, o2)
|
|
351
360
|
)
|
|
352
361
|
export const mergeDeep = curry2(
|
|
353
|
-
(a: AnyObject, b: AnyObject) => qmergeDeep(clone(a), clone(b))
|
|
362
|
+
(a: AnyObject, b: AnyObject) => qmergeDeep(clone(a), clone(b)) as AnyObject
|
|
354
363
|
)
|
|
355
364
|
export const mergeDeepX = curry2(
|
|
356
|
-
(a: AnyObject, b: AnyObject) => qmergeDeepX(clone(a), clone(b))
|
|
365
|
+
(a: AnyObject, b: AnyObject) => qmergeDeepX(clone(a), clone(b)) as AnyObject
|
|
357
366
|
)
|
|
358
367
|
export const mergeDeepAdd = curry2(
|
|
359
|
-
(a: AnyObject, b: AnyObject) => qmergeDeepAdd(clone(a), clone(b))
|
|
368
|
+
(a: AnyObject, b: AnyObject) => qmergeDeepAdd(clone(a), clone(b)) as AnyObject
|
|
360
369
|
)
|
|
361
370
|
export const overProp = curry3(
|
|
362
371
|
(prop: string, pipe: AnyFunc, data: any) =>
|
|
@@ -369,6 +378,24 @@ export const mapKeys = curry2(
|
|
|
369
378
|
o: AnyObject
|
|
370
379
|
) => qmapKeys(keyMap, Object.assign({}, o))
|
|
371
380
|
)
|
|
381
|
+
export const zip = curry2(
|
|
382
|
+
<T1 = any, T2 = any>(a: T1[], b: T2[]) => map((s: T1, i: number) => [s, b[i]], a)
|
|
383
|
+
)
|
|
384
|
+
export const zipObj = curry2(
|
|
385
|
+
<T1 = any, T2 = any>(a: T1[], b: T2[]) =>
|
|
386
|
+
reduce((ac: AnyObject, s: T1, i: number) => assoc(s, b[i], ac), {}, a)
|
|
387
|
+
)
|
|
388
|
+
// TODO: Tuple curried functions to replace these `AnyFuncs`.
|
|
389
|
+
/** zips through a pipe. Types T1, T2, T3.
|
|
390
|
+
* @returns T3[]
|
|
391
|
+
* @param pipe (T1, T2) => T3
|
|
392
|
+
* @param a T1[]
|
|
393
|
+
* @param b T2[]
|
|
394
|
+
*/
|
|
395
|
+
export const zipWith = curry3(
|
|
396
|
+
<T1 = any, T2 = any>(pipe: AnyFunc, a: T1[], b: T2[]) =>
|
|
397
|
+
map((s: T1, i: number) => pipe(s, b[i]), a)
|
|
398
|
+
)
|
|
372
399
|
|
|
373
400
|
// ASYNCS
|
|
374
401
|
|
package/src/uncurry.ts
CHANGED