pepka 1.12.2 → 1.12.3

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
@@ -169,6 +169,9 @@ const includes = curry2((s, ss) => {
169
169
  return false;
170
170
  }
171
171
  });
172
+ const always = (s) => () => s;
173
+ const identity = (s) => s;
174
+ const trim = (s) => s.trim();
172
175
 
173
176
  const { min } = Math;
174
177
  const z = 0;
@@ -341,23 +344,26 @@ const rmel = (index, xs) => {
341
344
  return xs;
342
345
  };
343
346
  const seen = new Set();
344
- const quniq = (xs) => {
345
- seen.clear();
346
- let size = length(xs);
347
+ const quniqWith = curry2((getter, xs) => {
348
+ let size = length(xs), cur;
347
349
  for (let i = z; i < size; i++) {
348
350
  const x = xs[i];
349
- if (seen.has(x)) {
351
+ cur = getter(x);
352
+ if (seen.has(cur)) {
350
353
  rmel(i, xs);
351
354
  size--;
352
355
  i--;
353
356
  }
354
357
  else
355
- seen.add(x);
358
+ seen.add(cur);
356
359
  }
360
+ seen.clear();
357
361
  return xs;
358
- };
362
+ });
363
+ const quniq = quniqWith(identity);
359
364
  // Aliases.
360
365
  const qpush = qappend;
366
+ const quniqBy = quniqWith;
361
367
 
362
368
  const { assign } = Object;
363
369
  // TODO: over, reduceAsync, propsEq is up to 20x slow due to deep equals.
@@ -413,9 +419,6 @@ const find = curry2((fn, s) => s.find(fn));
413
419
  const findIndex = curry2((fn, s) => s.findIndex(fn));
414
420
  const indexOf = curry2((x, xs) => findIndex(equals(x), xs));
415
421
  const divide = curry2((a, b) => b / a);
416
- const always = (s) => () => s;
417
- const identity = (s) => s;
418
- const trim = (s) => s.trim();
419
422
  const not = (x) => !x;
420
423
  const keys = (o) => Object.keys(o);
421
424
  const values = (o) => Object.values(o);
@@ -937,6 +940,8 @@ exports.qreverse = qreverse;
937
940
  exports.qslice = qslice;
938
941
  exports.qsort = qsort;
939
942
  exports.quniq = quniq;
943
+ exports.quniqBy = quniqBy;
944
+ exports.quniqWith = quniqWith;
940
945
  exports.qwaitAll = qwaitAll;
941
946
  exports.range = range;
942
947
  exports.reduce = reduce;
package/dist/bundle.d.ts CHANGED
@@ -111,6 +111,9 @@ export declare const includes: {
111
111
  (a: unknown): (b: unknown[]) => boolean;
112
112
  (a: unknown, b: unknown[]): boolean;
113
113
  };
114
+ export declare const always: <T extends any>(s: T) => () => T;
115
+ export declare const identity: <T extends any>(s: T) => T;
116
+ export declare const trim: (s: string) => string;
114
117
  export declare const qappend: {
115
118
  (a: Placeholder, b: any[]): (a: any) => any[];
116
119
  (a: any, b: Placeholder): (b: any[]) => any[];
@@ -231,13 +234,25 @@ export declare const qpick: {
231
234
  (a: string[], b: AnyObject): AnyObject;
232
235
  };
233
236
  export declare const qslice: (...args: AnyArgs) => any;
234
- export declare const quniq: (xs: any[]) => any[];
237
+ export declare const quniqWith: {
238
+ (a: Placeholder, b: any[]): (a: AnyFunc) => any[];
239
+ (a: AnyFunc, b: Placeholder): (b: any[]) => any[];
240
+ (a: AnyFunc): (b: any[]) => any[];
241
+ (a: AnyFunc, b: any[]): any[];
242
+ };
243
+ export declare const quniq: (b: any[]) => any[];
235
244
  export declare const qpush: {
236
245
  (a: Placeholder, b: any[]): (a: any) => any[];
237
246
  (a: any, b: Placeholder): (b: any[]) => any[];
238
247
  (a: any): (b: any[]) => any[];
239
248
  (a: any, b: any[]): any[];
240
249
  };
250
+ export declare const quniqBy: {
251
+ (a: Placeholder, b: any[]): (a: AnyFunc) => any[];
252
+ (a: AnyFunc, b: Placeholder): (b: any[]) => any[];
253
+ (a: AnyFunc): (b: any[]) => any[];
254
+ (a: AnyFunc, b: any[]): any[];
255
+ };
241
256
  export declare const isNil: <T extends any>(s: T) => T extends (null | undefined) ? true : false;
242
257
  export declare class QPromise<T> extends Promise<T> {
243
258
  private oncancel;
@@ -390,9 +405,6 @@ export declare const divide: {
390
405
  (a: number): (b: number) => number;
391
406
  (a: number, b: number): number;
392
407
  };
393
- export declare const always: <T extends any>(s: T) => () => T;
394
- export declare const identity: <T extends any>(s: T) => T;
395
- export declare const trim: (s: string) => string;
396
408
  type T_not = {
397
409
  (x: true): false;
398
410
  (x: false): true;
package/dist/bundle.mjs CHANGED
@@ -167,6 +167,9 @@ const includes = curry2((s, ss) => {
167
167
  return false;
168
168
  }
169
169
  });
170
+ const always = (s) => () => s;
171
+ const identity = (s) => s;
172
+ const trim = (s) => s.trim();
170
173
 
171
174
  const { min } = Math;
172
175
  const z = 0;
@@ -339,23 +342,26 @@ const rmel = (index, xs) => {
339
342
  return xs;
340
343
  };
341
344
  const seen = new Set();
342
- const quniq = (xs) => {
343
- seen.clear();
344
- let size = length(xs);
345
+ const quniqWith = curry2((getter, xs) => {
346
+ let size = length(xs), cur;
345
347
  for (let i = z; i < size; i++) {
346
348
  const x = xs[i];
347
- if (seen.has(x)) {
349
+ cur = getter(x);
350
+ if (seen.has(cur)) {
348
351
  rmel(i, xs);
349
352
  size--;
350
353
  i--;
351
354
  }
352
355
  else
353
- seen.add(x);
356
+ seen.add(cur);
354
357
  }
358
+ seen.clear();
355
359
  return xs;
356
- };
360
+ });
361
+ const quniq = quniqWith(identity);
357
362
  // Aliases.
358
363
  const qpush = qappend;
364
+ const quniqBy = quniqWith;
359
365
 
360
366
  const { assign } = Object;
361
367
  // TODO: over, reduceAsync, propsEq is up to 20x slow due to deep equals.
@@ -411,9 +417,6 @@ const find = curry2((fn, s) => s.find(fn));
411
417
  const findIndex = curry2((fn, s) => s.findIndex(fn));
412
418
  const indexOf = curry2((x, xs) => findIndex(equals(x), xs));
413
419
  const divide = curry2((a, b) => b / a);
414
- const always = (s) => () => s;
415
- const identity = (s) => s;
416
- const trim = (s) => s.trim();
417
420
  const not = (x) => !x;
418
421
  const keys = (o) => Object.keys(o);
419
422
  const values = (o) => Object.values(o);
@@ -814,4 +817,4 @@ const wait = (time) => new QPromise((ff) => setTimeout(ff, time), (timeout) => c
814
817
  // TODO: possibly introduce a second argument limiting unfolding.
815
818
  const uncurry = (fn) => (...args) => qreduce(((fn, arg) => fn ? fn(arg) : fn), fn, args);
816
819
 
817
- export { F, QPromise, 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, forEachParallel, 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, propLens, propsEq, push, qappend, qassoc, qassocPath, qempty, qfilter, qfilterAsync, qfreeze, qfreezeShallow, qmap, qmapKeys, qmapObj, qmergeDeep, qmergeDeepAdd, qmergeDeepX, qmergeShallow, qomit, qoverProp, qpick, qprepend, qpush, qreduce, qreverse, qslice, qsort, quniq, qwaitAll, range, reduce, reflect, replace, reverse, sizeof, slice, some, sort, split, startsWith, startsWithShallow, subtract, symbol, tail, take, tap, test, throttle, toLower, toPairs, toUpper, trim, type, typeIs, uncurry, uniq, uniqBy, uniqWith, values, wait, waitAll, waitTap, weakEq, when, zip, zipObj, zipWith };
820
+ export { F, QPromise, 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, forEachParallel, 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, propLens, propsEq, push, qappend, qassoc, qassocPath, qempty, qfilter, qfilterAsync, qfreeze, qfreezeShallow, qmap, qmapKeys, qmapObj, qmergeDeep, qmergeDeepAdd, qmergeDeepX, qmergeShallow, qomit, qoverProp, qpick, qprepend, qpush, qreduce, qreverse, qslice, qsort, quniq, quniqBy, quniqWith, qwaitAll, range, reduce, reflect, replace, reverse, sizeof, slice, some, sort, split, startsWith, startsWithShallow, subtract, symbol, tail, take, tap, test, throttle, toLower, toPairs, toUpper, trim, type, typeIs, uncurry, uniq, uniqBy, uniqWith, values, wait, waitAll, waitTap, weakEq, when, zip, zipObj, zipWith };
package/package.json CHANGED
@@ -42,7 +42,7 @@
42
42
  "prod": "npm run gentypes && npm run prod:es && npm run prod:cjs",
43
43
  "all": "npm run dev && npm run prod"
44
44
  },
45
- "version": "1.12.2",
45
+ "version": "1.12.3",
46
46
  "devDependencies": {
47
47
  "@rollup/plugin-commonjs": "^29.0.2",
48
48
  "@rollup/plugin-node-resolve": "^16.0.3",
package/src/common.ts CHANGED
@@ -44,5 +44,8 @@ export const includes = curry2(
44
44
  }
45
45
  }
46
46
  )
47
- export { length } from './internal'
47
+ export const always = <T extends any>(s: T) => () => s
48
+ export const identity = <T extends any>(s: T) => s
49
+ export const trim = (s: string) => s.trim()
48
50
 
51
+ export { length } from './internal'
package/src/quick.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { includes, length, type } from "./common"
1
+ import { identity, includes, length, type } from "./common"
2
2
  import { curry2, curry3 } from "./curry"
3
3
  import { AnyFunc, AnyObject, Reducer } from "./types"
4
4
  import { inf, isArray, isFunc, isNil, isNum, isObj, isSafe } from "./utils"
@@ -175,16 +175,19 @@ const rmel = (index: number, xs: any[]) => {
175
175
  return xs
176
176
  }
177
177
  const seen = new Set()
178
- export const quniq = (xs: any[]) => {
179
- seen.clear()
180
- let size = length(xs)
178
+ export const quniqWith = curry2((getter: AnyFunc, xs: any[]) => {
179
+ let size = length(xs), cur: any
181
180
  for(let i=z; i<size; i++) {
182
181
  const x = xs[i]
183
- if(seen.has(x)) {rmel(i, xs); size--; i--}
184
- else seen.add(x)
182
+ cur = getter(x)
183
+ if(seen.has(cur)) {rmel(i, xs); size--; i--}
184
+ else seen.add(cur)
185
185
  }
186
+ seen.clear()
186
187
  return xs
187
- }
188
+ })
189
+ export const quniq = quniqWith(identity)
188
190
 
189
191
  // Aliases.
190
- export const qpush = qappend
192
+ export const qpush = qappend
193
+ export const quniqBy = quniqWith
package/src/safe.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { eq, equals, includes, length, symbol, type } from './common'
1
+ import { always, eq, equals, identity, includes, length, symbol, type } from './common'
2
2
  import { __, curry, curry2, curry3 } from './curry'
3
3
  import { is_typed_arr, startsWithWith } from './internal'
4
4
  import { AnyArray, IndexesOfArray, Split } from './internal_types'
@@ -108,9 +108,6 @@ export const find = curry2((fn: Cond, s: any[]) => s.find(fn))
108
108
  export const findIndex = curry2((fn: Cond, s: any[]) => s.findIndex(fn))
109
109
  export const indexOf = curry2((x: any, xs: any[]) => findIndex(equals(x), xs))
110
110
  export const divide = curry2((a: number, b: number) => b/a)
111
- export const always = <T extends any>(s: T) => () => s
112
- export const identity = <T extends any>(s: T) => s
113
- export const trim = (s: string) => s.trim()
114
111
 
115
112
  type T_not = {
116
113
  (x: true): false