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

@adrianhelvik/bind

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@adrianhelvik/bind - npm Package Compare versions

Comparing version 1.1.0 to 1.2.0

lib/memoize.spec.js

30

lib/memoize.js

@@ -14,6 +14,9 @@ "use strict";

var staticSkipRecursive = false;
var upToDate = 'upToDate';
var dirty = 'dirty';
var tracking = new WeakSet();
function memoize(fn) {
var skipRecursive = staticSkipRecursive;
var status = dirty;

@@ -26,3 +29,17 @@ var removePrevious;

var _track = (0, _track2["default"])(function () {
value = fn();
if (tracking.has(fn)) {
if (skipRecursive) {
return;
}
throw Error('Use memoize.skipRecursive to skip recursive calls');
}
tracking.add(fn);
try {
value = fn();
} finally {
tracking["delete"](fn);
}
}),

@@ -95,2 +112,3 @@ accessed = _track.accessed;

if (skipRecursive) return;
return value;

@@ -100,3 +118,13 @@ };

memoize.skipRecursive = function (fn) {
staticSkipRecursive = true;
try {
return memoize(fn);
} finally {
staticSkipRecursive = false;
}
};
var _default = memoize;
exports["default"] = _default;

2

package.json
{
"name": "@adrianhelvik/bind",
"version": "1.1.0",
"version": "1.2.0",
"main": "lib/index.js",

@@ -5,0 +5,0 @@ "module": "src/index.js",

import { manager } from './state.js'
import track from './track.js'
let staticSkipRecursive = false
const upToDate = 'upToDate'
const dirty = 'dirty'
const tracking = new WeakSet()
function memoize(fn) {
const skipRecursive = staticSkipRecursive
let status = dirty

@@ -15,3 +19,14 @@ let removePrevious

const { accessed } = track(() => {
value = fn()
if (tracking.has(fn)) {
if (skipRecursive) {
return
}
throw Error('Use memoize.skipRecursive to skip recursive calls')
}
tracking.add(fn)
try {
value = fn()
} finally {
tracking.delete(fn)
}
})

@@ -36,2 +51,3 @@ const removers = new Set()

}
if (skipRecursive) return
return value

@@ -41,2 +57,11 @@ }

memoize.skipRecursive = fn => {
staticSkipRecursive = true
try {
return memoize(fn)
} finally {
staticSkipRecursive = false
}
}
export default memoize
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