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

@wry/context

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@wry/context - npm Package Compare versions

Comparing version 0.1.2 to 0.1.3

@@ -8,3 +8,7 @@ var currentContext = null;

var nextSlotId = 1;
// This unique internal object is used to denote the absence of a value
// for a given Slot, and is never exposed to outside code.
var MISSING_VALUE = {};
// Returns the ID of the given slot if the slot has a value defined.
// Caches the result in currentContext.slots for faster future lookups.
function lookup(slot) {

@@ -16,2 +20,5 @@ var slotId = slotIdMap.get(slot);

if (slotId in context_1.slots) {
var value = context_1.slots[slotId];
if (value === MISSING_VALUE)
break;
if (context_1 !== currentContext) {

@@ -21,3 +28,3 @@ // Cache the value in currentContext.slots so the next lookup will

// the values of the slots are logically immutable.
currentContext.slots[slotId] = context_1.slots[slotId];
currentContext.slots[slotId] = value;
}

@@ -27,2 +34,8 @@ return slotId;

}
if (currentContext) {
// If a value was not found for this Slot, it's never going to be found
// no matter how many times we look it up, so we might as well cache
// the absence of the value, too.
currentContext.slots[slotId] = MISSING_VALUE;
}
}

@@ -29,0 +42,0 @@ var Slot = /** @class */ (function () {

@@ -12,3 +12,7 @@ 'use strict';

var nextSlotId = 1;
// This unique internal object is used to denote the absence of a value
// for a given Slot, and is never exposed to outside code.
var MISSING_VALUE = {};
// Returns the ID of the given slot if the slot has a value defined.
// Caches the result in currentContext.slots for faster future lookups.
function lookup(slot) {

@@ -20,2 +24,5 @@ var slotId = slotIdMap.get(slot);

if (slotId in context_1.slots) {
var value = context_1.slots[slotId];
if (value === MISSING_VALUE)
break;
if (context_1 !== currentContext) {

@@ -25,3 +32,3 @@ // Cache the value in currentContext.slots so the next lookup will

// the values of the slots are logically immutable.
currentContext.slots[slotId] = context_1.slots[slotId];
currentContext.slots[slotId] = value;
}

@@ -31,2 +38,8 @@ return slotId;

}
if (currentContext) {
// If a value was not found for this Slot, it's never going to be found
// no matter how many times we look it up, so we might as well cache
// the absence of the value, too.
currentContext.slots[slotId] = MISSING_VALUE;
}
}

@@ -33,0 +46,0 @@ var Slot = /** @class */ (function () {

{
"name": "@wry/context",
"version": "0.1.2",
"version": "0.1.3",
"author": "Ben Newman <ben@eloper.dev>",

@@ -24,3 +24,3 @@ "description": "Manage contextual information needed by (a)synchronous tasks without explicitly passing objects around",

"build": "npm run clean && npm run tsc && npm run rollup",
"mocha": "../../node_modules/.bin/mocha --reporter spec --full-trace lib/tests.js",
"mocha": "node ../../node_modules/.bin/mocha --reporter spec --full-trace lib/tests.js",
"prepublish": "npm run build",

@@ -32,3 +32,3 @@ "test": "npm run build && npm run mocha"

},
"gitHead": "3638614f776645eca20fd5630361f226aecd3f60"
"gitHead": "2fd2f444e26a510b43ac0c2083a2f59d4e275cc0"
}

Sorry, the diff of this file is not supported yet