pepka 1.6.4 → 1.6.5

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
@@ -78,13 +78,14 @@ const undef = undefined;
78
78
  const nul = null;
79
79
  const inf = Infinity;
80
80
  const to = (s) => typeof s;
81
- const isNull = (s) => s === nul;
82
- const isUndef = (s) => s === undef;
83
- const isNum = (s) => to(s) == 'number';
84
- const isArray = (s) => Array.isArray(s);
85
- const isFunc = (s) => to(s) === 'function';
86
- const isStr = (s) => to(s) === 'string';
87
- const isObj = (s) => !isNull(s) && to(s) === 'object';
81
+ const isNull = (s) => (s === nul);
82
+ const isUndef = (s) => (s === undef);
83
+ const isNum = (s) => (to(s) == 'number');
84
+ const isArray = (s) => (Array.isArray(s));
85
+ function isFunc(s) { return to(s) === 'function'; }
86
+ const isStr = (s) => (to(s) === 'string');
87
+ const isObj = (s) => (!isNull(s) && to(s) === 'object');
88
+ const isNil = (s) => (isNull(s) || isUndef(s));
88
89
 
89
90
  // It's faster that toUpperCase() !
90
91
  const caseMap = { u: 'U', b: 'B', n: 'N', s: 'S', f: 'F' };
@@ -99,7 +100,6 @@ const type = (s) => {
99
100
  };
100
101
  const typeIs = curry2((t, s) => type(s) === t);
101
102
  const length = (s) => s.length;
102
- const isNil = (s) => isNull(s) || isUndef(s);
103
103
  const eq = curry2((a, b) => a === b);
