pepka 1.0.0-beta.8 → 1.0.0
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 +1 -1
- package/dist/bundle.d.ts +105 -37
- package/dist/bundle.mjs +1 -1
- package/package.json +80 -80
- package/src/curry.ts +0 -1
- package/src/index.ts +2 -1
- package/src/quick.ts +38 -9
- package/src/safe.ts +43 -20
- package/src/timers.ts +18 -0
- package/src/types.ts +5 -10
package/dist/bundle.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const e=Symbol("Placeholder"),r=r=>{let t=0;for(const s of r)s!==e&&t++;return t},t=(r,t)=>{const s=r.length,o=r.slice(),p=t.length;let n=p,
|
|
1
|
+
"use strict";const e=Symbol("Placeholder"),r=r=>{let t=0;for(const s of r)s!==e&&t++;return t},t=(r,t)=>{const s=r.length,o=r.slice(),p=t.length;let n=p,x=0;for(;n&&x<s;x++)o[x]===e&&(o[x]=t[p-n],n--);for(x=s;n;x++,n--)o[x]=t[p-n];return o},s=(e,o,p)=>{const n=e.length-o.length-r(p);if(n<1)return e(...t(o,p));{const r=(...r)=>s(e,t(o,p),r);return r.$args_left=n,r}},o=e=>(...t)=>e.length>r(t)?s(e,[],t):e(...t);function p(r){return function(t,s){const o=t===e;if(1===arguments.length&&o)throw new Error("Senseless placeholder usage.");return arguments.length>1?o?(r=>function(t){return t===e?r:r(t)})((e=>r(e,s))):r(t,s):e=>r(t,e)}}function n(e){return o(e)}const x=void 0,c=1/0,a=e=>typeof e,l=e=>null===e,i=e=>"number"==a(e),u=e=>Array.isArray(e),f=e=>"function"===a(e),h=e=>!l(e)&&"object"===a(e),m={u:"U",b:"B",n:"N",s:"S",f:"F"},d=e=>{const r=a(e);return"object"===r?l(e)?"Null":e.constructor.name:m[r[0]]+r.slice(1)},y=p(((e,r)=>d(r)===e)),g=e=>(...r)=>r[e],b=p(((e,r)=>e===r)),w=p(((e,r)=>e==r)),q=p(((e,r)=>{const t=d(e);if(b(t,d(r))&&(b(t,"Object")||b(t,"Array"))){if(l(e)||l(r))return b(e,r);if(b(e,r))return!0;for(const t of[e,r])for(const s in t)if(!(b(t,r)&&s in e||b(t,e)&&s in r&&q(e[s],r[s])))return!1;return!0}return b(e,r)})),j=o(((e,r,t,s)=>e(s)?r(s):t(s))),O=n(((e,r,t)=>j(e,r,J,t))),A=(...r)=>(...t)=>{let s,o=!0;for(let p=G(r)-1;p>-1;p--)o?(o=!1,s=r[p](...t)):s=s===e?r[p]():r[p](s);return s},S=p(((e,r)=>e.bind(r))),E=p(((e,r)=>r[e])),k=p(((e,r)=>{if((e=>"string"===a(e))(r))return r.includes(e);for(const t of r)if(q(t,e))return!0;return!1})),z=n(((e,r,t)=>t.slice(e,i(r)?r:c))),v=e=>p(((r,t)=>e(t,r))),P=E(0),D=z(1,c),N=p(((e,r)=>e+r)),B=p(((e,r)=>r-e)),T=p(((e,r)=>e*r)),_=p(((e,r)=>e>r)),C=p(((e,r)=>e<r)),F=p(((e,r)=>r>=e)),I=p(((e,r)=>r<=e)),U=p(((e,r)=>r.sort(e))),$=p(((e,r)=>r.find(e))),K=p(((e,r)=>r.findIndex(e))),L=p(((e,r)=>K(q(e),r))),W=p(((e,r)=>e/r)),X=e=>l(e)||(e=>e===x)(e),G=e=>e.length,H=e=>()=>e,J=e=>e,M=e=>!e,Q=p(((e,r)=>e.test(r))),R=p(((e,r)=>(e(r),r))),V=p(((e,r)=>[...r,e])),Y=p(((e,r)=>[...r,e])),Z=p(((e,r)=>r.flat(e))),ee=p(((e,r)=>r.split(e))),re=H(!0),te=H(!1),se=p(((e,r)=>r(...e))),oe=o(((e,r,t)=>t[r](...e))),pe=e=>(...r)=>{const t=e(...r),s=f(t);return!s||s&&t.$args_left<=0?M(t):pe(t)},ne=p(((e,r)=>ce(N(e),r-e))),xe=p(((e,r)=>e.filter(v(k)(r)))),ce=p(((e,r)=>[...Array(r)].map(((r,t)=>e(t))))),ae=p(((e,r)=>{for(const[t,s]of e)if(t(r))return s(r)})),le=n(((e,r,t)=>({...t,[e]:r}))),ie=n(((e,r,t)=>A((s=>le(s,G(e)<2?r:ie(z(1,c,e),r,h(t[s])?t[s]:{}),t)),P)(e))),ue=p(((e,r)=>r.every(e))),fe=p(((e,r)=>r.some(e))),he=p(((e,r)=>e.every((e=>e(r))))),me=p(((e,r)=>e.some((e=>e(r))))),de=p(((e,r)=>r[e])),ye=n(((e,r,t)=>q(t[e],r))),ge=n(((e,r,t)=>q(r[e],t[e]))),be=n(((e,r,t)=>j(G,(()=>X(t)?e:A(j(X,H(e),(t=>be(e,z(1,c,r),t))),v(de)(t),P)(r)),H(t),r))),we=be(x),qe=n(((e,r,t)=>q(we(e,t),r))),je=n(((e,r,t)=>q(we(e,r),we(e,t)))),Oe=/^(.*?)(8|16|32|64)(Clamped)?Array$/,Ae=(e,r=!1)=>{const t=d(e);switch(t){case"Null":case"String":case"Number":case"Boolean":case"Symbol":return e;case"Array":return r?[...e]:De(A(Ae,g(0)),e);case"Object":if(r)return{...e};const s={};for(let r in e)s[r]=Ae(e[r]);return s;default:return Oe.test(t)?e.constructor.from(e):e}},Se=n(((e,r,t)=>sr(e,Ae(r),t))),Ee=p(((e,r)=>_e(e,r))),ke=p(((e,r)=>{const t={};for(const s of e)s in r&&(t[s]=r[s]);return t})),ze=p(((e,r)=>_e(((r,t)=>!k(t,e)),r))),ve=p(((e,r)=>r.concat(e))),Pe=p(((e,r)=>r.join(e))),De=p(((e,r)=>r.map(e))),Ne=p(((e,r)=>r.forEach(e))),Be=n(((e,r,t)=>r(t)&&e(t))),Te=n(((e,r,t)=>t.replace(e,r))),_e=p(((e,r)=>u(r)?r.filter(e):ir(e,{...r}))),Ce=p(((e,r)=>Object.assign({},e,r))),Fe=p(((e,r)=>pr(Ae(e),Ae(r)))),Ie=p(((e,r)=>nr(Ae(e),Ae(r)))),Ue=p(((e,r)=>xr(Ae(e),Ae(r)))),$e=n(((e,r,t)=>le(e,r(t[e]),t))),Ke=p(((e,r)=>ar(e,Object.assign({},r)))),Le=p(((e,r)=>De(((e,t)=>[e,r[t]]),e))),We=p(((e,r)=>Se(((e,t,s)=>le(t,r[s],e)),{},e))),Xe=n(((e,r,t)=>De(((r,s)=>e(r,t[s])),r))),Ge=(()=>{const e=async(r,t,s)=>{s<t.length&&(await r(t[s]),await e(r,t,++s))};return p(((r,t)=>e(r,t,0)))})(),He=p((async(e,r)=>(await e(r),r))),Je=p(((e,r)=>Promise.all(r.map(e)))),Me=(()=>{const e=async(r,t,s)=>~s?await e(r,[await r[s](...t)],--s):P(t);return(...r)=>(...t)=>e(r,t,r.length-1)})(),Qe=J,Re=J,Ve=J,Ye=pe,Ze=V,er=fe,rr=p(((e,r)=>(r.push(e),r))),tr=n(((e,r,t)=>(t[e]=r,t))),sr=n(((e,r,t)=>t.reduce(e,r))),or=n(((e,r,t)=>{for(let s in t)switch(d(t[s])){case"Array":if(e>1&&"Array"===d(r[s]))switch(e){case 2:const o=r[s],p=t[s];for(const r in p)o[r]?or(e,o[r],p[r]):o[r]=p[r];break;case 3:r[s].push(...t[s])}else r[s]=t[s];break;case"Object":if("Object"===d(r[s])){or(e,r[s],t[s]);break}default:r[s]=t[s]}return r})),pr=or(1),nr=or(2),xr=or(3),cr=p(((e,r)=>Object.assign(e,r))),ar=p(((e,r)=>{let t,s,o,p;for(t in e)t in r&&(s=e[t],[o,p]=f(s)?s(r[t],t,r):[s,r[t]],r[X(o)?t:o]=p,t!==o&&delete r[t]);return r})),lr=p(((e,r)=>{for(let t in r)r[t]=e(r[t],+t,r);return r})),ir=p(((e,r)=>{const t=u(r);let s,o;t&&(s=0,o=[]);for(let s in r)e(r[s],s)||(t?o.push(+s):delete r[s]);if(t)for(const e of o)r.splice(e-s++,1);return r})),ur=e=>{let r;for(const t in e)r=e[t],h(r)&&ur(r);return Object.freeze(e)},fr=e=>Object.freeze(e),hr=p(((e,r)=>r.unshift(e))),mr=n(((e,r,t)=>{const s=e[0];return tr(s,e.length<2?r:mr(e.slice(1),r,h(t[s])?t[s]:{}),t)})),dr=p(((e,r)=>ir(((r,t)=>!k(t,e)),r)));exports.F=te,exports.T=re,exports.__=e,exports.add=N,exports.all=ue,exports.allPass=he,exports.always=H,exports.any=fe,exports.anyPass=me,exports.append=V,exports.assoc=le,exports.assocPath=ie,exports.bind=S,exports.both=Be,exports.callFrom=oe,exports.callWith=se,exports.clone=Ae,exports.cloneShallow=e=>Ae(e,!0),exports.complement=pe,exports.compose=A,exports.composeAsync=Me,exports.concat=ve,exports.cond=ae,exports.curry=o,exports.curry2=p,exports.curry3=n,exports.divide=W,exports.echo=Ve,exports.empty=e=>{switch(d(e)){case"String":return"";case"Object":return{};case"Array":return[];default:return x}},exports.eq=b,exports.equals=q,exports.explore=(e,r="log")=>R((t=>console[r](e,t))),exports.filter=_e,exports.find=$,exports.findIndex=K,exports.flat=e=>e.flat(c),exports.flatShallow=e=>e.flat(),exports.flatTo=Z,exports.flip=v,exports.forEach=Ne,exports.forEachAsync=Je,exports.forEachSerial=Ge,exports.freeze=e=>ur(Ae(e)),exports.freezeShallow=e=>fr(Ae(e)),exports.fromPairs=e=>Object.fromEntries(e),exports.genBy=ce,exports.getTmpl=e=>{const r=[],t=[],s=e.length;let o,p,n,x=0,c=0,a=!1,l=P(e),i=!1;for(x=0;x<s;x++)switch(o=e[x],o){case"{":if(!l){a=!0,c=x;break}case"}":if(!l){a=!1,r.push(""),t.push(e.slice(c+1,x));break}default:n=e[x+1],i="\\"===o,a||i&&("{"===n||"}"===n)||(p=r.length-1,p<0&&(r.push(""),p++),r[p]+=o),l=i}return e=>{const s=[],o=r.length-1;for(const p in r)x=+p,s.push(r[x]),x!==o&&s.push(we(t[x].split("."),e));return s.join("")}},exports.gt=_,exports.gte=F,exports.head=P,exports.identity=J,exports.ifElse=j,exports.includes=k,exports.indexOf=L,exports.intersection=xe,exports.isEmpty=e=>{switch(d(e)){case"String":case"Array":return 0==G(e);case"Object":for(const r in e)return!1;return!0;default:return null}},exports.isNil=X,exports.join=Pe,exports.keys=e=>Object.keys(e),exports.last=e=>e[G(e)-1],exports.length=G,exports.lt=C,exports.lte=I,exports.map=De,exports.mapKeys=Ke,exports.memoize=e=>{let r,t=!1;return()=>t?r:(t=!0,r=e())},exports.mergeDeep=Fe,exports.mergeDeepAdd=Ue,exports.mergeDeepX=Ie,exports.mergeShallow=Ce,exports.mirror=Qe,exports.multiply=T,exports.noop=()=>{},exports.not=M,exports.notf=Ye,exports.nth=E,exports.omit=ze,exports.once=e=>{let r,t=!1;return(...s)=>t?r:(t=!0,r=e(...s))},exports.overProp=$e,exports.path=we,exports.pathEq=qe,exports.pathOr=be,exports.pathsEq=je,exports.pick=ke,exports.pickBy=Ee,exports.prepend=Y,exports.prop=de,exports.propEq=ye,exports.propsEq=ge,exports.push=Ze,exports.qappend=rr,exports.qassoc=tr,exports.qassocPath=mr,exports.qempty=e=>{if(u(e))e.splice(0);else for(const r in e)delete e[r];return e},exports.qfilter=ir,exports.qfreeze=ur,exports.qfreezeShallow=fr,exports.qmap=lr,exports.qmapKeys=ar,exports.qmergeDeep=pr,exports.qmergeDeepAdd=xr,exports.qmergeDeepX=nr,exports.qmergeShallow=cr,exports.qomit=dr,exports.qprepend=hr,exports.qreduce=sr,exports.qreverse=e=>e.reverse(),exports.range=ne,exports.reduce=Se,exports.reflect=Re,exports.replace=Te,exports.reverse=e=>A((r=>Se(((t,s,o)=>rr(e[r-o],t)),[],e)),N(-1),G)(e),exports.sizeof=e=>{if("Object"===d(e)){let r=0;for(let t in e)r++;return r}return G(e)},exports.slice=z,exports.some=er,exports.sort=U,exports.split=ee,exports.subtract=B,exports.tail=D,exports.take=g,exports.tap=R,exports.test=Q,exports.toLower=e=>e.toLowerCase(),exports.toPairs=e=>Object.entries(e),exports.toUpper=e=>e.toUpperCase(),exports.trim=e=>e.trim(),exports.type=d,exports.typeIs=y,exports.uncurry=e=>(...r)=>sr(((e,r)=>e?e(r):e),e,r),exports.uniq=e=>sr(((e,r)=>k(r,e)?e:rr(r,e)),[],e),exports.values=e=>Object.values(e),exports.waitAll=e=>Promise.all(e),exports.waitTap=He,exports.weakEq=w,exports.when=O,exports.zip=Le,exports.zipObj=We,exports.zipWith=Xe;
|
package/dist/bundle.d.ts
CHANGED
|
@@ -1,27 +1,29 @@
|
|
|
1
1
|
export { __ }
|
|
2
2
|
|
|
3
|
-
// Generated by dts-bundle-generator
|
|
3
|
+
// Generated by dts-bundle-generator v9.3.1
|
|
4
4
|
|
|
5
5
|
export type Cond = (x1?: any, x2?: any, x3?: any) => boolean;
|
|
6
6
|
export interface AnyObject {
|
|
7
7
|
[k: string]: any;
|
|
8
8
|
}
|
|
9
9
|
export type AnyArgs = any[];
|
|
10
|
-
export type
|
|
10
|
+
export type Reducer<T = any> = (accum: T, cur: any, index: number) => T;
|
|
11
11
|
export type AnyFunc<ReturnT = any, Args extends AnyArgs = AnyArgs> = (...args: Args) => ReturnT;
|
|
12
|
-
export type
|
|
13
|
-
|
|
12
|
+
export type TupleFn<ARG1 = any, ARG2 = any, Out = any> = (a: ARG1, b: ARG2) => Out;
|
|
13
|
+
export type Curried<Args extends AnyArgs = AnyArgs, ReturnT = any> = (arg: Args[number]) => Curried<Args> | ReturnT;
|
|
14
|
+
type Placeholder = symbol;
|
|
15
|
+
export declare const __: Placeholder;
|
|
14
16
|
export declare const curry: (fn: AnyFunc) => (...args: AnyArgs) => any;
|
|
15
|
-
|
|
17
|
+
type Func2 = (a: any, b: any) => any;
|
|
16
18
|
export declare function curry2<Func extends Func2>(fn: Func): {
|
|
17
19
|
(a: Placeholder, b: Parameters<Func>[1]): (a: Parameters<Func>[0]) => ReturnType<Func>;
|
|
18
20
|
(a: Parameters<Func>[0], b: Placeholder): (b: Parameters<Func>[1]) => ReturnType<Func>;
|
|
19
21
|
(a: Parameters<Func>[0]): (b: Parameters<Func>[1]) => ReturnType<Func>;
|
|
20
22
|
(a: Parameters<Func>[0], b: Parameters<Func>[1]): ReturnType<Func>;
|
|
21
23
|
};
|
|
22
|
-
|
|
24
|
+
type Func3 = (a: any, b: any, c: any) => any;
|
|
23
25
|
export declare function curry3<Func extends Func3>(fn: Func): (...args: AnyArgs) => any;
|
|
24
|
-
export declare const uncurry: <Args extends any[] = any[], ReturnT = any>(fn: Curried<Args
|
|
26
|
+
export declare const uncurry: <Args extends any[] = any[], ReturnT = any>(fn: Curried<Args>) => AnyFunc;
|
|
25
27
|
export declare const toLower: (s: string) => string;
|
|
26
28
|
export declare const toUpper: (s: string) => string;
|
|
27
29
|
export declare const type: (s: any) => any;
|
|
@@ -32,6 +34,18 @@ export declare const typeIs: {
|
|
|
32
34
|
(a: string, b: any): boolean;
|
|
33
35
|
};
|
|
34
36
|
export declare const take: (argN: number) => (...args: any[]) => any;
|
|
37
|
+
export declare const eq: {
|
|
38
|
+
(a: symbol, b: any): (a: any) => boolean;
|
|
39
|
+
(a: any, b: symbol): (b: any) => boolean;
|
|
40
|
+
(a: any): (b: any) => boolean;
|
|
41
|
+
(a: any, b: any): boolean;
|
|
42
|
+
};
|
|
43
|
+
export declare const weakEq: {
|
|
44
|
+
(a: symbol, b: any): (a: any) => boolean;
|
|
45
|
+
(a: any, b: symbol): (b: any) => boolean;
|
|
46
|
+
(a: any): (b: any) => boolean;
|
|
47
|
+
(a: any, b: any): boolean;
|
|
48
|
+
};
|
|
35
49
|
export declare const equals: {
|
|
36
50
|
(a: symbol, b: any): (a: any) => boolean;
|
|
37
51
|
(a: any, b: symbol): (b: any) => boolean;
|
|
@@ -40,7 +54,7 @@ export declare const equals: {
|
|
|
40
54
|
};
|
|
41
55
|
export declare const ifElse: (...args: AnyArgs) => any;
|
|
42
56
|
export declare const when: (...args: AnyArgs) => any;
|
|
43
|
-
|
|
57
|
+
type Composed<TIn extends any[], TOut> = (...xs: TIn) => TOut;
|
|
44
58
|
export declare const compose: <TIn extends any[] = any[], TOut = any>(...fns: AnyFunc[]) => Composed<TIn, TOut>;
|
|
45
59
|
export declare const bind: {
|
|
46
60
|
(a: symbol, b: any): (a: any) => any;
|
|
@@ -61,13 +75,13 @@ export declare const includes: {
|
|
|
61
75
|
(a: unknown, b: unknown[]): boolean;
|
|
62
76
|
};
|
|
63
77
|
export declare const slice: (...args: AnyArgs) => any;
|
|
64
|
-
export declare const flip: <T extends AnyFunc
|
|
78
|
+
export declare const flip: <T extends AnyFunc>(fn: T) => {
|
|
65
79
|
(a: symbol, b: Parameters<T>[0]): (a: Parameters<T>[1]) => any;
|
|
66
80
|
(a: Parameters<T>[1], b: symbol): (b: Parameters<T>[0]) => any;
|
|
67
81
|
(a: Parameters<T>[1]): (b: Parameters<T>[0]) => any;
|
|
68
82
|
(a: Parameters<T>[1], b: Parameters<T>[0]): any;
|
|
69
83
|
};
|
|
70
|
-
export declare const head: <T = any>(xs:
|
|
84
|
+
export declare const head: <T = any>(xs: T[] | string) => T;
|
|
71
85
|
export declare const tail: any;
|
|
72
86
|
export declare const add: {
|
|
73
87
|
(a: symbol, b: number): (a: number) => number;
|
|
@@ -142,13 +156,25 @@ export declare const divide: {
|
|
|
142
156
|
(a: number, b: number): number;
|
|
143
157
|
};
|
|
144
158
|
export declare const isNil: (s: any) => boolean;
|
|
145
|
-
|
|
159
|
+
declare const length$1: (s: any[] | string) => number;
|
|
146
160
|
export declare const always: <T = any>(s: T) => () => T;
|
|
147
161
|
export declare const identity: (s: any) => any;
|
|
148
162
|
export declare const trim: (s: string) => string;
|
|
149
163
|
export declare const last: (s: any[] | string) => any;
|
|
150
|
-
|
|
151
|
-
|
|
164
|
+
type NotOverload = {
|
|
165
|
+
(x: true): false;
|
|
166
|
+
(x: false): true;
|
|
167
|
+
(x: any): boolean;
|
|
168
|
+
};
|
|
169
|
+
export declare const not: NotOverload;
|
|
170
|
+
type IndexesOfArray<A> = Exclude<keyof A, keyof [
|
|
171
|
+
]>;
|
|
172
|
+
type KeysOverload = {
|
|
173
|
+
<T extends any[]>(o: T): string[];
|
|
174
|
+
<T extends readonly any[]>(o: T): IndexesOfArray<T>[];
|
|
175
|
+
<T extends AnyObject>(o: T): (keyof T)[];
|
|
176
|
+
};
|
|
177
|
+
export declare const keys: KeysOverload;
|
|
152
178
|
export declare const values: (o: AnyObject | any[]) => any[];
|
|
153
179
|
export declare const toPairs: (o: AnyObject | any[]) => [
|
|
154
180
|
string,
|
|
@@ -172,6 +198,20 @@ export declare const append: {
|
|
|
172
198
|
(a: any): (b: any[]) => any[];
|
|
173
199
|
(a: any, b: any[]): any[];
|
|
174
200
|
};
|
|
201
|
+
export declare const prepend: {
|
|
202
|
+
(a: symbol, b: any[]): (a: any) => any[];
|
|
203
|
+
(a: any, b: symbol): (b: any[]) => any[];
|
|
204
|
+
(a: any): (b: any[]) => any[];
|
|
205
|
+
(a: any, b: any[]): any[];
|
|
206
|
+
};
|
|
207
|
+
export declare const flat: (xs: any[]) => any[];
|
|
208
|
+
export declare const flatShallow: (xs: any[]) => any[];
|
|
209
|
+
export declare const flatTo: {
|
|
210
|
+
(a: symbol, b: any[]): (a: number) => any[];
|
|
211
|
+
(a: number, b: symbol): (b: any[]) => any[];
|
|
212
|
+
(a: number): (b: any[]) => any[];
|
|
213
|
+
(a: number, b: any[]): any[];
|
|
214
|
+
};
|
|
175
215
|
export declare const split: {
|
|
176
216
|
(a: symbol, b: string): (a: string | RegExp) => string[];
|
|
177
217
|
(a: string | RegExp, b: symbol): (b: string) => string[];
|
|
@@ -181,12 +221,17 @@ export declare const split: {
|
|
|
181
221
|
export declare const T: (...args: any[]) => true;
|
|
182
222
|
export declare const F: (...args: any[]) => false;
|
|
183
223
|
export declare const callWith: {
|
|
184
|
-
(a: symbol, b: AnyFunc
|
|
185
|
-
(a: any[], b: symbol): (b: AnyFunc
|
|
186
|
-
(a: any[]): (b: AnyFunc
|
|
187
|
-
(a: any[], b: AnyFunc
|
|
188
|
-
};
|
|
189
|
-
export declare const noop: (...
|
|
224
|
+
(a: symbol, b: AnyFunc): (a: any[]) => any;
|
|
225
|
+
(a: any[], b: symbol): (b: AnyFunc) => any;
|
|
226
|
+
(a: any[]): (b: AnyFunc) => any;
|
|
227
|
+
(a: any[], b: AnyFunc): any;
|
|
228
|
+
};
|
|
229
|
+
export declare const noop: (...args: any[]) => any;
|
|
230
|
+
/** Calls a func from object.
|
|
231
|
+
* @param {any[]} [args] - arguments for the function.
|
|
232
|
+
* @param {string} [fnName] - property name of the function.
|
|
233
|
+
* @param {AnyObject} [o] - the object with the function. */
|
|
234
|
+
export declare const callFrom: (...args: AnyArgs) => any;
|
|
190
235
|
export declare const complement: (fn: AnyFunc) => (...args: any) => boolean | any;
|
|
191
236
|
export declare const sizeof: (s: any[] | string | AnyObject) => number;
|
|
192
237
|
export declare const range: {
|
|
@@ -208,7 +253,7 @@ export declare const genBy: {
|
|
|
208
253
|
(a: (i: number) => any): (b: number) => any[];
|
|
209
254
|
(a: (i: number) => any, b: number): any[];
|
|
210
255
|
};
|
|
211
|
-
export declare const once: <Func extends AnyFunc
|
|
256
|
+
export declare const once: <Func extends AnyFunc>(fn: Func) => (...args: Parameters<Func>) => any;
|
|
212
257
|
export declare const reverse: (xs: any[]) => any;
|
|
213
258
|
export declare const explore: (caption: string, level?: string) => (b: any) => any;
|
|
214
259
|
export declare const cond: {
|
|
@@ -274,6 +319,8 @@ export declare const pathEq: (...args: AnyArgs) => any;
|
|
|
274
319
|
export declare const pathsEq: (...args: AnyArgs) => any;
|
|
275
320
|
export declare const clone: (s: any, shallow?: boolean) => any;
|
|
276
321
|
export declare const cloneShallow: (s: any) => any;
|
|
322
|
+
export declare const freeze: <T extends AnyObject>(o: T) => Readonly<T>;
|
|
323
|
+
export declare const freezeShallow: <T extends AnyObject>(o: T) => Readonly<T>;
|
|
277
324
|
/** types T1, T2
|
|
278
325
|
* @param reducer (accum: T1, current: T2, index: number) => newAccum: T1
|
|
279
326
|
* @param accum T1
|
|
@@ -367,16 +414,16 @@ export declare const overProp: (...args: AnyArgs) => any;
|
|
|
367
414
|
/** mapKeys({ a: 'b' }, { a: 44 }) -> { b: 44 } */
|
|
368
415
|
export declare const mapKeys: {
|
|
369
416
|
(a: symbol, b: AnyObject): (a: {
|
|
370
|
-
[oldKey: string]: string;
|
|
417
|
+
[oldKey: string]: string | AnyFunc;
|
|
371
418
|
}) => AnyObject;
|
|
372
419
|
(a: {
|
|
373
|
-
[oldKey: string]: string;
|
|
420
|
+
[oldKey: string]: string | AnyFunc;
|
|
374
421
|
}, b: symbol): (b: AnyObject) => AnyObject;
|
|
375
422
|
(a: {
|
|
376
|
-
[oldKey: string]: string;
|
|
423
|
+
[oldKey: string]: string | AnyFunc;
|
|
377
424
|
}): (b: AnyObject) => AnyObject;
|
|
378
425
|
(a: {
|
|
379
|
-
[oldKey: string]: string;
|
|
426
|
+
[oldKey: string]: string | AnyFunc;
|
|
380
427
|
}, b: AnyObject): AnyObject;
|
|
381
428
|
};
|
|
382
429
|
export declare const zip: {
|
|
@@ -400,10 +447,10 @@ export declare const zipObj: {
|
|
|
400
447
|
export declare const zipWith: (...args: AnyArgs) => any;
|
|
401
448
|
/** One promise waits for another. */
|
|
402
449
|
export declare const forEachSerial: {
|
|
403
|
-
(a: symbol, b: any[]): (a: AnyFunc
|
|
404
|
-
(a: AnyFunc
|
|
405
|
-
(a: AnyFunc
|
|
406
|
-
(a: AnyFunc
|
|
450
|
+
(a: symbol, b: any[]): (a: AnyFunc) => Promise<void>;
|
|
451
|
+
(a: AnyFunc, b: symbol): (b: any[]) => Promise<void>;
|
|
452
|
+
(a: AnyFunc): (b: any[]) => Promise<void>;
|
|
453
|
+
(a: AnyFunc, b: any[]): Promise<void>;
|
|
407
454
|
};
|
|
408
455
|
/** Promise.all wrapper for functional pipelining. */
|
|
409
456
|
export declare const waitAll: (promises: Promise<any>[]) => Promise<any[]>;
|
|
@@ -413,10 +460,10 @@ export declare const waitAll: (promises: Promise<any>[]) => Promise<any[]>;
|
|
|
413
460
|
* @returns {T}
|
|
414
461
|
*/
|
|
415
462
|
export declare const waitTap: {
|
|
416
|
-
(a: symbol, b: any): (a: AnyFunc
|
|
417
|
-
(a: AnyFunc
|
|
418
|
-
(a: AnyFunc
|
|
419
|
-
(a: AnyFunc
|
|
463
|
+
(a: symbol, b: any): (a: AnyFunc) => Promise<any>;
|
|
464
|
+
(a: AnyFunc, b: symbol): (b: any) => Promise<any>;
|
|
465
|
+
(a: AnyFunc): (b: any) => Promise<any>;
|
|
466
|
+
(a: AnyFunc, b: any): Promise<any>;
|
|
420
467
|
};
|
|
421
468
|
/** Waits for all promises mapped by the fn. */
|
|
422
469
|
export declare const forEachAsync: {
|
|
@@ -463,16 +510,16 @@ export declare const qmergeShallow: {
|
|
|
463
510
|
/** qmapKeys({ a: 'b' }, { a: 44 }) -> { b: 44 } */
|
|
464
511
|
export declare const qmapKeys: {
|
|
465
512
|
(a: symbol, b: AnyObject): (a: {
|
|
466
|
-
[oldKey: string]: string | AnyFunc
|
|
513
|
+
[oldKey: string]: string | AnyFunc;
|
|
467
514
|
}) => AnyObject;
|
|
468
515
|
(a: {
|
|
469
|
-
[oldKey: string]: string | AnyFunc
|
|
516
|
+
[oldKey: string]: string | AnyFunc;
|
|
470
517
|
}, b: symbol): (b: AnyObject) => AnyObject;
|
|
471
518
|
(a: {
|
|
472
|
-
[oldKey: string]: string | AnyFunc
|
|
519
|
+
[oldKey: string]: string | AnyFunc;
|
|
473
520
|
}): (b: AnyObject) => AnyObject;
|
|
474
521
|
(a: {
|
|
475
|
-
[oldKey: string]: string | AnyFunc
|
|
522
|
+
[oldKey: string]: string | AnyFunc;
|
|
476
523
|
}, b: AnyObject): AnyObject;
|
|
477
524
|
};
|
|
478
525
|
export declare const qmap: {
|
|
@@ -487,7 +534,28 @@ export declare const qfilter: {
|
|
|
487
534
|
(a: (v: any, k: string | number) => boolean): (b: any[] | AnyObject) => any[] | AnyObject;
|
|
488
535
|
(a: (v: any, k: string | number) => boolean, b: any[] | AnyObject): any[] | AnyObject;
|
|
489
536
|
};
|
|
490
|
-
export
|
|
537
|
+
export declare const qempty: (o: AnyObject | any[]) => any[] | AnyObject;
|
|
538
|
+
export declare const qfreeze: <T extends AnyObject>(o: T) => Readonly<T>;
|
|
539
|
+
export declare const qfreezeShallow: <T extends AnyObject>(o: T) => Readonly<T>;
|
|
540
|
+
export declare const qprepend: {
|
|
541
|
+
(a: symbol, b: any[]): (a: any) => number;
|
|
542
|
+
(a: any, b: symbol): (b: any[]) => number;
|
|
543
|
+
(a: any): (b: any[]) => number;
|
|
544
|
+
(a: any, b: any[]): number;
|
|
545
|
+
};
|
|
546
|
+
export declare const qassocPath: any;
|
|
547
|
+
export declare const qreverse: (arr: any[]) => any[];
|
|
548
|
+
export declare const qomit: {
|
|
549
|
+
(a: symbol, b: AnyObject): (a: string[]) => any[] | AnyObject;
|
|
550
|
+
(a: string[], b: symbol): (b: AnyObject) => any[] | AnyObject;
|
|
551
|
+
(a: string[]): (b: AnyObject) => any[] | AnyObject;
|
|
552
|
+
(a: string[], b: AnyObject): any[] | AnyObject;
|
|
553
|
+
};
|
|
554
|
+
type StrTmpl = ((data: AnyObject) => string);
|
|
491
555
|
export declare const getTmpl: (tmpl: string) => StrTmpl;
|
|
492
556
|
|
|
557
|
+
export {
|
|
558
|
+
length$1 as length,
|
|
559
|
+
};
|
|
560
|
+
|
|
493
561
|
export {};
|
package/dist/bundle.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const e=Symbol("Placeholder"),r=r=>{let t=0;for(const n of r)n!==e&&t++;return t},t=(r,t)=>{const n=r.length,s=r.slice(),c=t.length;let o=c,
|
|
1
|
+
const e=Symbol("Placeholder"),r=r=>{let t=0;for(const n of r)n!==e&&t++;return t},t=(r,t)=>{const n=r.length,s=r.slice(),c=t.length;let o=c,l=0;for(;o&&l<n;l++)s[l]===e&&(s[l]=t[c-o],o--);for(l=n;o;l++,o--)s[l]=t[c-o];return s},n=(e,s,c)=>{const o=e.length-s.length-r(c);if(o<1)return e(...t(s,c));{const r=(...r)=>n(e,t(s,c),r);return r.$args_left=o,r}},s=e=>(...t)=>e.length>r(t)?n(e,[],t):e(...t);function c(r){return function(t,n){const s=t===e;if(1===arguments.length&&s)throw new Error("Senseless placeholder usage.");return arguments.length>1?s?(r=>function(t){return t===e?r:r(t)})((e=>r(e,n))):r(t,n):e=>r(t,e)}}function o(e){return s(e)}const l=void 0,i=1/0,u=e=>typeof e,a=e=>null===e,f=e=>"number"==u(e),h=e=>Array.isArray(e),b=e=>"function"===u(e),g=e=>!a(e)&&"object"===u(e),p={u:"U",b:"B",n:"N",s:"S",f:"F"},j=e=>e.toLowerCase(),y=e=>e.toUpperCase(),d=e=>{const r=u(e);return"object"===r?a(e)?"Null":e.constructor.name:p[r[0]]+r.slice(1)},m=c(((e,r)=>d(r)===e)),O=e=>(...r)=>r[e],w=c(((e,r)=>e===r)),A=c(((e,r)=>e==r)),S=c(((e,r)=>{const t=d(e);if(w(t,d(r))&&(w(t,"Object")||w(t,"Array"))){if(a(e)||a(r))return w(e,r);if(w(e,r))return!0;for(const t of[e,r])for(const n in t)if(!(w(t,r)&&n in e||w(t,e)&&n in r&&S(e[n],r[n])))return!1;return!0}return w(e,r)})),k=s(((e,r,t,n)=>e(n)?r(n):t(n))),v=o(((e,r,t)=>k(e,r,V,t))),N=(...r)=>(...t)=>{let n,s=!0;for(let c=R(r)-1;c>-1;c--)s?(s=!1,n=r[c](...t)):n=n===e?r[c]():r[c](n);return n},C=c(((e,r)=>e.bind(r))),E=c(((e,r)=>r[e])),P=c(((e,r)=>{if((e=>"string"===u(e))(r))return r.includes(e);for(const t of r)if(S(t,e))return!0;return!1})),$=o(((e,r,t)=>t.slice(e,f(r)?r:i))),x=e=>c(((r,t)=>e(t,r))),z=E(0),B=$(1,i),U=c(((e,r)=>e+r)),_=c(((e,r)=>r-e)),D=c(((e,r)=>e*r)),F=c(((e,r)=>e>r)),I=c(((e,r)=>e<r)),L=c(((e,r)=>r>=e)),q=c(((e,r)=>r<=e)),G=c(((e,r)=>r.sort(e))),H=c(((e,r)=>r.find(e))),J=c(((e,r)=>r.findIndex(e))),K=c(((e,r)=>J(S(e),r))),M=c(((e,r)=>e/r)),Q=e=>a(e)||(e=>e===l)(e),R=e=>e.length,T=e=>()=>e,V=e=>e,W=e=>e.trim(),X=e=>e[R(e)-1],Y=e=>!e,Z=e=>Object.keys(e),ee=e=>Object.values(e),re=e=>Object.entries(e),te=c(((e,r)=>e.test(r))),ne=c(((e,r)=>(e(r),r))),se=c(((e,r)=>[...r,e])),ce=c(((e,r)=>[...r,e])),oe=e=>e.flat(i),le=e=>e.flat(),ie=c(((e,r)=>r.flat(e))),ue=c(((e,r)=>r.split(e))),ae=T(!0),fe=T(!1),he=c(((e,r)=>r(...e))),be=()=>{},ge=s(((e,r,t)=>t[r](...e))),pe=e=>(...r)=>{const t=e(...r),n=b(t);return!n||n&&t.$args_left<=0?Y(t):pe(t)},je=e=>{if("Object"===d(e)){let r=0;for(let t in e)r++;return r}return R(e)},ye=c(((e,r)=>Oe(U(e),r-e))),de=e=>Nr(((e,r)=>P(r,e)?e:kr(r,e)),[],e),me=c(((e,r)=>e.filter(x(P)(r)))),Oe=c(((e,r)=>[...Array(r)].map(((r,t)=>e(t))))),we=e=>{let r,t=!1;return(...n)=>t?r:(t=!0,r=e(...n))},Ae=e=>N((r=>Je(((t,n,s)=>kr(e[r-s],t)),[],e)),U(-1),R)(e),Se=(e,r="log")=>ne((t=>console[r](e,t))),ke=c(((e,r)=>{for(const[t,n]of e)if(t(r))return n(r)})),ve=o(((e,r,t)=>({...t,[e]:r}))),Ne=o(((e,r,t)=>N((n=>ve(n,R(e)<2?r:Ne($(1,i,e),r,g(t[n])?t[n]:{}),t)),z)(e))),Ce=c(((e,r)=>r.every(e))),Ee=c(((e,r)=>r.some(e))),Pe=c(((e,r)=>e.every((e=>e(r))))),$e=c(((e,r)=>e.some((e=>e(r))))),xe=c(((e,r)=>r[e])),ze=o(((e,r,t)=>S(t[e],r))),Be=o(((e,r,t)=>S(r[e],t[e]))),Ue=o(((e,r,t)=>k(R,(()=>Q(t)?e:N(k(Q,T(e),(t=>Ue(e,$(1,i,r),t))),x(xe)(t),z)(r)),T(t),r))),_e=Ue(l),De=o(((e,r,t)=>S(_e(e,t),r))),Fe=o(((e,r,t)=>S(_e(e,r),_e(e,t)))),Ie=/^(.*?)(8|16|32|64)(Clamped)?Array$/,Le=(e,r=!1)=>{const t=d(e);switch(t){case"Null":case"String":case"Number":case"Boolean":case"Symbol":return e;case"Array":return r?[...e]:We(N(Le,O(0)),e);case"Object":if(r)return{...e};const n={};for(let r in e)n[r]=Le(e[r]);return n;default:return Ie.test(t)?e.constructor.from(e):e}},qe=e=>Le(e,!0),Ge=e=>Dr(Le(e)),He=e=>Fr(Le(e)),Je=o(((e,r,t)=>Nr(e,Le(r),t))),Ke=c(((e,r)=>tr(e,r))),Me=c(((e,r)=>{const t={};for(const n of e)n in r&&(t[n]=r[n]);return t})),Qe=c(((e,r)=>tr(((r,t)=>!P(t,e)),r))),Re=e=>Object.fromEntries(e),Te=c(((e,r)=>r.concat(e))),Ve=c(((e,r)=>r.join(e))),We=c(((e,r)=>r.map(e))),Xe=c(((e,r)=>r.forEach(e))),Ye=o(((e,r,t)=>r(t)&&e(t))),Ze=e=>{switch(d(e)){case"String":case"Array":return 0==R(e);case"Object":for(const r in e)return!1;return!0;default:return null}},er=e=>{switch(d(e)){case"String":return"";case"Object":return{};case"Array":return[];default:return l}},rr=o(((e,r,t)=>t.replace(e,r))),tr=c(((e,r)=>h(r)?r.filter(e):Ur(e,{...r}))),nr=e=>{let r,t=!1;return()=>t?r:(t=!0,r=e())},sr=c(((e,r)=>Object.assign({},e,r))),cr=c(((e,r)=>Er(Le(e),Le(r)))),or=c(((e,r)=>Pr(Le(e),Le(r)))),lr=c(((e,r)=>$r(Le(e),Le(r)))),ir=o(((e,r,t)=>ve(e,r(t[e]),t))),ur=c(((e,r)=>zr(e,Object.assign({},r)))),ar=c(((e,r)=>We(((e,t)=>[e,r[t]]),e))),fr=c(((e,r)=>Je(((e,t,n)=>ve(t,r[n],e)),{},e))),hr=o(((e,r,t)=>We(((r,n)=>e(r,t[n])),r))),br=(()=>{const e=async(r,t,n)=>{n<t.length&&(await r(t[n]),await e(r,t,++n))};return c(((r,t)=>e(r,t,0)))})(),gr=e=>Promise.all(e),pr=c((async(e,r)=>(await e(r),r))),jr=c(((e,r)=>Promise.all(r.map(e)))),yr=(()=>{const e=async(r,t,n)=>~n?await e(r,[await r[n](...t)],--n):z(t);return(...r)=>(...t)=>e(r,t,r.length-1)})(),dr=V,mr=V,Or=V,wr=pe,Ar=se,Sr=Ee,kr=c(((e,r)=>(r.push(e),r))),vr=o(((e,r,t)=>(t[e]=r,t))),Nr=o(((e,r,t)=>t.reduce(e,r))),Cr=o(((e,r,t)=>{for(let n in t)switch(d(t[n])){case"Array":if(e>1&&"Array"===d(r[n]))switch(e){case 2:const s=r[n],c=t[n];for(const r in c)s[r]?Cr(e,s[r],c[r]):s[r]=c[r];break;case 3:r[n].push(...t[n])}else r[n]=t[n];break;case"Object":if("Object"===d(r[n])){Cr(e,r[n],t[n]);break}default:r[n]=t[n]}return r})),Er=Cr(1),Pr=Cr(2),$r=Cr(3),xr=c(((e,r)=>Object.assign(e,r))),zr=c(((e,r)=>{let t,n,s,c;for(t in e)t in r&&(n=e[t],[s,c]=b(n)?n(r[t],t,r):[n,r[t]],r[Q(s)?t:s]=c,t!==s&&delete r[t]);return r})),Br=c(((e,r)=>{for(let t in r)r[t]=e(r[t],+t,r);return r})),Ur=c(((e,r)=>{const t=h(r);let n,s;t&&(n=0,s=[]);for(let n in r)e(r[n],n)||(t?s.push(+n):delete r[n]);if(t)for(const e of s)r.splice(e-n++,1);return r})),_r=e=>{if(h(e))e.splice(0);else for(const r in e)delete e[r];return e},Dr=e=>{let r;for(const t in e)r=e[t],g(r)&&Dr(r);return Object.freeze(e)},Fr=e=>Object.freeze(e),Ir=c(((e,r)=>r.unshift(e))),Lr=o(((e,r,t)=>{const n=e[0];return vr(n,e.length<2?r:Lr(e.slice(1),r,g(t[n])?t[n]:{}),t)})),qr=e=>e.reverse(),Gr=c(((e,r)=>Ur(((r,t)=>!P(t,e)),r))),Hr=e=>(...r)=>Nr(((e,r)=>e?e(r):e),e,r),Jr=e=>{const r=[],t=[],n=e.length;let s,c,o,l=0,i=0,u=!1,a=z(e),f=!1;for(l=0;l<n;l++)switch(s=e[l],s){case"{":if(!a){u=!0,i=l;break}case"}":if(!a){u=!1,r.push(""),t.push(e.slice(i+1,l));break}default:o=e[l+1],f="\\"===s,u||f&&("{"===o||"}"===o)||(c=r.length-1,c<0&&(r.push(""),c++),r[c]+=s),a=f}return e=>{const n=[],s=r.length-1;for(const c in r)l=+c,n.push(r[l]),l!==s&&n.push(_e(t[l].split("."),e));return n.join("")}};export{fe as F,ae as T,e as __,U as add,Ce as all,Pe as allPass,T as always,Ee as any,$e as anyPass,se as append,ve as assoc,Ne as assocPath,C as bind,Ye as both,ge as callFrom,he as callWith,Le as clone,qe as cloneShallow,pe as complement,N as compose,yr as composeAsync,Te as concat,ke as cond,s as curry,c as curry2,o as curry3,M as divide,Or as echo,er as empty,w as eq,S as equals,Se as explore,tr as filter,H as find,J as findIndex,oe as flat,le as flatShallow,ie as flatTo,x as flip,Xe as forEach,jr as forEachAsync,br as forEachSerial,Ge as freeze,He as freezeShallow,Re as fromPairs,Oe as genBy,Jr as getTmpl,F as gt,L as gte,z as head,V as identity,k as ifElse,P as includes,K as indexOf,me as intersection,Ze as isEmpty,Q as isNil,Ve as join,Z as keys,X as last,R as length,I as lt,q as lte,We as map,ur as mapKeys,nr as memoize,cr as mergeDeep,lr as mergeDeepAdd,or as mergeDeepX,sr as mergeShallow,dr as mirror,D as multiply,be as noop,Y as not,wr as notf,E as nth,Qe as omit,we as once,ir as overProp,_e as path,De as pathEq,Ue as pathOr,Fe as pathsEq,Me as pick,Ke as pickBy,ce as prepend,xe as prop,ze as propEq,Be as propsEq,Ar as push,kr as qappend,vr as qassoc,Lr as qassocPath,_r as qempty,Ur as qfilter,Dr as qfreeze,Fr as qfreezeShallow,Br as qmap,zr as qmapKeys,Er as qmergeDeep,$r as qmergeDeepAdd,Pr as qmergeDeepX,xr as qmergeShallow,Gr as qomit,Ir as qprepend,Nr as qreduce,qr as qreverse,ye as range,Je as reduce,mr as reflect,rr as replace,Ae as reverse,je as sizeof,$ as slice,Sr as some,G as sort,ue as split,_ as subtract,B as tail,O as take,ne as tap,te as test,j as toLower,re as toPairs,y as toUpper,W as trim,d as type,m as typeIs,Hr as uncurry,de as uniq,ee as values,gr as waitAll,pr as waitTap,A as weakEq,v as when,ar as zip,fr as zipObj,hr as zipWith};
|
package/package.json
CHANGED
|
@@ -1,80 +1,80 @@
|
|
|
1
|
-
{
|
|
2
|
-
"author": {
|
|
3
|
-
"name": "Michael houd1ni Akiliev"
|
|
4
|
-
},
|
|
5
|
-
"bugs": {
|
|
6
|
-
"url": "https://github.com/houd1ni/pepka/issues"
|
|
7
|
-
},
|
|
8
|
-
"deprecated": false,
|
|
9
|
-
"description": "An ultra lightweight, async or unsafe-speedy ramda alternative.",
|
|
10
|
-
"homepage": "https://houd1ni.github.io/pepka/",
|
|
11
|
-
"keywords": [
|
|
12
|
-
"ramda",
|
|
13
|
-
"functional",
|
|
14
|
-
"fp",
|
|
15
|
-
"pure",
|
|
16
|
-
"strongly-typed",
|
|
17
|
-
"typescript",
|
|
18
|
-
"d.ts"
|
|
19
|
-
],
|
|
20
|
-
"license": "MIT",
|
|
21
|
-
"type": "module",
|
|
22
|
-
"exports": {
|
|
23
|
-
".": {
|
|
24
|
-
"import": "./dist/bundle.mjs",
|
|
25
|
-
"require": "./dist/bundle.cjs"
|
|
26
|
-
}
|
|
27
|
-
},
|
|
28
|
-
"name": "pepka",
|
|
29
|
-
"repository": {
|
|
30
|
-
"type": "git",
|
|
31
|
-
"url": "git+https://github.com/houd1ni/pepka.git"
|
|
32
|
-
},
|
|
33
|
-
"scripts": {
|
|
34
|
-
"lint": "tslint src/*.ts",
|
|
35
|
-
"test": "npm run gentypes && npm run prod:es && ava",
|
|
36
|
-
"test:report": "nyc npm test && nyc report --reporter=text-lcov > coverage.lcov && codecov",
|
|
37
|
-
"test:lazy": "ava",
|
|
38
|
-
"dts-fix": "node dts-fix.js",
|
|
39
|
-
"gentypes": "dts-bundle-generator --no-check -o dist/bundle.d.ts src/index.ts && npm run dts-fix",
|
|
40
|
-
"dev": "cross-env NODE_ENV=development BUILD=es rollup -c",
|
|
41
|
-
"prod:cjs": "cross-env NODE_ENV=production BUILD=cjs rollup -c",
|
|
42
|
-
"prod:es": "cross-env NODE_ENV=production BUILD=es rollup -c",
|
|
43
|
-
"prod": "npm run gentypes && npm run prod:es && npm run prod:cjs",
|
|
44
|
-
"all": "npm run dev && npm run prod"
|
|
45
|
-
},
|
|
46
|
-
"version": "1.0.0
|
|
47
|
-
"ava": {
|
|
48
|
-
"files": [
|
|
49
|
-
"./test/specs/*.ts"
|
|
50
|
-
],
|
|
51
|
-
"failFast": true,
|
|
52
|
-
"timeout": "2m",
|
|
53
|
-
"extensions": [
|
|
54
|
-
"ts"
|
|
55
|
-
],
|
|
56
|
-
"require": [
|
|
57
|
-
"ts-node/register"
|
|
58
|
-
]
|
|
59
|
-
},
|
|
60
|
-
"devDependencies": {
|
|
61
|
-
"@rollup/plugin-commonjs": "^
|
|
62
|
-
"@rollup/plugin-node-resolve": "^15.
|
|
63
|
-
"@rollup/plugin-replace": "^5.0.
|
|
64
|
-
"@rollup/plugin-terser": "^0.
|
|
65
|
-
"@types/node": "^
|
|
66
|
-
"ava": "^
|
|
67
|
-
"codecov": "^3.8.
|
|
68
|
-
"cross-env": "^7.0.3",
|
|
69
|
-
"dts-bundle-generator": "^
|
|
70
|
-
"nyc": "^15.1.0",
|
|
71
|
-
"prepend": "^1.0.2",
|
|
72
|
-
"rollup": "^
|
|
73
|
-
"rollup-plugin-typescript2": "^0.
|
|
74
|
-
"ts-node": "^10.9.
|
|
75
|
-
"tslint": "^6.1.
|
|
76
|
-
"typescript": "^4.
|
|
77
|
-
},
|
|
78
|
-
"types": "./dist/bundle.d.ts",
|
|
79
|
-
"sideEffects": false
|
|
80
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"author": {
|
|
3
|
+
"name": "Michael houd1ni Akiliev"
|
|
4
|
+
},
|
|
5
|
+
"bugs": {
|
|
6
|
+
"url": "https://github.com/houd1ni/pepka/issues"
|
|
7
|
+
},
|
|
8
|
+
"deprecated": false,
|
|
9
|
+
"description": "An ultra lightweight, async or unsafe-speedy ramda alternative.",
|
|
10
|
+
"homepage": "https://houd1ni.github.io/pepka/",
|
|
11
|
+
"keywords": [
|
|
12
|
+
"ramda",
|
|
13
|
+
"functional",
|
|
14
|
+
"fp",
|
|
15
|
+
"pure",
|
|
16
|
+
"strongly-typed",
|
|
17
|
+
"typescript",
|
|
18
|
+
"d.ts"
|
|
19
|
+
],
|
|
20
|
+
"license": "MIT",
|
|
21
|
+
"type": "module",
|
|
22
|
+
"exports": {
|
|
23
|
+
".": {
|
|
24
|
+
"import": "./dist/bundle.mjs",
|
|
25
|
+
"require": "./dist/bundle.cjs"
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
"name": "pepka",
|
|
29
|
+
"repository": {
|
|
30
|
+
"type": "git",
|
|
31
|
+
"url": "git+https://github.com/houd1ni/pepka.git"
|
|
32
|
+
},
|
|
33
|
+
"scripts": {
|
|
34
|
+
"lint": "tslint src/*.ts",
|
|
35
|
+
"test": "npm run gentypes && npm run prod:es && ava",
|
|
36
|
+
"test:report": "nyc npm test && nyc report --reporter=text-lcov > coverage.lcov && codecov",
|
|
37
|
+
"test:lazy": "ava",
|
|
38
|
+
"dts-fix": "node dts-fix.js",
|
|
39
|
+
"gentypes": "dts-bundle-generator --no-check --export-referenced-types=false -o dist/bundle.d.ts src/index.ts && npm run dts-fix",
|
|
40
|
+
"dev": "cross-env NODE_ENV=development BUILD=es rollup -c",
|
|
41
|
+
"prod:cjs": "cross-env NODE_ENV=production BUILD=cjs rollup -c",
|
|
42
|
+
"prod:es": "cross-env NODE_ENV=production BUILD=es rollup -c",
|
|
43
|
+
"prod": "npm run gentypes && npm run prod:es && npm run prod:cjs",
|
|
44
|
+
"all": "npm run dev && npm run prod"
|
|
45
|
+
},
|
|
46
|
+
"version": "1.0.0",
|
|
47
|
+
"ava": {
|
|
48
|
+
"files": [
|
|
49
|
+
"./test/specs/*.ts"
|
|
50
|
+
],
|
|
51
|
+
"failFast": true,
|
|
52
|
+
"timeout": "2m",
|
|
53
|
+
"extensions": [
|
|
54
|
+
"ts"
|
|
55
|
+
],
|
|
56
|
+
"require": [
|
|
57
|
+
"ts-node/register"
|
|
58
|
+
]
|
|
59
|
+
},
|
|
60
|
+
"devDependencies": {
|
|
61
|
+
"@rollup/plugin-commonjs": "^25.0.7",
|
|
62
|
+
"@rollup/plugin-node-resolve": "^15.2.3",
|
|
63
|
+
"@rollup/plugin-replace": "^5.0.5",
|
|
64
|
+
"@rollup/plugin-terser": "^0.4.4",
|
|
65
|
+
"@types/node": "^20.12.2",
|
|
66
|
+
"ava": "^6.1.2",
|
|
67
|
+
"codecov": "^3.8.3",
|
|
68
|
+
"cross-env": "^7.0.3",
|
|
69
|
+
"dts-bundle-generator": "^9.3.1",
|
|
70
|
+
"nyc": "^15.1.0",
|
|
71
|
+
"prepend": "^1.0.2",
|
|
72
|
+
"rollup": "^4.13.2",
|
|
73
|
+
"rollup-plugin-typescript2": "^0.36.0",
|
|
74
|
+
"ts-node": "^10.9.2",
|
|
75
|
+
"tslint": "^6.1.3",
|
|
76
|
+
"typescript": "^5.4.3"
|
|
77
|
+
},
|
|
78
|
+
"types": "./dist/bundle.d.ts",
|
|
79
|
+
"sideEffects": false
|
|
80
|
+
}
|
package/src/curry.ts
CHANGED
package/src/index.ts
CHANGED
package/src/quick.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { curry2, curry3 } from "./curry"
|
|
2
2
|
import { type } from "./common"
|
|
3
3
|
import { AnyObject, Reducer, AnyFunc } from "./types"
|
|
4
|
-
import { isFunc, isArray } from "./utils"
|
|
5
|
-
|
|
4
|
+
import { isFunc, isArray, isObj } from "./utils"
|
|
5
|
+
import { includes, isNil } from "./safe"
|
|
6
6
|
// TODO: qoverProp, qover array ?
|
|
7
7
|
|
|
8
8
|
export const qappend = curry2((s: any, xs: any[]) => {xs.push(s); return xs})
|
|
@@ -60,8 +60,8 @@ export const qmapKeys = curry2(
|
|
|
60
60
|
mapped = keyMap[k]
|
|
61
61
|
;[newKey, newValue] = isFunc(mapped)
|
|
62
62
|
? (mapped as AnyFunc)(o[k], k, o)
|
|
63
|
-
: [mapped
|
|
64
|
-
o[newKey] = newValue
|
|
63
|
+
: [mapped, o[k]]
|
|
64
|
+
o[isNil(newKey) ? k : newKey] = newValue
|
|
65
65
|
if(k !== newKey) delete o[k]
|
|
66
66
|
}
|
|
67
67
|
return o
|
|
@@ -74,10 +74,10 @@ export const qmap = curry2(
|
|
|
74
74
|
}
|
|
75
75
|
)
|
|
76
76
|
export const qfilter = curry2(
|
|
77
|
-
(
|
|
77
|
+
<T extends any[] | AnyObject>(
|
|
78
78
|
cond: (v: any, k: string | number) => boolean,
|
|
79
|
-
data:
|
|
80
|
-
) => {
|
|
79
|
+
data: T
|
|
80
|
+
): T => {
|
|
81
81
|
const isArr = isArray(data)
|
|
82
82
|
let indicies_offset: number, indicies2rm: number[]
|
|
83
83
|
if(isArr) {
|
|
@@ -87,11 +87,40 @@ export const qfilter = curry2(
|
|
|
87
87
|
for(let k in data)
|
|
88
88
|
if(!cond(data[k], k)) // @ts-ignore
|
|
89
89
|
if(isArr) indicies2rm.push(+k)
|
|
90
|
-
else
|
|
91
|
-
delete data[k]
|
|
90
|
+
else delete data[k]
|
|
92
91
|
if(isArr)// @ts-ignore
|
|
93
92
|
for(const i of indicies2rm) // @ts-ignore
|
|
94
93
|
data.splice(i - indicies_offset++, 1)
|
|
95
94
|
return data
|
|
96
95
|
}
|
|
96
|
+
)
|
|
97
|
+
export const qempty = (o: AnyObject|any[]) => {
|
|
98
|
+
if(isArray(o)) o.splice(0)
|
|
99
|
+
else for(const i in o) delete o[i]
|
|
100
|
+
return o
|
|
101
|
+
}
|
|
102
|
+
export const qfreeze = <T extends AnyObject>(o: T): Readonly<T> => {
|
|
103
|
+
let v: any
|
|
104
|
+
for(const k in o) {
|
|
105
|
+
v = o[k]
|
|
106
|
+
if(isObj(v)) qfreeze(v)
|
|
107
|
+
}
|
|
108
|
+
return Object.freeze(o)
|
|
109
|
+
}
|
|
110
|
+
export const qfreezeShallow = <T extends AnyObject>(o: T): Readonly<T> => Object.freeze(o)
|
|
111
|
+
export const qprepend = curry2((x: any, xs: any[]) => xs.unshift(x))
|
|
112
|
+
export const qassocPath = curry3((_path: string[], v: any, o: AnyObject) => {
|
|
113
|
+
const first = _path[0]
|
|
114
|
+
return qassoc(first, _path.length<2
|
|
115
|
+
? v
|
|
116
|
+
: qassocPath(_path.slice(1), v, isObj(o[first]) ? o[first] : {}),
|
|
117
|
+
o
|
|
118
|
+
)
|
|
119
|
+
})
|
|
120
|
+
export const qreverse = (arr: any[]) => arr.reverse()
|
|
121
|
+
export const qomit = curry2(
|
|
122
|
+
(props: string[], o: AnyObject) => qfilter(
|
|
123
|
+
(_: any, k: string) => !includes(k, props),
|
|
124
|
+
o
|
|
125
|
+
)
|
|
97
126
|
)
|
package/src/safe.ts
CHANGED
|
@@ -1,25 +1,27 @@
|
|
|
1
1
|
import { __, curry, curry2, curry3 } from './curry'
|
|
2
2
|
import { isNum, isUndef, undef, isNull, isArray, isFunc, isStr, isObj, inf } from './utils'
|
|
3
|
-
import { qmergeDeep, qreduce, qappend, qmapKeys, qmergeDeepX, qmergeDeepAdd, qfilter } from './quick'
|
|
3
|
+
import { qmergeDeep, qreduce, qappend, qmapKeys, qmergeDeepX, qmergeDeepAdd, qfilter, qfreeze, qfreezeShallow } from './quick'
|
|
4
4
|
import { AnyFunc, Cond, AnyObject, Reducer } from './types'
|
|
5
5
|
import { type } from './common'
|
|
6
6
|
// over, lensProp
|
|
7
7
|
|
|
8
8
|
export const take = (argN: number) => (...args: any[]) => args[argN]
|
|
9
|
+
export const eq = curry2((a: any, b: any) => a===b)
|
|
10
|
+
export const weakEq = curry2((a: any, b: any) => a==b)
|
|
9
11
|
export const equals = curry2((a: any, b: any) => {
|
|
10
12
|
const typea = type(a)
|
|
11
|
-
if(typea
|
|
12
|
-
if(isNull(a) || isNull(b)) return a
|
|
13
|
-
if(a
|
|
13
|
+
if(eq(typea, type(b)) && (eq(typea, 'Object') || eq(typea, 'Array'))) {
|
|
14
|
+
if(isNull(a) || isNull(b)) return eq(a, b)
|
|
15
|
+
if(eq(a, b)) return true
|
|
14
16
|
for(const v of [a, b])
|
|
15
17
|
for(const k in v)
|
|
16
18
|
if(
|
|
17
|
-
!((v
|
|
18
|
-
!((v
|
|
19
|
+
!((eq(v, b)) && (k in a)) &&
|
|
20
|
+
!((eq(v, a)) && (k in b) && equals(a[k], b[k]))
|
|
19
21
|
) return false
|
|
20
22
|
return true
|
|
21
23
|
}
|
|
22
|
-
return a
|
|
24
|
+
return eq(a, b)
|
|
23
25
|
})
|
|
24
26
|
export const ifElse = curry(
|
|
25
27
|
(
|
|
@@ -92,18 +94,39 @@ export const always = <T=any>(s: T) => () => s
|
|
|
92
94
|
export const identity = (s: any) => s
|
|
93
95
|
export const trim = (s: string) => s.trim()
|
|
94
96
|
export const last = (s: any[] | string) => s[length(s)-1]
|
|
95
|
-
|
|
96
|
-
|
|
97
|
+
type NotOverload = {
|
|
98
|
+
(x: true): false
|
|
99
|
+
(x: false): true
|
|
100
|
+
(x: any): boolean
|
|
101
|
+
}
|
|
102
|
+
export const not: NotOverload = (x: any) => !x as any
|
|
103
|
+
type IndexesOfArray<A> = Exclude<keyof A, keyof []>
|
|
104
|
+
type KeysOverload = {
|
|
105
|
+
<T extends any[]>(o: T): string[]
|
|
106
|
+
<T extends readonly any[]>(o: T): IndexesOfArray<T>[]
|
|
107
|
+
<T extends AnyObject>(o: T): (keyof T)[]
|
|
108
|
+
}
|
|
109
|
+
export const keys: KeysOverload = (o: number[]) => Object.keys(o)
|
|
110
|
+
|
|
97
111
|
export const values = (o: AnyObject | any[]) => Object.values(o)
|
|
98
112
|
export const toPairs = (o: AnyObject | any[]) => Object.entries(o)
|
|
99
113
|
export const test = curry2((re: RegExp, s: string) => re.test(s))
|
|
100
|
-
export const tap = curry2((fn: Function,
|
|
101
|
-
export const append = curry2((
|
|
114
|
+
export const tap = curry2((fn: Function, x: any) => { fn(x); return x })
|
|
115
|
+
export const append = curry2((x: any, xs: any[]) => [...xs, x])
|
|
116
|
+
export const prepend = curry2((x: any, xs: any[]) => [...xs, x])
|
|
117
|
+
export const flat = (xs: any[]) => xs.flat(inf)
|
|
118
|
+
export const flatShallow = (xs: any[]) => xs.flat()
|
|
119
|
+
export const flatTo = curry2((depth: number, xs: any[]) => xs.flat(depth))
|
|
102
120
|
export const split = curry2((s: string|RegExp, xs: string) => xs.split(s))
|
|
103
121
|
export const T = always<true>(true) as (...args: any[]) => true
|
|
104
122
|
export const F = always<false>(false) as (...args: any[]) => false
|
|
105
123
|
export const callWith = curry2((args: any[], fn: AnyFunc) => fn(...args))
|
|
106
|
-
export const noop = (...
|
|
124
|
+
export const noop = (()=>{}) as (...args: any[]) => any
|
|
125
|
+
/** Calls a func from object.
|
|
126
|
+
* @param {any[]} [args] - arguments for the function.
|
|
127
|
+
* @param {string} [fnName] - property name of the function.
|
|
128
|
+
* @param {AnyObject} [o] - the object with the function. */
|
|
129
|
+
export const callFrom = curry((args: any[], fn: string, o: AnyObject) => o[fn](...args))
|
|
107
130
|
export const complement = (fn: AnyFunc) => (...args: any) => {
|
|
108
131
|
const out = fn(...args)
|
|
109
132
|
const f = isFunc(out)
|
|
@@ -119,6 +142,7 @@ export const sizeof = (s: any[] | string | AnyObject) => {
|
|
|
119
142
|
export const range = curry2((from: number, to: number) =>
|
|
120
143
|
genBy(add(from), to-from)
|
|
121
144
|
)
|
|
145
|
+
// TODO: make it using equals for deep stuff !
|
|
122
146
|
export const uniq = (xs: any[]) => qreduce(
|
|
123
147
|
<T>(accum: any, x: T) =>
|
|
124
148
|
includes(x, accum) ? accum : qappend(x, accum),
|
|
@@ -135,12 +159,9 @@ export const genBy = curry2(
|
|
|
135
159
|
export const once = <Func extends AnyFunc>(fn: Func) => {
|
|
136
160
|
let done = false, cache: any
|
|
137
161
|
return (...args: Parameters<Func>) => {
|
|
138
|
-
if(done)
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
done = true
|
|
142
|
-
return cache = fn(...args)
|
|
143
|
-
}
|
|
162
|
+
if(done) return cache
|
|
163
|
+
done = true
|
|
164
|
+
return cache = fn(...args)
|
|
144
165
|
}
|
|
145
166
|
}
|
|
146
167
|
export const reverse = (xs: any[]) => compose(
|
|
@@ -244,6 +265,8 @@ export const clone = (s: any, shallow = false) => {
|
|
|
244
265
|
}
|
|
245
266
|
}
|
|
246
267
|
export const cloneShallow = (s: any) => clone(s, true)
|
|
268
|
+
export const freeze = <T extends AnyObject>(o: T): Readonly<T> => qfreeze(clone(o))
|
|
269
|
+
export const freezeShallow = <T extends AnyObject>(o: T): Readonly<T> => qfreezeShallow(clone(o))
|
|
247
270
|
|
|
248
271
|
/** types T1, T2
|
|
249
272
|
* @param reducer (accum: T1, current: T2, index: number) => newAccum: T1
|
|
@@ -314,7 +337,7 @@ export const replace = curry3(
|
|
|
314
337
|
// @ts-ignore Some bug with overload.
|
|
315
338
|
) => where.replace(a, b)
|
|
316
339
|
)
|
|
317
|
-
//
|
|
340
|
+
// FIXME: it thinks cond is a symbol in usage !!!
|
|
318
341
|
export const filter = curry2(
|
|
319
342
|
(
|
|
320
343
|
cond: (v: any, k: string | number) => boolean,
|
|
@@ -348,7 +371,7 @@ export const overProp = curry3(
|
|
|
348
371
|
/** mapKeys({ a: 'b' }, { a: 44 }) -> { b: 44 } */
|
|
349
372
|
export const mapKeys = curry2(
|
|
350
373
|
(
|
|
351
|
-
keyMap: {[oldKey: string]: string},
|
|
374
|
+
keyMap: {[oldKey: string]: string | AnyFunc},
|
|
352
375
|
o: AnyObject
|
|
353
376
|
) => qmapKeys(keyMap, Object.assign({}, o))
|
|
354
377
|
)
|
package/src/timers.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { AnyFunc } from "./types"
|
|
2
|
+
|
|
3
|
+
export const debounce = <T extends AnyFunc>(time: number, fn: T) => {
|
|
4
|
+
let queue: AnyFunc[] = []
|
|
5
|
+
let to: NodeJS.Timeout
|
|
6
|
+
return ((...args: Parameters<T>) => new Promise<ReturnType<T>>((ff) => {
|
|
7
|
+
const qel = async () => {
|
|
8
|
+
clearTimeout(to)
|
|
9
|
+
to = setTimeout(async () => {
|
|
10
|
+
const res = await fn!(...args)
|
|
11
|
+
if(queue.includes(qel)) ff(res)
|
|
12
|
+
}, time)
|
|
13
|
+
}
|
|
14
|
+
queue.splice(0)
|
|
15
|
+
queue.push(qel)
|
|
16
|
+
qel()
|
|
17
|
+
}))
|
|
18
|
+
}
|
package/src/types.ts
CHANGED
|
@@ -1,15 +1,10 @@
|
|
|
1
1
|
export type Cond = (x1?: any, x2?: any, x3?: any) => boolean
|
|
2
|
-
export interface AnyObject {
|
|
3
|
-
[k: string]: any
|
|
4
|
-
}
|
|
2
|
+
export interface AnyObject { [k: string]: any }
|
|
5
3
|
export type AnyArgs = any[]
|
|
4
|
+
export type Reducer<T=any> = (accum: T, cur: any, index: number) => T
|
|
5
|
+
export type AnyFunc<ReturnT = any, Args extends AnyArgs = AnyArgs> = (...args: Args) => ReturnT
|
|
6
|
+
export type TupleFn<ARG1=any, ARG2=any, Out=any> = (a: ARG1, b: ARG2) => Out
|
|
6
7
|
export type Curried<
|
|
7
8
|
Args extends AnyArgs = AnyArgs,
|
|
8
9
|
ReturnT = any
|
|
9
|
-
> = (arg: Args[number]) => Curried<Args> | ReturnT
|
|
10
|
-
export type Reducer<T=any> = (accum: T, cur: any, index: number) => T
|
|
11
|
-
export type AnyFunc<
|
|
12
|
-
ReturnT = any,
|
|
13
|
-
Args extends AnyArgs = AnyArgs
|
|
14
|
-
> = (...args: Args) => ReturnT
|
|
15
|
-
export type TupleFn<ARG1=any, ARG2=any, Out=any> = (a: ARG1, b: ARG2) => Out
|
|
10
|
+
> = (arg: Args[number]) => Curried<Args> | ReturnT
|