pepka 1.6.3 → 1.6.4

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 CHANGED
@@ -71,6 +71,9 @@ function curry3(fn) {
71
71
  return curry(fn);
72
72
  }
73
73
 
74
+ const typed_arr_re = /^(.*?)(8|16|32|64)(Clamped)?Array$/;
75
+ const is_typed_arr = (t) => typed_arr_re.test(t);
76
+
74
77
  const undef = undefined;
75
78
  const nul = null;
76
79
  const inf = Infinity;
@@ -100,7 +103,7 @@ const isNil = (s) => isNull(s) || isUndef(s);
100
103
  const eq = curry2((a, b) => a === b);
101
104
  const equals = curry2((a, b) => {
102
105
  const typea = type(a);
103
- if (eq(typea, type(b)) && (eq(typea, 'Object') || eq(typea, 'Array'))) {
106
+ if (eq(typea, type(b)) && (eq(typea, 'Object') || eq(typea, 'Array') || is_typed_arr(typea))) {
104
107
  if (isNull(a) || isNull(b))
105
108
  return eq(a, b);
106
109
  if (eq(a, b))
@@ -241,6 +244,7 @@ const qfreeze = (o) => {
241
244
  };
242
245
  const qfreezeShallow = (o) => Object.freeze(o);
243
246
  const qprepend = curry2((x, xs) => xs.unshift(x));
247
+ const qsort = curry2((sortFn, xs) => xs.sort(sortFn));
244
248
  const qassocPath = curry3((_path, v, o) => {
245
249
  const first = _path[0];
246
250
  return qassoc(first, _path.length < 2
@@ -301,7 +305,7 @@ const lt = curry2((a, b) => a > b);
301
305
  const gte = curry2((a, b) => a <= b);
302
306
  /** @param a @param b @returns a≥b */
303
307
  const lte = curry2((a, b) => a >= b);
304
- const sort = curry2((sortFn, xs) => xs.sort(sortFn)); // TODO: make it shallow cloning.
308
+ const sort = curry2((sortFn, xs) => [...xs].sort(sortFn));
305
309
  const find = curry2((fn, s) => s.find(fn));
306
310
  const findIndex = curry2((fn, s) => s.findIndex(fn));
307
311
  const indexOf = curry2((x, xs) => findIndex(equals(x), xs));
@@ -426,7 +430,6 @@ const path = pathOr(undef);
426
430
  const pathEq = curry3((_path, value, o) => equals(path(_path, o), value));
427
431
  const pathsEq = curry3((_path, o1, o2) => equals(path(_path, o1), path(_path, o2)));
428
432
  const pathExists = compose(ifElse(equals(symbol), F, T), pathOr(symbol));
429
- const typed_arr_re = /^(.*?)(8|16|32|64)(Clamped)?Array$/;
430
433
  const clone = (s, shallow = false) => {
431
434
  const t = type(s);
432
435
  switch (t) {
@@ -445,7 +448,7 @@ const clone = (s, shallow = false) => {
445
448
  case 'Symbol':
446
449
  return s;
447
450
  default:
448
- return typed_arr_re.test(t) ? s.constructor.from(s) : s;
451
+ return is_typed_arr(t) ? s.constructor.from(s) : s;
449
452
  }
450
453
  };
451
454
  const cloneShallow = (s) => clone(s, true);
@@ -469,7 +472,7 @@ const omit = curry2((props, o) => filter((_, k) => !includes(k, props), o));
469
472
  const fromPairs = (pairs) => Object.fromEntries(pairs);
470
473
  const concat = curry2(((a, b) => b.concat(a)));
471
474
  const map = curry2((pipe, arr) => arr.map(pipe));
472
- const mapObj = curry2((pipe, o) => qmapObj(pipe, cloneShallow(o)));
475
+ const mapObj = curry2((pipe, o) => qmapObj(pipe, { ...o }));
473
476
  const join = curry2((delimeter, arr) => arr.join(delimeter));
474
477
  const forEach = curry2((pipe, arr) => arr.forEach(pipe));
475
478
  const both = curry3((cond1, cond2, s) => cond2(s) && cond1(s));
@@ -760,6 +763,7 @@ exports.qoverProp = qoverProp;
760
763
  exports.qprepend = qprepend;
761
764
  exports.qreduce = qreduce;
762
765
  exports.qreverse = qreverse;
766
+ exports.qsort = qsort;
763
767
  exports.qstartsWith = qstartsWith;
764
768
  exports.qstartsWithWith = qstartsWithWith;
765
769
  exports.range = range;
package/dist/bundle.d.ts CHANGED
@@ -180,10 +180,10 @@ export declare const lte: {
180
180
  (a: number, b: number): boolean;
181
181
  };
182
182
  export declare const sort: {
183
- (a: symbol, b: any[]): (a: (a: any, b: any) => number) => any[];
184
- (a: (a: any, b: any) => number, b: symbol): (b: any[]) => any[];
185
- (a: (a: any, b: any) => number): (b: any[]) => any[];
186
- (a: (a: any, b: any) => number, b: any[]): any[];
183
+ (a: symbol, b: unknown[]): (a: (a: unknown, b: unknown) => number) => unknown[];
184
+ (a: (a: unknown, b: unknown) => number, b: symbol): (b: unknown[]) => unknown[];
185
+ (a: (a: unknown, b: unknown) => number): (b: unknown[]) => unknown[];
186
+ (a: (a: unknown, b: unknown) => number, b: unknown[]): unknown[];
187
187
  };
188
188
  export declare const find: {
189
189
  (a: symbol, b: any[]): (a: Cond) => any;
@@ -438,10 +438,10 @@ export declare const map: {
438
438
  (a: (s: any, i?: number, list?: any[]) => any, b: any[]): any[];
439
439
  };
440
440
  export declare const mapObj: {
441
- (a: symbol, b: AnyObject): (a: (s: any, i?: string, list?: any[]) => any) => (b: AnyObject) => AnyObject;
442
- (a: (s: any, i?: string, list?: any[]) => any, b: symbol): (b: AnyObject) => (b: AnyObject) => AnyObject;
443
- (a: (s: any, i?: string, list?: any[]) => any): (b: AnyObject) => (b: AnyObject) => AnyObject;
444
- (a: (s: any, i?: string, list?: any[]) => any, b: AnyObject): (b: AnyObject) => AnyObject;
441
+ (a: symbol, b: AnyObject): (a: (s: any, i?: string, list?: any[]) => any) => AnyObject;
442
+ (a: (s: any, i?: string, list?: any[]) => any, b: symbol): (b: AnyObject) => AnyObject;
443
+ (a: (s: any, i?: string, list?: any[]) => any): (b: AnyObject) => AnyObject;
444
+ (a: (s: any, i?: string, list?: any[]) => any, b: AnyObject): AnyObject;
445
445
  };
446
446
  export declare const join: {
447
447
  (a: symbol, b: string[]): (a: string) => string;
@@ -632,6 +632,12 @@ export declare const qprepend: {
632
632
  (a: any): (b: any[]) => number;
633
633
  (a: any, b: any[]): number;
634
634
  };
635
+ export declare const qsort: {
636
+ (a: symbol, b: any[]): (a: (a: any, b: any) => number) => any[];
637
+ (a: (a: any, b: any) => number, b: symbol): (b: any[]) => any[];
638
+ (a: (a: any, b: any) => number): (b: any[]) => any[];
639
+ (a: (a: any, b: any) => number, b: any[]): any[];
640
+ };
635
641
  export declare const qassocPath: (...args: AnyArgs) => any;
636
642
  export declare const qreverse: (arr: any[]) => any[];
637
643
  export declare const qomit: {
package/dist/bundle.mjs CHANGED
@@ -69,6 +69,9 @@ function curry3(fn) {
69
69
  return curry(fn);
70
70
  }
71
71
 
72
+ const typed_arr_re = /^(.*?)(8|16|32|64)(Clamped)?Array$/;
73
+ const is_typed_arr = (t) => typed_arr_re.test(t);
74
+
72
75
  const undef = undefined;
73
76
  const nul = null;
74
77
  const inf = Infinity;
@@ -98,7 +101,7 @@ const isNil = (s) => isNull(s) || isUndef(s);
98
101
  const eq = curry2((a, b) => a === b);
99
102
  const equals = curry2((a, b) => {
100
103
  const typea = type(a);
101
- if (eq(typea, type(b)) && (eq(typea, 'Object') || eq(typea, 'Array'))) {
104
+ if (eq(typea, type(b)) && (eq(typea, 'Object') || eq(typea, 'Array') || is_typed_arr(typea))) {
102
105
  if (isNull(a) || isNull(b))
103
106
  return eq(a, b);
104
107
  if (eq(a, b))
@@ -239,6 +242,7 @@ const qfreeze = (o) => {
239
242
  };
240
243
  const qfreezeShallow = (o) => Object.freeze(o);
241
244
  const qprepend = curry2((x, xs) => xs.unshift(x));
245
+ const qsort = curry2((sortFn, xs) => xs.sort(sortFn));
242
246
  const qassocPath = curry3((_path, v, o) => {
243
247
  const first = _path[0];
244
248
  return qassoc(first, _path.length < 2
@@ -299,7 +303,7 @@ const lt = curry2((a, b) => a > b);
299
303
  const gte = curry2((a, b) => a <= b);
300
304
  /** @param a @param b @returns a≥b */
301
305
  const lte = curry2((a, b) => a >= b);
302
- const sort = curry2((sortFn, xs) => xs.sort(sortFn)); // TODO: make it shallow cloning.
306
+ const sort = curry2((sortFn, xs) => [...xs].sort(sortFn));
303
307
  const find = curry2((fn, s) => s.find(fn));
304
308
  const findIndex = curry2((fn, s) => s.findIndex(fn));
305
309
  const indexOf = curry2((x, xs) => findIndex(equals(x), xs));
@@ -424,7 +428,6 @@ const path = pathOr(undef);
424
428
  const pathEq = curry3((_path, value, o) => equals(path(_path, o), value));
425
429
  const pathsEq = curry3((_path, o1, o2) => equals(path(_path, o1), path(_path, o2)));
426
430
  const pathExists = compose(ifElse(equals(symbol), F, T), pathOr(symbol));
427
- const typed_arr_re = /^(.*?)(8|16|32|64)(Clamped)?Array$/;
428
431
  const clone = (s, shallow = false) => {
429
432
  const t = type(s);
430
433
  switch (t) {
@@ -443,7 +446,7 @@ const clone = (s, shallow = false) => {
443
446
  case 'Symbol':
444
447
  return s;
445
448
  default:
446
- return typed_arr_re.test(t) ? s.constructor.from(s) : s;
449
+ return is_typed_arr(t) ? s.constructor.from(s) : s;
447
450
  }
448
451
  };
449
452
  const cloneShallow = (s) => clone(s, true);
@@ -467,7 +470,7 @@ const omit = curry2((props, o) => filter((_, k) => !includes(k, props), o));
467
470
  const fromPairs = (pairs) => Object.fromEntries(pairs);
468
471
  const concat = curry2(((a, b) => b.concat(a)));
469
472
  const map = curry2((pipe, arr) => arr.map(pipe));
470
- const mapObj = curry2((pipe, o) => qmapObj(pipe, cloneShallow(o)));
473
+ const mapObj = curry2((pipe, o) => qmapObj(pipe, { ...o }));
471
474
  const join = curry2((delimeter, arr) => arr.join(delimeter));
472
475
  const forEach = curry2((pipe, arr) => arr.forEach(pipe));
473
476
  const both = curry3((cond1, cond2, s) => cond2(s) && cond1(s));
@@ -645,4 +648,4 @@ const composeAsync = (() => {
645
648
  return (...fns) => (...input) => pipe(fns, input, fns.length - 1);
646
649
  })();
647
650
 
648
- export { F, T, __, add, all, allPass, always, any, anyPass, append, assoc, assocPath, bind, both, callFrom, callWith, clone, cloneShallow, complement, compose, composeAsync, concat, cond, curry, curry2, curry3, debounce, diff, divide, echo, empty, eq, equals, explore, filter, find, findIndex, flat, flatShallow, flatTo, flip, forEach, forEachAsync, forEachSerial, freeze, freezeShallow, fromPairs, genBy, getTmpl, gt, gte, head, identity, ifElse, includes, indexOf, intersection, isEmpty, isNil, join, keys, last, length, lt, lte, map, mapKeys, mapObj, memoize, mergeDeep, mergeDeepAdd, mergeDeepX, mergeShallow, mirror, multiply, noop, not, notf, nth, omit, once, overProp, path, pathEq, pathExists, pathOr, pathsEq, pick, pickBy, prepend, prop, propEq, propsEq, push, qappend, qassoc, qassocPath, qempty, qfilter, qfreeze, qfreezeShallow, qmap, qmapKeys, qmapObj, qmergeDeep, qmergeDeepAdd, qmergeDeepX, qmergeShallow, qomit, qoverProp, qprepend, qreduce, qreverse, qstartsWith, qstartsWithWith, range, reduce, reflect, replace, reverse, sizeof, slice, some, sort, split, startsWith, subtract, symbol, tail, take, tap, test, throttle, toLower, toPairs, toUpper, trim, type, typeIs, uncurry, uniq, uniqWith, values, wait, waitAll, waitTap, weakEq, when, zip, zipObj, zipWith };
651
+ export { F, T, __, add, all, allPass, always, any, anyPass, append, assoc, assocPath, bind, both, callFrom, callWith, clone, cloneShallow, complement, compose, composeAsync, concat, cond, curry, curry2, curry3, debounce, diff, divide, echo, empty, eq, equals, explore, filter, find, findIndex, flat, flatShallow, flatTo, flip, forEach, forEachAsync, forEachSerial, freeze, freezeShallow, fromPairs, genBy, getTmpl, gt, gte, head, identity, ifElse, includes, indexOf, intersection, isEmpty, isNil, join, keys, last, length, lt, lte, map, mapKeys, mapObj, memoize, mergeDeep, mergeDeepAdd, mergeDeepX, mergeShallow, mirror, multiply, noop, not, notf, nth, omit, once, overProp, path, pathEq, pathExists, pathOr, pathsEq, pick, pickBy, prepend, prop, propEq, propsEq, push, qappend, qassoc, qassocPath, qempty, qfilter, qfreeze, qfreezeShallow, qmap, qmapKeys, qmapObj, qmergeDeep, qmergeDeepAdd, qmergeDeepX, qmergeShallow, qomit, qoverProp, qprepend, qreduce, qreverse, qsort, qstartsWith, qstartsWithWith, range, reduce, reflect, replace, reverse, sizeof, slice, some, sort, split, startsWith, subtract, symbol, tail, take, tap, test, throttle, toLower, toPairs, toUpper, trim, type, typeIs, uncurry, uniq, uniqWith, values, wait, waitAll, waitTap, weakEq, when, zip, zipObj, zipWith };
package/package.json CHANGED
@@ -12,6 +12,7 @@
12
12
  "ramda",
13
13
  "functional",
14
14
  "fp",
15
+ "toolkit",
15
16
  "pure",
16
17
  "strongly-typed",
17
18
  "typescript",
@@ -40,7 +41,7 @@
40
41
  "prod": "npm run gentypes && npm run prod:es && npm run prod:cjs",
41
42
  "all": "npm run dev && npm run prod"
42
43
  },
43
- "version": "1.6.3",
44
+ "version": "1.6.4",
44
45
  "devDependencies": {
45
46
  "@rollup/plugin-commonjs": "^28.0.3",
46
47
  "@rollup/plugin-node-resolve": "^16.0.0",
package/src/common.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { curry2 } from "./curry"
2
+ import { is_typed_arr } from "./internal"
2
3
  import { AnyArray, StrLen } from "./internal_types"
3
4
  import { to, isNull, isStr, isUndef } from "./utils"
4
5
 
@@ -21,7 +22,7 @@ export const isNil = (s: any) => isNull(s) || isUndef(s)
21
22
  export const eq = curry2((a: any, b: any) => a===b)
22
23
  export const equals = curry2((a: any, b: any) => {
23
24
  const typea = type(a)
24
- if(eq(typea, type(b)) && (eq(typea, 'Object') || eq(typea, 'Array'))) {
25
+ if(eq(typea, type(b)) && (eq(typea, 'Object') || eq(typea, 'Array') || is_typed_arr(typea))) {
25
26
  if(isNull(a) || isNull(b)) return eq(a, b)
26
27
  if(eq(a, b)) return true
27
28
  for(const v of [a, b])
@@ -0,0 +1,2 @@
1
+ const typed_arr_re = /^(.*?)(8|16|32|64)(Clamped)?Array$/
2
+ export const is_typed_arr = (t: string) => typed_arr_re.test(t)
package/src/safe.ts CHANGED
@@ -4,6 +4,7 @@ import { qmergeDeep, qreduce, qappend, qmapKeys, qmergeDeepX, qmergeDeepAdd, qfi
4
4
  import { AnyFunc, Cond, AnyObject, Reducer } from './types'
5
5
  import { symbol, type, length, equals, includes, isNil, qstartsWithWith, eq } from './common'
6
6
  import { Split, AnyArray, IndexesOfArray } from './internal_types'
7
+ import { is_typed_arr } from './internal'
7
8
  // TODO: over, lensProp. propsEq is up to 20x slow due to deep equals.
8
9
 
9
10
  export const take = (argN: number) => (...args: any[]) => args[argN]
@@ -260,7 +261,6 @@ export const pathsEq = curry3(
260
261
  equals(path(_path, o1), path(_path, o2))
261
262
  )
262
263
  export const pathExists = compose(ifElse(equals(symbol), F, T), pathOr(symbol))
263
- const typed_arr_re = /^(.*?)(8|16|32|64)(Clamped)?Array$/
264
264
  export const clone = (s: any, shallow = false) => {
265
265
  const t = type(s)
266
266
  switch(t) {
@@ -275,7 +275,7 @@ export const clone = (s: any, shallow = false) => {
275
275
  case 'Boolean': case 'Symbol':
276
276
  return s
277
277
  default:
278
- return typed_arr_re.test(t) ? s.constructor.from(s) : s
278
+ return is_typed_arr(t) ? s.constructor.from(s) : s
279
279
  }
280
280
  }
281
281
  export const cloneShallow = (s: any) => clone(s, true)