104
104
  const equals = curry2((a, b) => {
105
105
  const typea = type(a);
@@ -281,6 +281,10 @@ const compose = ((...fns) => (...args) => {
281
281
  });
282
282
  const bind = curry2((fn, context) => fn.bind(context));
283
283
  const nth = curry2((i, data) => data[i]);
284
+ // FIXME: these types. Somewhere in curry2.
285
+ // const x = nth(0)([1,2,3])
286
+ // const y = nth(0)('123')
287
+ // const z = nth(0)(new Uint8Array([0,2,3]))
284
288
  const slice = curry3((from, to, o) => o.slice(from, (isNum(to) ? to : inf)));
285
289
  const flip = (fn) => curry2((b, a) => fn(a, b));
286
290
  /** @returns first element of an array or a string. */
@@ -417,7 +421,7 @@ const allPass = curry2((preds, x) => preds.every((pred) => pred(x)));
417
421
  const anyPass = curry2((preds, x) => preds.some((pred) => pred(x)));
418
422
  /** @param key string @param o AnyObject @returns o[key] */
419
423
  const prop = curry2((key, o) => o[key]);
420
- /** @param key string @param value any @param o AnyObject @returns o[key] equals value */
424
+ /** @param key string @param value any @param o AnyObject @returns boolean o[key] equals value */
421
425
  const propEq = curry3((key, value, o) => equals(o[key], value));
422
426
  /** @param key string @param o1 AnyObject @param o2 AnyObject @returns o₁[key] equals o₂[key] */
423
427
  const propsEq = curry3((key, o1, o2) => equals(o1[key], o2[key]));
package/dist/bundle.d.ts CHANGED
@@ -44,7 +44,6 @@ export declare const typeIs: {
44
44
  (a: string, b: any): boolean;
45
45
  };
46
46
  declare const length$1: <T extends AnyArray | string>(s: T) => T extends string ? StrLen<T> : T["length"];
47
- export declare const isNil: (s: any) => boolean;
48
47
  export declare const eq: {
49
48
  (a: symbol, b: any): (a: any) => boolean;
50
49
  (a: any, b: symbol): (b: any) => boolean;
@@ -70,6 +69,7 @@ export declare const qstartsWithWith: (comparator: (x: any, y: any) => boolean)
70
69
  (a: string | any[]): (b: string | any[]) => boolean;
71
70
  (a: string | any[], b: string | any[]): boolean;
72
71
  };
72
+ export declare const isNil: <T extends any>(s: T) => T extends (null | undefined) ? true : false;
73
73
  export declare const take: (argN: number) => (...args: any[]) => any;
74
74
  export declare const ifElse: (...args: AnyArgs) => any;
75
75
  export declare const when: (...args: AnyArgs) => any;
@@ -82,10 +82,10 @@ export declare const bind: {
82
82
  (a: any, b: any): any;
83
83
  };
84
84
  export declare const nth: {
85
- (a: symbol, b: string | any[]): (a: number) => any;
86
- (a: number, b: symbol): (b: string | any[]) => any;
87
- (a: number): (b: string | any[]) => any;
88
- (a: number, b: string | any[]): any;
85
+ (a: symbol, b: string | ArrayLike<unknown>): (a: number) => unknown;
86
+ (a: number, b: symbol): (b: string | ArrayLike<unknown>) => unknown;
87
+ (a: number): (b: string | ArrayLike<unknown>) => unknown;
88
+ (a: number, b: string | ArrayLike<unknown>): unknown;
89
89
  };
90
90
  export declare const slice: (...args: AnyArgs) => any;
91
91
  export declare const flip: <T extends AnyFunc>(fn: T) => {
@@ -382,7 +382,7 @@ export declare const prop: {
382
382
  (a: string): (b: AnyObject) => any;
383
383
  (a: string, b: AnyObject): any;
384
384
  };
385
- /** @param key string @param value any @param o AnyObject @returns o[key] equals value */
385
+ /** @param key string @param value any @param o AnyObject @returns boolean o[key] equals value */
386
386
  export declare const propEq: (...args: AnyArgs) => any;
387
387
  /** @param key string @param o1 AnyObject @param o2 AnyObject @returns o₁[key] equals o₂[key] */
388
388
  export declare const propsEq: (...args: AnyArgs) => any;
@@ -414,10 +414,10 @@ export declare const pickBy: {
414
414
  (a: Cond, b: AnyObject): any;
415
415
  };
416
416
  export declare const omit: {
417
- (a: symbol, b: AnyObject): (a: string[]) => any[] | AnyObject;
418
- (a: string[], b: symbol): (b: AnyObject) => any[] | AnyObject;
419
- (a: string[]): (b: AnyObject) => any[] | AnyObject;
420
- (a: string[], b: AnyObject): any[] | AnyObject;
417
+ (a: symbol, b: AnyObject): (a: string[]) => any;
418
+ (a: string[], b: symbol): (b: AnyObject) => any;
419
+ (a: string[]): (b: AnyObject) => any;
420
+ (a: string[], b: AnyObject): any;
421
421
  };
422
422
  export declare const fromPairs: (pairs: [
423
423
  string,
@@ -460,10 +460,10 @@ export declare const isEmpty: (s: any) => boolean | null;
460
460
  export declare const empty: (s: any) => {} | undefined;
461
461
  export declare const replace: (...args: AnyArgs) => any;
462
462
  export declare const filter: {
463
- (a: symbol, b: any[] | AnyObject): (a: (v: any, k: string | number) => boolean) => any[] | AnyObject;
464
- (a: (v: any, k: string | number) => boolean, b: symbol): (b: any[] | AnyObject) => any[] | AnyObject;
465
- (a: (v: any, k: string | number) => boolean): (b: any[] | AnyObject) => any[] | AnyObject;
466
- (a: (v: any, k: string | number) => boolean, b: any[] | AnyObject): any[] | AnyObject;
463
+ (a: symbol, b: any[] | AnyObject): (a: (v: any, k: string | number) => boolean) => any;
464
+ (a: (v: any, k: string | number) => boolean, b: symbol): (b: any[] | AnyObject) => any;
465
+ (a: (v: any, k: string | number) => boolean): (b: any[] | AnyObject) => any;
466
+ (a: (v: any, k: string | number) => boolean, b: any[] | AnyObject): any;
467
467
  };
468
468
  /** Saves result of a function with given key and avoids calling it again.
469
469
  * @param {(...args: Args) string} keyGen that takes the same args and returns a key for the cache.
package/dist/bundle.mjs CHANGED
@@ -76,13 +76,14 @@ const undef = undefined;
76
76
  const nul = null;
77
77
  const inf = Infinity;
78
78
  const to = (s) => typeof s;
79
- const isNull = (s) => s === nul;
80
- const isUndef = (s) => s === undef;
81
- const isNum = (s) => to(s) == 'number';
82
- const isArray = (s) => Array.isArray(s);
83
- const isFunc = (s) => to(s) === 'function';
84
- const isStr = (s) => to(s) === 'string';
85
- const isObj = (s) => !isNull(s) && to(s) === 'object';
79
+ const isNull = (s) => (s === nul);
80
+ const isUndef = (s) => (s === undef);
81
+ const isNum = (s) => (to(s) == 'number');
82
+ const isArray = (s) => (Array.isArray(s));
83
+ function isFunc(s) { return to(s) === 'function'; }
84
+ const isStr = (s) => (to(s) === 'string');
85
+ const isObj = (s) => (!isNull(s) && to(s) === 'object');
86
+ const isNil = (s) => (isNull(s) || isUndef(s));
86
87
 
87
88
  // It's faster that toUpperCase() !
88
89
  const caseMap = { u: 'U', b: 'B', n: 'N', s: 'S', f: 'F' };
@@ -97,7 +98,6 @@ const type = (s) => {
97
98
  };
98
99
  const typeIs = curry2((t, s) => type(s) === t);
99
100
  const length = (s) => s.length;
100
- const isNil = (s) => isNull(s) || isUndef(s);
101
101
  const eq = curry2((a, b) => a === b);
102
102
  const equals = curry2((a, b) => {
103
103
  const typea = type(a);
@@ -279,6 +279,10 @@ const compose = ((...fns) => (...args) => {
279
279
  });
280
280
  const bind = curry2((fn, context) => fn.bind(context));
281
281
  const nth = curry2((i, data) => data[i]);
282
+ // FIXME: these types. Somewhere in curry2.
283
+ // const x = nth(0)([1,2,3])
284
+ // const y = nth(0)('123')
285
+ // const z = nth(0)(new Uint8Array([0,2,3]))
282
286
  const slice = curry3((from, to, o) => o.slice(from, (isNum(to) ? to : inf)));
283
287
  const flip = (fn) => curry2((b, a) => fn(a, b));
284
288
  /** @returns first element of an array or a string. */
@@ -415,7 +419,7 @@ const allPass = curry2((preds, x) => preds.every((pred) => pred(x)));
415
419
  const anyPass = curry2((preds, x) => preds.some((pred) => pred(x)));
416
420
  /** @param key string @param o AnyObject @returns o[key] */
417
421
  const prop = curry2((key, o) => o[key]);
418
- /** @param key string @param value any @param o AnyObject @returns o[key] equals value */
422
+ /** @param key string @param value any @param o AnyObject @returns boolean o[key] equals value */
419
423
  const propEq = curry3((key, value, o) => equals(o[key], value));
420
424
  /** @param key string @param o1 AnyObject @param o2 AnyObject @returns o₁[key] equals o₂[key] */
421
425
  const propsEq = curry3((key, o1, o2) => equals(o1[key], o2[key]));
package/package.json CHANGED
@@ -41,19 +41,19 @@
41
41
  "prod": "npm run gentypes && npm run prod:es && npm run prod:cjs",
42
42
  "all": "npm run dev && npm run prod"
43
43
  },
44
- "version": "1.6.4",
44
+ "version": "1.6.5",
45
45
  "devDependencies": {
46
- "@rollup/plugin-commonjs": "^28.0.3",
47
- "@rollup/plugin-node-resolve": "^16.0.0",
46
+ "@rollup/plugin-commonjs": "^28.0.6",
47
+ "@rollup/plugin-node-resolve": "^16.0.1",
48
48
  "@rollup/plugin-replace": "^6.0.2",
49
- "@types/node": "^22.13.10",
50
- "cross-env": "^7.0.3",
49
+ "@types/node": "^24.1.0",
50
+ "cross-env": "^10.0.0",
51
51
  "dts-bundle-generator": "^9.5.1",
52
- "rollup": "^4.35.0",
52
+ "rollup": "^4.46.0",
53
53
  "rollup-plugin-typescript2": "^0.36.0",
54
54
  "ts-node": "^10.9.2",
55
55
  "tslint": "^6.1.3",
56
- "typescript": "^5.8.2"
56
+ "typescript": "^5.8.3"
57
57
  },
58
58
  "sideEffects": false
59
59
  }
package/src/common.ts CHANGED
@@ -18,7 +18,6 @@ export const type = (s: any): string => {
18
18
  export const typeIs = curry2((t: string, s: any) => type(s)===t)
19
19
 
20
20
  export const length = <T extends AnyArray | string>(s: T): T extends string ? StrLen<T> : T["length"] => s.length as any
21
- export const isNil = (s: any) => isNull(s) || isUndef(s)
22
21
  export const eq = curry2((a: any, b: any) => a===b)
23
22
  export const equals = curry2((a: any, b: any) => {
24
23
  const typea = type(a)
package/src/curry.ts CHANGED
@@ -65,11 +65,11 @@ export function curry2<Func extends Func2>(fn: Func) {
65
65
  type p0 = Parameters<Func>[0]
66
66
  type p1 = Parameters<Func>[1]
67
67
  type ReturnT = ReturnType<Func>
68
- function curried2( a: Placeholder, b: p1 ): (a: p0) => ReturnT
69
- function curried2( a: p0, b: Placeholder ): (b: p1) => ReturnT
70
- function curried2( a: p0 ): (b: p1) => ReturnT
71
- function curried2( a: p0, b: p1 ): ReturnT
72
- function curried2( a: p0 | Placeholder, b?: p1 ) {
68
+ function curried2(a: Placeholder, b: p1): (a: p0) => ReturnT
69
+ function curried2(a: p0, b: Placeholder): (b: p1) => ReturnT
70
+ function curried2(a: p0 ): (b: p1) => ReturnT
71
+ function curried2(a: p0, b: p1): ReturnT
72
+ function curried2(a: p0 | Placeholder, b?: p1) {
73
73
  const withPlaceholder1 = a===__
74
74
  const aln = arguments.length
75
75
  if(aln === 1 && withPlaceholder1)
package/src/quick.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { curry2, curry3 } from "./curry"
2
- import { includes, isNil, type, eq, qstartsWithWith } from "./common"
2
+ import { includes, type, eq, qstartsWithWith } from "./common"
3
3
  import { AnyObject, Reducer, AnyFunc } from "./types"
4
- import { isFunc, isArray, isObj } from "./utils"
4
+ import { isFunc, isArray, isObj, isNil } from "./utils"
5
5
  /* Then next fns seem to be excess due to their safe ver performance should be the same or better:
6
6
  * qflat, qpick
7
7
  */
package/src/safe.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  import { __, curry, curry2, curry3 } from './curry'
2
- import { isNum, undef, isArray, isFunc, isObj, inf } from './utils'
3
- import { qmergeDeep, qreduce, qappend, qmapKeys, qmergeDeepX, qmergeDeepAdd, qfilter, qfreeze, qfreezeShallow, qmapObj, qsort } from './quick'
2
+ import { isNum, undef, isArray, isFunc, isObj, inf, isNil } from './utils'
3
+ import { qmergeDeep, qreduce, qappend, qmapKeys, qmergeDeepX, qmergeDeepAdd, qfilter, qfreeze, qfreezeShallow, qmapObj } from './quick'
4
4
  import { AnyFunc, Cond, AnyObject, Reducer } from './types'
5
- import { symbol, type, length, equals, includes, isNil, qstartsWithWith, eq } from './common'
5
+ import { symbol, type, length, equals, includes, qstartsWithWith, eq } from './common'
6
6
  import { Split, AnyArray, IndexesOfArray } from './internal_types'
7
7
  import { is_typed_arr } from './internal'
8
8
  // TODO: over, lensProp. propsEq is up to 20x slow due to deep equals.
@@ -40,7 +40,11 @@ export const compose = (
40
40
  }
41
41
  )
42
42
  export const bind = curry2<AnyFunc>((fn: AnyFunc, context: any) => fn.bind(context))
43
- export const nth = curry2((i: number, data: any[] | string) => data[i])
43
+ export const nth = curry2(<T extends any>(i: number, data: string | ArrayLike<T>) => data[i])
44
+ // FIXME: these types. Somewhere in curry2.
45
+ // const x = nth(0)([1,2,3])
46
+ // const y = nth(0)('123')
47
+ // const z = nth(0)(new Uint8Array([0,2,3]))
44
48
  export const slice = curry3(
45
49
  (from: number, to: number, o: any[] | string) =>
46
50
  o.slice(from, (isNum(to)?to:inf) as number)
@@ -234,7 +238,7 @@ export const allPass = curry2((preds: Cond[], x: any) => preds.every((pred) => p
234
238
  export const anyPass = curry2((preds: Cond[], x: any) => preds.some((pred) => pred(x)))
235
239
  /** @param key string @param o AnyObject @returns o[key] */
236
240
  export const prop = curry2((key: string, o: AnyObject) => o[key])
237
- /** @param key string @param value any @param o AnyObject @returns o[key] equals value */
241
+ /** @param key string @param value any @param o AnyObject @returns boolean o[key] equals value */
238
242
  export const propEq = curry3(
239
243
  (key: string, value: any, o: AnyObject) => equals(o[key], value)
240
244
  )
@@ -418,7 +422,8 @@ export const zipWith = curry3(
418
422
  )
419
423
 
420
424
  // Reexport safe stuff that is ready to use externally.
421
- export { toLower, toUpper, type, typeIs, length, isNil, eq, equals, includes } from './common'
425
+ export { toLower, toUpper, type, typeIs, length, eq, equals, includes } from './common'
426
+ export { isNil } from './utils'
422
427
 
423
428
  // ALIASES
424
429
  export const mirror = identity
package/src/utils.ts CHANGED
@@ -1,13 +1,16 @@
1
-
1
+ import { AnyFunc, AnyObject } from "./types"
2
2
 
3
3
  export const undef = undefined
4
4
  export const nul = null
5
5
  export const inf = Infinity
6
6
  export const to = (s: any) => typeof s
7
- export const isNull = (s: any) => s===nul
8
- export const isUndef = (s: any) => s===undef
9
- export const isNum = (s: any) => to(s)=='number'
10
- export const isArray = (s: any) => Array.isArray(s)
11
- export const isFunc = (s: any) => to(s)==='function'
12
- export const isStr = (s: any) => to(s)==='string'
13
- export const isObj = (s: any) => !isNull(s) && to(s)==='object'
7
+ export const isNull = <T extends any>(s: T) => (s===nul) as T extends null ? true : false
8
+ export const isUndef = <T extends any>(s: T) => (s===undef) as T extends undefined ? true : false
9
+ export const isNum = <T extends any>(s: T) => (to(s)=='number') as T extends number ? true : false
10
+ export const isArray = <T extends any>(s: T) => (Array.isArray(s)) as T extends any[] ? true : false
11
+ export function isFunc<T extends AnyFunc>(value: T): true
12
+ export function isFunc(value: any): false
13
+ export function isFunc(s: any) { return to(s)==='function' }
14
+ export const isStr = <T extends any>(s: T) => (to(s)==='string') as T extends string ? true : false
15
+ export const isObj = <T extends any>(s: T) => (!isNull(s) && to(s)==='object') as T extends AnyObject ? true : false
16
+ export const isNil = <T extends any>(s: T) => (isNull(s) || isUndef(s)) as T extends (null|undefined) ? true : false