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/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
- "bundleDependencies": [],
9
- "deprecated": false,
10
- "description": "An ultra lightweight or unsafe-speedy ramda alternative.",
11
- "homepage": "https://houd1ni.github.io/pepka/",
12
- "keywords": [
13
- "ramda",
14
- "functional",
15
- "fp",
16
- "pure",
17
- "strongly-typed",
18
- "typescript",
19
- "d.ts"
20
- ],
21
- "license": "MIT",
22
- "type": "module",
23
- "exports": {
24
- ".": {
25
- "module": "./dist/bundle.mjs",
26
- "require": "./dist/bundle.cjs"
27
- }
28
- },
29
- "name": "pepka",
30
- "repository": {
31
- "type": "git",
32
- "url": "git+https://github.com/houd1ni/pepka.git"
33
- },
34
- "scripts": {
35
- "lint": "tslint src/*.ts",
36
- "test": "npm run gentypes && npm run prod:cjs && ava",
37
- "test:report": "nyc npm test && nyc report --reporter=text-lcov > coverage.lcov && codecov",
38
- "test:lazy": "ava",
39
- "dts-fix": "node dts-fix.js",
40
- "gentypes": "dts-bundle-generator --no-check -o dist/bundle.d.ts src/index.ts && npm run dts-fix",
41
- "dev": "cross-env NODE_ENV=development BUILD=es rollup -c",
42
- "prod:cjs": "cross-env NODE_ENV=production BUILD=cjs rollup -c",
43
- "prod:es": "cross-env NODE_ENV=production BUILD=es rollup -c",
44
- "prod": "npm run gentypes && npm run prod:es && npm run prod:cjs",
45
- "all": "npm run dev && npm run prod"
46
- },
47
- "version": "0.14.0-beta8",
48
- "ava": {
49
- "files": [ "./test/specs/*.ts" ],
50
- "failFast": true,
51
- "timeout": "2m",
52
- "extensions": [ "ts" ],
53
- "require": [ "ts-node/register" ]
54
- },
55
- "dependencies": {
56
- "ts-toolbelt": "^9.6.0"
57
- },
58
- "devDependencies": {
59
- "@rollup/plugin-commonjs": "^23.0.3",
60
- "@rollup/plugin-node-resolve": "^15.0.1",
61
- "@rollup/plugin-replace": "^5.0.1",
62
- "@rollup/plugin-terser": "^0.1.0",
63
- "@types/node": "^18.11.11",
64
- "ava": "^5.1.0",
65
- "codecov": "^3.8.2",
66
- "cross-env": "^7.0.3",
67
- "dts-bundle-generator": "^7.1.0",
68
- "nyc": "^15.1.0",
69
- "prepend": "^1.0.2",
70
- "rollup": "^3.6.0",
71
- "rollup-plugin-typescript2": "^0.34.1",
72
- "ts-node": "^10.9.1",
73
- "tslint": "^6.1.0",
74
- "typescript": "^4.9.4"
75
- },
76
- "types": "./dist/bundle.d.ts",
77
- "sideEffects": false
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
- <Func extends AnyFunc>(fn: AnyFunc) => (
50
- (...args: AnyArgs) => fn.length>countArgs(args)
51
- ? _curry(fn, [], args)
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 FT.Function>(fn: Func) => {
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
- return curry(fn) as FT.Curry<Func>
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, Curried, TupleFn } from './types'
4
+ import { AnyFunc, Cond, AnyObject, Reducer } from './types'
6
5
  import { type } from './common'
7
- // SomeType, totype, over, lensProp
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<any>(
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>(fn: Reducer<T>, accum: T, arr: any[]) =>
263
- qreduce(fn, clone(accum), arr)
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<any>(
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
- <T = any>(pipe: (s: T, i?: number, list?: T[]) => any, arr: T[]) => arr.map(pipe)
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
@@ -6,6 +6,6 @@ export const uncurry = <
6
6
  Args extends any[] = any[],
7
7
  ReturnT = any
8
8
  >(fn: Curried<Args>): AnyFunc =>
9
- (...args: Args) => qreduce<any>(
9
+ (...args: Args) => qreduce(
10
10
  ((fn: Curried<Args>, arg: any) => fn ? fn(arg) : fn), fn, args
11
11
  ) as ReturnT