@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.
@@ -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
- export declare const consume: (context: Context<unknown>, pluck: (value: unknown) => unknown) => import("lit-html/directive.js").DirectiveResult<typeof ConsumeDirective>;
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
@@ -1,3 +1,4 @@
1
+ export function memize(fn: any): () => any;
1
2
  export function memoize(fn: any): (arg: any) => any;
2
3
  export function memooize(fn: any): (arg1: any, arg2: any) => any;
3
4
  export function memoooize(fn: any): (arg1: any, arg2: any, arg3: any) => any;
package/dist/memoize.js CHANGED
@@ -1,4 +1,15 @@
1
- export const memoize = fn => {
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) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@neovici/cosmoz-utils",
3
- "version": "6.6.0",
3
+ "version": "6.8.0",
4
4
  "description": "Date, money and template management functions commonly needed in Cosmoz views.",
5
5
  "keywords": [
6
6
  "polymer",