Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@thi.ng/memoize

Package Overview
Dependencies
Maintainers
1
Versions
163
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@thi.ng/memoize - npm Package Compare versions

Comparing version 3.2.0 to 3.3.0

delay.d.ts

15

CHANGELOG.md
# Change Log
- **Last updated**: 2024-03-27T09:53:45Z
- **Last updated**: 2024-04-08T14:59:29Z
- **Generator**: [thi.ng/monopub](https://thi.ng/monopub)

@@ -12,2 +12,15 @@

## [3.3.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/memoize@3.3.0) (2024-04-08)
#### 🚀 Features
- add delay() wrapper ([d8f4733](https://github.com/thi-ng/umbrella/commit/d8f4733))
- migrated from [@thi.ng/compose](https://github.com/thi-ng/umbrella/tree/main/packages/compose) since conceptually better at home here
- add docs
#### ♻️ Refactoring
- rename `defonce()` => `defOnce()` ([08e876f](https://github.com/thi-ng/umbrella/commit/08e876f))
- deprecate old spelling
## [3.2.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/memoize@3.2.0) (2024-03-27)

@@ -14,0 +27,0 @@

@@ -20,3 +20,5 @@ import type { Fn0 } from "@thi.ng/api";

*/
export declare const defOnce: <T>(id: string, factory: Fn0<T>) => T;
/** @deprecated renamed to {@link defOnce} */
export declare const defonce: <T>(id: string, factory: Fn0<T>) => T;
//# sourceMappingURL=defonce.d.ts.map

4

defonce.js
const cache = /* @__PURE__ */ Object.create(null);
const defonce = (id, factory) => id in cache ? cache[id] : cache[id] = factory();
const defOnce = (id, factory) => id in cache ? cache[id] : cache[id] = factory();
const defonce = defOnce;
export {
defOnce,
defonce
};
export * from "./api.js";
export * from "./defonce.js";
export * from "./delay.js";
export * from "./do-once.js";

@@ -4,0 +5,0 @@ export * from "./memoize.js";

export * from "./api.js";
export * from "./defonce.js";
export * from "./delay.js";
export * from "./do-once.js";

@@ -4,0 +5,0 @@ export * from "./memoize.js";

@@ -11,3 +11,3 @@ import type { Fn, Fn2, Fn3, Fn4, NumOrString } from "@thi.ng/api";

* @example
* ```ts tangle:../../export/memoizeo.ts
* ```ts tangle:../export/memoizeo.ts
* import { memoizeO } from "@thi.ng/memoize";

@@ -14,0 +14,0 @@ *

{
"name": "@thi.ng/memoize",
"version": "3.2.0",
"version": "3.3.0",
"description": "Function memoization with configurable caching",

@@ -39,3 +39,3 @@ "type": "module",

"dependencies": {
"@thi.ng/api": "^8.9.31"
"@thi.ng/api": "^8.10.0"
},

@@ -75,2 +75,5 @@ "devDependencies": {

},
"./delay": {
"default": "./delay.js"
},
"./do-once": {

@@ -98,3 +101,3 @@ "default": "./do-once.js"

},
"gitHead": "feb3b24654f2c931cd3c3308c1c0c807ee14d0e4\n"
"gitHead": "85ac4bd4d6d89f8e3689e2863d5bea0cecdb371c\n"
}

@@ -10,3 +10,3 @@ <!-- This file is generated - DO NOT EDIT! -->

> [!NOTE]
> This is one of 190 standalone projects, maintained as part
> This is one of 191 standalone projects, maintained as part
> of the [@thi.ng/umbrella](https://github.com/thi-ng/umbrella/) monorepo

@@ -19,2 +19,3 @@ > and anti-framework.

- [About](#about)
- [Available memoization functions](#available-memoization-functions)
- [Status](#status)

@@ -37,3 +38,3 @@ - [Related packages](#related-packages)

This package provides different function memoization implementations for
functions with 1 or more arguments and custom result caching using ES6
functions with arbitrary arguments and custom result caching using ES6
Map API like implementations. Unlike native ES6 Maps, **the

@@ -48,2 +49,12 @@ implementations MUST support value, not just referential, equality

### Available memoization functions
- [defOnce()](https://docs.thi.ng/umbrella/memoize/functions/defOnce.html)
- [delay()](https://docs.thi.ng/umbrella/memoize/functions/delay.html)
- [doOnce()](https://docs.thi.ng/umbrella/memoize/functions/doOnce.html)
- [memoize()](https://docs.thi.ng/umbrella/memoize/functions/memoize.html)
- [memoize1()](https://docs.thi.ng/umbrella/memoize/functions/memoize1.html)
- [memoizeJ()](https://docs.thi.ng/umbrella/memoize/functions/memoizeJ.html)
- [memoizeO()](https://docs.thi.ng/umbrella/memoize/functions/memoizeO.html)
## Status

@@ -65,4 +76,10 @@

ES module import:
ESM import:
```ts
import * as mem from "@thi.ng/memoize";
```
Browser ESM import:
```html

@@ -77,6 +94,6 @@ <script type="module" src="https://cdn.skypack.dev/@thi.ng/memoize"></script>

```js
const memoize = await import("@thi.ng/memoize");
const mem = await import("@thi.ng/memoize");
```
Package sizes (brotli'd, pre-treeshake): ESM: 334 bytes
Package sizes (brotli'd, pre-treeshake): ESM: 518 bytes

@@ -83,0 +100,0 @@ ## Dependencies

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc