@neovici/cosmoz-utils 6.6.0 → 6.8.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/directives/consume.d.ts +5 -2
- package/dist/memoize.d.ts +1 -0
- package/dist/memoize.js +14 -3
- package/package.json +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Context } from '@pionjs/pion/lib/create-context';
|
|
2
2
|
import { AttributePart } from 'lit-html';
|
|
3
3
|
import { AsyncDirective } from 'lit-html/async-directive.js';
|
|
4
|
-
import { ChildPart, DirectiveParameters } from 'lit-html/directive.js';
|
|
4
|
+
import { ChildPart, DirectiveParameters, DirectiveResult } from 'lit-html/directive.js';
|
|
5
5
|
declare class ConsumeDirective<T> extends AsyncDirective {
|
|
6
6
|
value: T;
|
|
7
7
|
context: Context<T>;
|
|
@@ -14,5 +14,8 @@ declare class ConsumeDirective<T> extends AsyncDirective {
|
|
|
14
14
|
updater(value: T): void;
|
|
15
15
|
protected disconnected(): void;
|
|
16
16
|
}
|
|
17
|
-
|
|
17
|
+
interface Consume {
|
|
18
|
+
<T>(consume: Context<T>, pluck: (value: T) => unknown): DirectiveResult<typeof ConsumeDirective<T>>;
|
|
19
|
+
}
|
|
20
|
+
export declare const consume: Consume;
|
|
18
21
|
export {};
|
package/dist/memoize.d.ts
CHANGED
package/dist/memoize.js
CHANGED
|
@@ -1,4 +1,15 @@
|
|
|
1
|
-
export const
|
|
1
|
+
export const memize = (fn) => {
|
|
2
|
+
let called = false, lastResult;
|
|
3
|
+
return function () {
|
|
4
|
+
if (called) {
|
|
5
|
+
return lastResult;
|
|
6
|
+
}
|
|
7
|
+
const result = fn();
|
|
8
|
+
lastResult = result;
|
|
9
|
+
called = true;
|
|
10
|
+
return result;
|
|
11
|
+
};
|
|
12
|
+
}, memoize = (fn) => {
|
|
2
13
|
let lastArg, lastResult;
|
|
3
14
|
return function (arg) {
|
|
4
15
|
if (lastArg === arg) {
|
|
@@ -9,7 +20,7 @@ export const memoize = fn => {
|
|
|
9
20
|
lastArg = arg;
|
|
10
21
|
return result;
|
|
11
22
|
};
|
|
12
|
-
}, memooize = fn => {
|
|
23
|
+
}, memooize = (fn) => {
|
|
13
24
|
let lastArg1, lastArg2, lastResult;
|
|
14
25
|
return function (arg1, arg2) {
|
|
15
26
|
if (lastArg1 === arg1 && lastArg2 === arg2) {
|
|
@@ -21,7 +32,7 @@ export const memoize = fn => {
|
|
|
21
32
|
lastArg2 = arg2;
|
|
22
33
|
return result;
|
|
23
34
|
};
|
|
24
|
-
}, memoooize = fn => {
|
|
35
|
+
}, memoooize = (fn) => {
|
|
25
36
|
let lastArg1, lastArg2, lastArg3, lastResult;
|
|
26
37
|
return function (arg1, arg2, arg3) {
|
|
27
38
|
if (lastArg1 === arg1 && lastArg2 === arg2 && lastArg3 === arg3) {
|