pepka 0.12.3 → 0.13.0-b10

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/es/safe.js CHANGED
@@ -1,9 +1,9 @@
1
- import { __, curry } from './curry';
2
- import { isNum, nul, isUndef, undef, isNull, isArray, isFunc, isStr, isObj } from './utils';
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 = curry((a, b) => {
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 = curry((cond, pipe, s) => ifElse(cond, pipe, identity, s));
29
- export const compose = ((...fns) => (s = __) => {
28
+ export const when = curry3((cond, pipe, s) => ifElse(cond, pipe, identity, s));
29
+ export const compose = ((...fns) => (s = Symbol()) => {
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
- }); // as F.Compose
35
- export const bind = curry((fn, context) => fn.bind(context));
36
- export const nth = curry((i, data) => data[i]);
37
- export const includes = curry((s, ss) => {
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 = curry((from, to, o) => o.slice(from, (isNum(to) ? to : Infinity)));
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, nul);
53
- export const add = curry((n, m) => n + m);
54
- export const subtract = curry((n, m) => m - n);
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 = curry((re, s) => re.test(s));
71
- export const tap = curry((fn, s) => { fn(s); return s; });
72
- export const append = curry((s, xs) => [...xs, s]);
73
- export const split = curry((s, xs) => xs.split(s));
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 = curry((from, to) => genBy(add(from), to - from));
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 = curry((xs1, xs2) => xs1.filter(flip(includes)(xs2)));
89
- export const genBy = curry((generator, length) => [...Array(length)].map((_, i) => generator(i)));
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 = curry((a, b) => a > b);
104
- export const lt = curry((a, b) => a < b);
105
- export const gte = curry((a, b) => b >= a);
106
- export const lte = curry((a, b) => b <= a);
107
- // : <U=any>(sortFn: (v: U)=>-1|1, xs: U[]) => U[]
108
- export const sort = curry((sortFn, xs) => xs.sort(sortFn));
109
- export const find = curry((fn, s) => s.find(fn));
110
- export const findIndex = curry((fn, s) => s.findIndex(fn));
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 = curry((pairs, s) => {
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 = curry((prop, v, obj) => ({
120
+ export const assoc = curry3((prop, v, obj) => ({
121
121
  ...obj,
122
122
  [prop]: v
123
123
  }));
124
- export const assocPath = curry((_path, v, o) => compose((first) => assoc(first, length(_path) < 2
124
+ export const assocPath = curry3((_path, v, o) => compose((first) => assoc(first, length(_path) < 2
125
125
  ? v
126
- : assocPath(slice(1, null, _path), v, isObj(o[first]) ? o[first] : {}), o), head)(_path));
127
- export const all = curry((pred, xs) => xs.every(pred));
128
- export const any = curry((pred, xs) => xs.some(pred));
129
- export const allPass = curry((preds, x) => preds.every((pred) => pred(x)));
130
- export const anyPass = curry((preds, x) => preds.some((pred) => pred(x)));
131
- export const prop = curry((key, o) => o[key]);
132
- export const propEq = curry((key, value, o) => equals(o[key], value));
133
- export const propsEq = curry((key, o1, o2) => equals(o1[key], o2[key]));
134
- export const pathOr = curry((_default, path, o) => ifElse(length, () => isNil(o)
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, nul, path), o)), flip(prop)(o), head)(path), always(o), path));
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 = curry((_path, value, o) => equals(path(_path, o), value));
139
- export const pathsEq = curry((_path, o1, o2) => equals(path(_path, o1), path(_path, o2)));
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) ? map(clone, s) : s;
160
+ return typed_arr_re.test(t) ? s.constructor.from(s) : s;
159
161
  }
160
162
  };
161
- export const reduce = curry((fn, accum, arr) => qreduce(fn, clone(accum), arr));
162
- export const pickBy = curry((cond, o) => filter(cond, o));
163
- export const pick = curry((props, o) => {
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 = curry((props, o) => filter((_, k) => !includes(k, props), o));
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 = curry(((a, b) => a.concat(b)));
175
- export const join = curry((delimeter, arr) => arr.join(delimeter));
176
- export const map = curry((pipe, arr) => arr.map(pipe));
177
- export const forEach = curry((pipe, arr) => arr.forEach(pipe));
178
- export const both = curry((cond1, cond2, s) => cond2(s) && cond1(s));
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 = curry((a, b, where) => where.replace(a, b));
199
- export const filter = curry((cond, data) => isArray(data)
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 = curry((o1, o2) => Object.assign({}, o1, o2));
208
- export const mergeDeep = curry((a, b) => qmergeDeep(clone(a), clone(b)));
209
- export const mergeDeepX = curry((a, b) => qmergeDeepX(clone(a), clone(b)));
210
- export const mergeDeepAdd = curry((a, b) => qmergeDeepAdd(clone(a), clone(b)));
211
- export const overProp = curry((prop, pipe, data) => assoc(prop, pipe(data[prop]), data));
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 = curry((keyMap, o) => qmapKeys(keyMap, Object.assign({}, o)));
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 curry((fn, items) => pipe(fn, items, 0));
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 = curry((fn, items) => Promise.all(items.map(fn)));
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;
@@ -0,0 +1,3 @@
1
+ import { qreduce } from "./quick";
2
+ // TODO: possibly introduce a second argument limiting unfolding.
3
+ export const uncurry = (fn) => (...args) => qreduce(((fn, arg) => fn ? fn(arg) : fn), fn, args);
package/dist/es/utils.js CHANGED
@@ -1,5 +1,6 @@
1
1
  export const undef = undefined;
2
2
  export const nul = null;
3
+ export const inf = Infinity;
3
4
  export const to = (s) => typeof s;
4
5
  export const isNull = (s) => s === nul;
5
6
  export const isUndef = (s) => s === undef;
package/dts-fix.js ADDED
@@ -0,0 +1,11 @@
1
+ import prepend from 'prepend'
2
+  
3
+ const s =
4
+ `import {F as FT} from 'ts-toolbelt'
5
+ export { __ }
6
+ `
7
+
8
+ prepend('./dist/bundle.d.ts', s, function(error) {
9
+     if (error)
10
+         console.error(error.message)
11
+ })
package/package.json CHANGED
@@ -19,6 +19,7 @@
19
19
  "d.ts"
20
20
  ],
21
21
  "license": "MIT",
22
+ "type": "module",
22
23
  "main": "dist/bundle.js",
23
24
  "module": "dist/es/index.js",
24
25
  "name": "pepka",
@@ -31,22 +32,21 @@
31
32
  "test": "npm run gentypes && npm run prod:cjs && ava",
32
33
  "test:report": "nyc npm test && nyc report --reporter=text-lcov > coverage.lcov && codecov",
33
34
  "test:lazy": "ava",
34
- "gentypes": "dts-bundle-generator -o dist/bundle.d.ts src/index.ts",
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",
35
37
  "dev": "cross-env NODE_ENV=development BUILD=es rollup -c",
36
38
  "prod:cjs": "cross-env NODE_ENV=production BUILD=cjs rollup -c",
37
39
  "prod:es": "cross-env NODE_ENV=production tsc",
38
40
  "prod": "npm run gentypes && npm run prod:es && npm run prod:cjs",
39
41
  "all": "npm run dev && npm run prod"
40
42
  },
41
- "version": "0.12.3",
43
+ "version": "0.13.0b10",
42
44
  "ava": {
43
45
  "files": [
44
46
  "./test/specs/*.ts"
45
47
  ],
46
- "serial": false,
47
48
  "failFast": true,
48
49
  "timeout": "2m",
49
- "compileEnhancements": false,
50
50
  "extensions": [
51
51
  "ts"
52
52
  ],
@@ -54,24 +54,27 @@
54
54
  "ts-node/register"
55
55
  ]
56
56
  },
57
+ "dependencies": {
58
+ "ts-toolbelt": "^9.6.0"
59
+ },
57
60
  "devDependencies": {
58
- "@types/node": "^15.12.4",
59
- "ava": "^3.15.0",
61
+ "@types/node": "^18.11.10",
62
+ "ava": "^5.1.0",
60
63
  "codecov": "^3.8.2",
61
64
  "cross-env": "^7.0.3",
62
- "dts-bundle-generator": "^5.9.0",
65
+ "dts-bundle-generator": "^7.1.0",
63
66
  "nyc": "^15.1.0",
64
- "rollup": "^2.52.1",
67
+ "prepend": "^1.0.2",
68
+ "rollup": "^3.5.1",
65
69
  "rollup-plugin-commonjs": "^10.1.0",
66
70
  "rollup-plugin-node-resolve": "^5.2.0",
67
71
  "rollup-plugin-replace": "^2.2.0",
68
72
  "rollup-plugin-resolve-aliases": "^0.3.0",
69
73
  "rollup-plugin-terser": "^7.0.2",
70
- "rollup-plugin-typescript2": "^0.30.0",
71
- "ts-node": "^10.0.0",
72
- "ts-toolbelt": "^9.6.0",
74
+ "rollup-plugin-typescript2": "^0.34.1",
75
+ "ts-node": "^10.9.1",
73
76
  "tslint": "^6.1.0",
74
- "typescript": "^4.3.4"
77
+ "typescript": "^4.9.3"
75
78
  },
76
79
  "types": "./dist/bundle.d.ts",
77
80
  "sideEffects": false
package/rollup.config.js CHANGED
@@ -3,6 +3,7 @@ import resolve from 'rollup-plugin-node-resolve'
3
3
  import typescript from 'rollup-plugin-typescript2'
4
4
  import { terser } from 'rollup-plugin-terser'
5
5
  import replace from 'rollup-plugin-replace'
6
+ import tsc from 'typescript'
6
7
 
7
8
  export default {
8
9
  input: process.env.NODE_ENV=='development' ? 'test/in-browser.ts' : 'src/index.ts',
@@ -16,7 +17,7 @@ export default {
16
17
  resolve(),
17
18
  commonjs(),
18
19
  typescript({
19
- typescript: require("typescript"),
20
+ typescript: tsc,
20
21
  tsconfig: "./tsconfig.json",
21
22
  tsconfigOverride: {
22
23
  compilerOptions: {
package/src/curry.ts CHANGED
@@ -1,9 +1,10 @@
1
+ import { F as FT } from 'ts-toolbelt'
2
+ import { AnyFunc, AnyArgs } from "./types"
1
3
 
2
- type Args = any[]
4
+ type Placeholder = symbol
5
+ export const __: Placeholder = Symbol('Placeholder')
3
6
 
4
- export const __ = (function Placeholder() {})
5
-
6
- const countArgs = (s: Args) => {
7
+ const countArgs = (s: AnyArgs) => {
7
8
  let i = 0
8
9
  for (const v of s) v!==__ && i++
9
10
  return i
@@ -11,7 +12,7 @@ const countArgs = (s: Args) => {
11
12
 
12
13
  // TODO: try to make it mutable.
13
14
  // { 0: __, 1: 10 }, [ 11 ]
14
- const addArgs = (args: Args, _args: Args) => {
15
+ const addArgs = (args: AnyArgs, _args: AnyArgs) => {
15
16
  const len = args.length
16
17
  const new_args = args.slice()
17
18
  const _args_len = _args.length
@@ -29,12 +30,12 @@ const addArgs = (args: Args, _args: Args) => {
29
30
  return new_args
30
31
  }
31
32
 
32
- const _curry = (fn: Function, args: Args, new_args: Args) => {
33
+ const _curry = (fn: Function, args: AnyArgs, new_args: AnyArgs) => {
33
34
  const args2add = fn.length - args.length - countArgs(new_args)
34
35
  if(args2add < 1) {
35
36
  return fn(...addArgs(args, new_args))
36
37
  } else {
37
- const curried = (...__args: Args) => _curry(
38
+ const curried = (...__args: AnyArgs) => _curry(
38
39
  fn,
39
40
  addArgs(args, new_args),
40
41
  __args
@@ -45,9 +46,52 @@ const _curry = (fn: Function, args: Args, new_args: Args) => {
45
46
  }
46
47
 
47
48
  export const curry = (
48
- (fn: Function) => (
49
- (...args: Args) => fn.length>countArgs(args)
49
+ <Func extends AnyFunc>(fn: AnyFunc) => (
50
+ (...args: AnyArgs) => fn.length>countArgs(args)
50
51
  ? _curry(fn, [], args)
51
52
  : fn(...args)
52
- )
53
- )
53
+ ) as FT.Curry<Func>
54
+ )
55
+ const endlessph = <Func extends FT.Function>(fn: Func) => {
56
+ type ReturnT = ReturnType<Func>
57
+ type p0 = Parameters<Func>[0]
58
+ function _endlessph(a: p0): ReturnT
59
+ function _endlessph(a: Placeholder): Func
60
+ function _endlessph(a: p0 | Placeholder) {
61
+ return a===__ ? fn : fn(a)
62
+ }
63
+ return _endlessph
64
+ }
65
+
66
+ type Func2 = (a: any, b: any) => any
67
+ export function curry2<Func extends Func2>(fn: Func) {
68
+ type p0 = Parameters<Func>[0]
69
+ type p1 = Parameters<Func>[1]
70
+ type ReturnT = ReturnType<Func>
71
+ function curried2( a: Placeholder, b: p1 ): (a: p0) => ReturnT
72
+ function curried2( a: p0, b: Placeholder ): (b: p1) => ReturnT
73
+ function curried2( a: p0 ): (b: p1) => ReturnT
74
+ function curried2( a: p0, b: p1 ): ReturnT
75
+ function curried2( a: p0 | Placeholder, b?: p1 ) {
76
+ const withPlaceholder1 = a===__
77
+ const aln = arguments.length
78
+ if(aln === 1 && withPlaceholder1)
79
+ throw new Error('Senseless placeholder usage.')
80
+ return arguments.length>1
81
+ ? withPlaceholder1
82
+ ? endlessph((a: p0) => fn(a, b))
83
+ : fn(a, b) as ReturnType<Func>
84
+ : (b: p1) => fn(a, b)
85
+ }
86
+ return curried2
87
+ }
88
+
89
+ type Func3 = (a: any, b: any, c: any) => any
90
+ export function curry3<Func extends Func3>(fn: Func) {
91
+ // type p0 = Parameters<Func>[0]
92
+ // type p1 = Parameters<Func>[1]
93
+ // type p2 = Parameters<Func>[2]
94
+ // type ReturnT = ReturnType<Func>
95
+ // TODO: optimize.
96
+ return curry(fn) as FT.Curry<Func>
97
+ }
package/src/index.ts CHANGED
@@ -1,5 +1,6 @@
1
1
 
2
2
  export * from './curry'
3
+ export * from './uncurry'
3
4
  export * from './common'
4
5
  export * from './safe'
5
6
  export * from './quick'
package/src/quick.ts CHANGED
@@ -1,21 +1,21 @@
1
- import { curry } from "./curry"
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"
5
5
 
6
- export const qappend = curry((s: any, xs: any[]) => {xs.push(s); return xs})
7
- export const qassoc = curry(
6
+ export const qappend = curry2((s: any, xs: any[]) => {xs.push(s); return xs})
7
+ export const qassoc = curry3(
8
8
  (prop: string, v: any, obj: AnyObject) => {
9
9
  obj[prop] = v
10
10
  return obj
11
11
  }
12
12
  )
13
- export const qreduce = curry(
14
- (fn: Reducer, accum: any, arr: any[]) =>
13
+ export const qreduce = curry3(
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.
18
- const mergeDeep = curry((strategy: 1|2|3, o1: AnyObject, o2: AnyObject): AnyObject => {
18
+ const mergeDeep = curry3((strategy: 1|2|3, o1: AnyObject, o2: AnyObject): AnyObject => {
19
19
  for(let k in o2) {
20
20
  switch(type(o2[k])) {
21
21
  case 'Array':
@@ -54,7 +54,7 @@ export const qmergeDeep = mergeDeep(1)
54
54
  export const qmergeDeepX = mergeDeep(2)
55
55
  export const qmergeDeepAdd = mergeDeep(3)
56
56
  /** qmapKeys({ a: 'b' }, { a: 44 }) -> { b: 44 } */
57
- export const qmapKeys = curry(
57
+ export const qmapKeys = curry2(
58
58
  (
59
59
  keyMap: {[oldKey: string]: string},
60
60
  o: AnyObject
@@ -74,7 +74,7 @@ export const qmapKeys = curry(
74
74
  }
75
75
  )
76
76
 
77
- export const qfilter = curry(
77
+ export const qfilter = curry2(
78
78
  (
79
79
  cond: (v: any, k: string | number) => boolean,
80
80
  data: any[] | AnyObject
@@ -94,6 +94,6 @@ export const qfilter = curry(
94
94
  }
95
95
  )
96
96
  /** @deprecated */
97
- export const qindexOf = curry(
97
+ export const qindexOf = curry2(
98
98
  (x: any, xs: any[]) => xs.indexOf(x)
99
99
  )