utilium 2.8.0 → 2.8.2

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/index.d.ts CHANGED
@@ -1,3 +1,8 @@
1
+ export * from './array.js';
2
+ export * from './buffer.js';
3
+ export * as cache from './cache.js';
4
+ export * from './checksum.js';
5
+ export * from './color.js';
1
6
  export * from './list.js';
2
7
  export * from './misc.js';
3
8
  export * from './numbers.js';
package/dist/index.js CHANGED
@@ -1,6 +1,11 @@
1
1
  // SPDX-License-Identifier: LGPL-3.0-or-later
2
2
  // Copyright (c) 2025 James Prevett
3
3
  // For better tree shaking, import from whichever file is actually needed
4
+ export * from './array.js';
5
+ export * from './buffer.js';
6
+ export * as cache from './cache.js';
7
+ export * from './checksum.js';
8
+ export * from './color.js';
4
9
  export * from './list.js';
5
10
  export * from './misc.js';
6
11
  export * from './numbers.js';
package/dist/misc.d.ts CHANGED
@@ -9,13 +9,7 @@ export declare function canary(error?: Error): () => void;
9
9
  * @see https://github.com/tc39/proposal-throw-expressions
10
10
  */
11
11
  export declare function _throw(e: unknown): never;
12
- interface MemoizeMetadata extends DecoratorMetadata {
13
- memoized?: Record<PropertyKey, any>;
14
- }
15
12
  /**
16
13
  * Decorator for memoizing the result of a getter.
17
14
  */
18
- export declare function memoize<T, This>(get: () => T, context: ClassGetterDecoratorContext<This, T> & {
19
- metadata?: MemoizeMetadata;
20
- }): (this: This) => T;
21
- export {};
15
+ export declare function memoize<T, This>(get: () => T, context: ClassGetterDecoratorContext<This, T>): (this: This) => T;
package/dist/misc.js CHANGED
@@ -51,20 +51,19 @@ export function _throw(e) {
51
51
  Error?.captureStackTrace(e, _throw);
52
52
  throw e;
53
53
  }
54
+ const missing = Symbol('not memoized');
54
55
  /**
55
56
  * Decorator for memoizing the result of a getter.
56
57
  */
57
58
  export function memoize(get, context) {
58
59
  if (context.kind != 'getter')
59
60
  throw new Error('@memoize can only be used on getters');
61
+ let value = missing;
60
62
  return function () {
61
- context.metadata ??= {};
62
- const { memoized = {} } = context.metadata;
63
- if (context.name in memoized) {
64
- console.log('Using cached value for', context.name, JSON.stringify(memoized[context.name]));
65
- return memoized[context.name];
63
+ if (value !== missing) {
64
+ return value;
66
65
  }
67
- memoized[context.name] = get.call(this);
68
- return memoized[context.name];
66
+ value = get.call(this);
67
+ return value;
69
68
  };
70
69
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "utilium",
3
- "version": "2.8.0",
3
+ "version": "2.8.2",
4
4
  "description": "Typescript utilities",
5
5
  "funding": {
6
6
  "type": "individual",