yummies 4.6.1 → 4.7.1
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/complex/counter.d.ts +3 -1
- package/complex/counter.d.ts.map +1 -1
- package/complex/counter.js +11 -12
- package/package.json +6 -1
package/complex/counter.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
export interface CounterFn<TProcessedValue = number> {
|
|
2
2
|
(): TProcessedValue;
|
|
3
|
+
counter: number;
|
|
4
|
+
value: TProcessedValue;
|
|
3
5
|
reset(): void;
|
|
4
6
|
}
|
|
5
|
-
export declare const createCounter: <TProcessedValue = number>(processValue?: (value: number) => TProcessedValue) => CounterFn<TProcessedValue>;
|
|
7
|
+
export declare const createCounter: <TProcessedValue = number>(processValue?: (value: number) => TProcessedValue, initial?: number) => CounterFn<TProcessedValue>;
|
|
6
8
|
//# sourceMappingURL=counter.d.ts.map
|
package/complex/counter.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"counter.d.ts","sourceRoot":"","sources":["../../src/complex/counter.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,SAAS,CAAC,eAAe,GAAG,MAAM;IACjD,IAAI,eAAe,CAAC;IACpB,KAAK,IAAI,IAAI,CAAC;CACf;AAED,eAAO,MAAM,aAAa,GAAI,eAAe,GAAG,MAAM,EACpD,eAAe,CAAC,KAAK,EAAE,MAAM,KAAK,eAAe,
|
|
1
|
+
{"version":3,"file":"counter.d.ts","sourceRoot":"","sources":["../../src/complex/counter.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,SAAS,CAAC,eAAe,GAAG,MAAM;IACjD,IAAI,eAAe,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,eAAe,CAAC;IACvB,KAAK,IAAI,IAAI,CAAC;CACf;AAED,eAAO,MAAM,aAAa,GAAI,eAAe,GAAG,MAAM,EACpD,eAAe,CAAC,KAAK,EAAE,MAAM,KAAK,eAAe,EACjD,UAAS,MAAU,KAClB,SAAS,CAAC,eAAe,CAe3B,CAAC"}
|
package/complex/counter.js
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
|
-
export const createCounter = (processValue) => {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
incrementFn.reset = () => {
|
|
11
|
-
counter = 0;
|
|
1
|
+
export const createCounter = (processValue, initial = 0) => {
|
|
2
|
+
const fn = (() => {
|
|
3
|
+
const nextCounter = ++fn.counter;
|
|
4
|
+
fn.value = processValue?.(nextCounter) ?? nextCounter;
|
|
5
|
+
return fn.value;
|
|
6
|
+
});
|
|
7
|
+
fn.reset = () => {
|
|
8
|
+
fn.counter = initial;
|
|
9
|
+
fn.value = processValue?.(initial) ?? initial;
|
|
12
10
|
};
|
|
13
|
-
|
|
11
|
+
fn.reset();
|
|
12
|
+
return fn;
|
|
14
13
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "yummies",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.7.1",
|
|
4
4
|
"keywords": [],
|
|
5
5
|
"author": "js2me",
|
|
6
6
|
"license": "MIT",
|
|
@@ -51,6 +51,11 @@
|
|
|
51
51
|
"default": "./common.js",
|
|
52
52
|
"types": "./common.d.ts"
|
|
53
53
|
},
|
|
54
|
+
"./complex/counter.test": {
|
|
55
|
+
"import": "./complex/counter.test.js",
|
|
56
|
+
"default": "./complex/counter.test.js",
|
|
57
|
+
"types": "./complex/counter.test.d.ts"
|
|
58
|
+
},
|
|
54
59
|
"./complex/counter": {
|
|
55
60
|
"import": "./complex/counter.js",
|
|
56
61
|
"default": "./complex/counter.js",
|