pepka 0.14.0-beta5 → 0.14.0-beta8

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.d.ts CHANGED
@@ -9,9 +9,8 @@ export interface AnyObject {
9
9
  }
10
10
  export type AnyArgs = any[];
11
11
  export type Curried<Args extends AnyArgs = AnyArgs, ReturnT = any> = (arg: Args[number]) => Curried<Args> | ReturnT;
12
- export type Reducer = <T = any>(accum: T, cur: any, index: number) => T;
12
+ export type Reducer<T = any> = (accum: T, cur: any, index: number) => T;
13
13
  export type AnyFunc<ReturnT = any, Args extends AnyArgs = AnyArgs> = (...args: Args) => ReturnT;
14
- export type TupleFn<ARG1 = any, ARG2 = any, Out = any> = (a: ARG1, b: ARG2) => Out;
15
14
  export type Placeholder = symbol;
16
15
  declare const __: Placeholder;
17
16
  export declare const curry: <Func extends AnyFunc<any, AnyArgs>>(fn: AnyFunc) => FT.Curry<Func>;
@@ -64,7 +63,12 @@ export declare const includes: {
64
63
  (a: unknown, b: unknown[]): boolean;
65
64
  };
66
65
  export declare const slice: FT.Curry<(from: number, to: number, o: any[] | string) => string | any[]>;
67
- export declare const flip: <ARG1 = any, ARG2 = any, Out = any>(fn: FT.Curry<TupleFn<ARG1, ARG2, Out>>) => FT.Curry<TupleFn<ARG2, ARG1, Out>>;
66
+ export declare const flip: <T extends AnyFunc<any, AnyArgs>>(fn: T) => {
67
+ (a: symbol, b: Parameters<T>[0]): (a: Parameters<T>[1]) => any;
68
+ (a: Parameters<T>[1], b: symbol): (b: Parameters<T>[0]) => any;
69
+ (a: Parameters<T>[1]): (b: Parameters<T>[0]) => any;
70
+ (a: Parameters<T>[1], b: Parameters<T>[0]): any;
71
+ };
68
72
  export declare const head: (b: string | unknown[]) => unknown;
69
73
  export declare const tail: FT.Curry<(o: string | any[]) => string | any[]>;
70
74
  export declare const add: {
@@ -262,10 +266,10 @@ export declare const pathEq: FT.Curry<(_path: string[], value: any, o: AnyObject
262
266
  export declare const pathsEq: FT.Curry<(_path: string[], o1: AnyObject, o2: AnyObject) => (a: any) => boolean>;
263
267
  export declare const clone: (s: any, shallow?: boolean) => any;
264
268
  export declare const cloneShallow: (s: any) => any;
265
- export declare const reduce: FT.Curry<(fn: Reducer, accum: any, arr: any[]) => FT.Curry<(...p: [
269
+ export declare const reduce: FT.Curry<(<T = any>(fn: Reducer<T>, accum: T, arr: any[]) => FT.Curry<(...p: [
266
270
  ] | [
267
271
  accum: any
268
- ]) => any>>;
272
+ ]) => any>)>;
269
273
  export declare const pickBy: {
270
274
  (a: symbol, b: AnyObject): (a: Cond) => any;
271
275
  (a: Cond, b: symbol): (b: AnyObject) => any;
@@ -287,7 +291,7 @@ export declare const omit: {
287
291
  export declare const fromPairs: (pairs: [
288
292
  string,
289
293
  any
290
- ][]) => FT.Curry<(fn: Reducer, accum: any, arr: any[]) => FT.Curry<(...p: [
294
+ ][]) => FT.Curry<(fn: Reducer<unknown>, accum: unknown, arr: any[]) => FT.Curry<(...p: [
291
295
  ] | [
292
296
  accum: any
293
297
  ]) => any>>;
package/package.json CHANGED
@@ -44,7 +44,7 @@
44
44
  "prod": "npm run gentypes && npm run prod:es && npm run prod:cjs",
45
45
  "all": "npm run dev && npm run prod"
46
46
  },
47
- "version": "0.14.0-beta5",
47
+ "version": "0.14.0-beta8",
48
48
  "ava": {
49
49
  "files": [ "./test/specs/*.ts" ],
50
50
  "failFast": true,
package/src/safe.ts CHANGED
@@ -87,10 +87,10 @@ export const slice = curry3(
87
87
  (from: number, to: number, o: any[] | string) =>
88
88
  o.slice(from, (isNum(to)?to:inf) as number)
89
89
  )
90
- export const flip = <ARG1=any, ARG2=any, Out=any>(
91
- fn: FT.Curry<TupleFn<ARG1, ARG2, Out>>
92
- ): FT.Curry<TupleFn<ARG2, ARG1, Out>> =>
93
- curry2((b: ARG2, a: ARG1) => fn(a as any, b as any))
90
+ export const flip =
91
+ <T extends AnyFunc>(fn: T) => curry2(
92
+ (b: Parameters<T>[1], a: Parameters<T>[0]) => fn(a, b)
93
+ )
94
94
  export const head = nth(0)
95
95
  export const tail = slice(1, inf) // typeshit.
96
96
  export const add = curry2((n: number, m: number) => n+m)
@@ -259,7 +259,7 @@ export const clone = (s: any, shallow = false) => {
259
259
  export const cloneShallow = (s: any) => clone(s, true)
260
260
 
261
261
  export const reduce = curry3(
262
- (fn: Reducer, accum: any, arr: any[]) =>
262
+ <T = any>(fn: Reducer<T>, accum: T, arr: any[]) =>
263
263
  qreduce(fn, clone(accum), arr)
264
264
  )
265
265
  export const pickBy = curry2(
package/src/types.ts CHANGED
@@ -7,7 +7,7 @@ export type Curried<
7
7
  Args extends AnyArgs = AnyArgs,
8
8
  ReturnT = any
9
9
  > = (arg: Args[number]) => Curried<Args> | ReturnT
10
- export type Reducer = <T=any>(accum: T, cur: any, index: number) => T
10
+ export type Reducer<T=any> = (accum: T, cur: any, index: number) => T
11
11
  export type AnyFunc<
12
12
  ReturnT = any,
13
13
  Args extends AnyArgs = AnyArgs