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

optimism

Package Overview
Dependencies
Maintainers
1
Versions
72
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

optimism - npm Package Compare versions

Comparing version 0.13.2 to 0.14.0

58

lib/bundle.cjs.js

@@ -5,2 +5,3 @@ 'use strict';

var trie = require('@wry/trie');
var context = require('@wry/context');

@@ -366,50 +367,2 @@

// A trie data structure that holds object keys weakly, yet can also hold
// non-object keys, unlike the native `WeakMap`.
// If no makeData function is supplied, the looked-up data will be an empty,
// no-prototype Object.
var defaultMakeData = function () { return Object.create(null); };
// Useful for processing arguments objects as well as arrays.
var _a = Array.prototype, forEach = _a.forEach, slice = _a.slice;
var KeyTrie = /** @class */ (function () {
function KeyTrie(weakness, makeData) {
if (makeData === void 0) { makeData = defaultMakeData; }
this.weakness = weakness;
this.makeData = makeData;
}
KeyTrie.prototype.lookup = function () {
var array = [];
for (var _i = 0; _i < arguments.length; _i++) {
array[_i] = arguments[_i];
}
return this.lookupArray(array);
};
KeyTrie.prototype.lookupArray = function (array) {
var node = this;
forEach.call(array, function (key) { return node = node.getChildTrie(key); });
return node.data || (node.data = this.makeData(slice.call(array)));
};
KeyTrie.prototype.getChildTrie = function (key) {
var map = this.weakness && isObjRef(key)
? this.weak || (this.weak = new WeakMap())
: this.strong || (this.strong = new Map());
var child = map.get(key);
if (!child)
map.set(key, child = new KeyTrie(this.weakness, this.makeData));
return child;
};
return KeyTrie;
}());
function isObjRef(value) {
switch (typeof value) {
case "object":
if (value === null)
break;
// Fall through to return true...
case "function":
return true;
}
return false;
}
function dep(options) {

@@ -450,3 +403,3 @@ var depsByKey = new Map();

// In those cases, just write your own custom makeCacheKey functions.
var keyTrie = new KeyTrie(typeof WeakMap === "function");
var keyTrie = new trie.Trie(typeof WeakMap === "function");
function defaultMakeCacheKey() {

@@ -520,2 +473,8 @@ var args = [];

Object.defineProperty(exports, 'KeyTrie', {
enumerable: true,
get: function () {
return trie.Trie;
}
});
Object.defineProperty(exports, 'asyncFromGen', {

@@ -545,3 +504,2 @@ enumerable: true,

});
exports.KeyTrie = KeyTrie;
exports.defaultMakeCacheKey = defaultMakeCacheKey;

@@ -548,0 +506,0 @@ exports.dep = dep;

@@ -0,1 +1,3 @@

import { Trie } from '@wry/trie';
export { Trie as KeyTrie } from '@wry/trie';
import { Slot } from '@wry/context';

@@ -362,50 +364,2 @@ export { asyncFromGen, bind as bindContext, noContext, setTimeout } from '@wry/context';

// A trie data structure that holds object keys weakly, yet can also hold
// non-object keys, unlike the native `WeakMap`.
// If no makeData function is supplied, the looked-up data will be an empty,
// no-prototype Object.
var defaultMakeData = function () { return Object.create(null); };
// Useful for processing arguments objects as well as arrays.
var _a = Array.prototype, forEach = _a.forEach, slice = _a.slice;
var KeyTrie = /** @class */ (function () {
function KeyTrie(weakness, makeData) {
if (makeData === void 0) { makeData = defaultMakeData; }
this.weakness = weakness;
this.makeData = makeData;
}
KeyTrie.prototype.lookup = function () {
var array = [];
for (var _i = 0; _i < arguments.length; _i++) {
array[_i] = arguments[_i];
}
return this.lookupArray(array);
};
KeyTrie.prototype.lookupArray = function (array) {
var node = this;
forEach.call(array, function (key) { return node = node.getChildTrie(key); });
return node.data || (node.data = this.makeData(slice.call(array)));
};
KeyTrie.prototype.getChildTrie = function (key) {
var map = this.weakness && isObjRef(key)
? this.weak || (this.weak = new WeakMap())
: this.strong || (this.strong = new Map());
var child = map.get(key);
if (!child)
map.set(key, child = new KeyTrie(this.weakness, this.makeData));
return child;
};
return KeyTrie;
}());
function isObjRef(value) {
switch (typeof value) {
case "object":
if (value === null)
break;
// Fall through to return true...
case "function":
return true;
}
return false;
}
function dep(options) {

@@ -446,3 +400,3 @@ var depsByKey = new Map();

// In those cases, just write your own custom makeCacheKey functions.
var keyTrie = new KeyTrie(typeof WeakMap === "function");
var keyTrie = new Trie(typeof WeakMap === "function");
function defaultMakeCacheKey() {

@@ -516,3 +470,3 @@ var args = [];

export { KeyTrie, defaultMakeCacheKey, dep, wrap };
export { defaultMakeCacheKey, dep, wrap };
//# sourceMappingURL=bundle.esm.js.map

4

lib/index.d.ts

@@ -1,2 +0,2 @@

import { KeyTrie } from "./key-trie";
import { Trie } from "@wry/trie";
export { bindContext, noContext, setTimeout, asyncFromGen, } from "./context";

@@ -6,3 +6,3 @@ export { dep, OptimisticDependencyFunction } from "./dep";

export declare function defaultMakeCacheKey(...args: any[]): any;
export { KeyTrie };
export { Trie as KeyTrie };
export declare type OptimisticWrapperFunction<TArgs extends any[], TResult, TKeyArgs extends any[] = TArgs> = ((...args: TArgs) => TResult) & {

@@ -9,0 +9,0 @@ dirty: (...args: TKeyArgs) => void;

{
"name": "optimism",
"version": "0.13.2",
"version": "0.14.0",
"author": "Ben Newman <ben@benjamn.com>",

@@ -50,4 +50,5 @@ "description": "Composable reactive caching with efficient invalidation.",

"dependencies": {
"@wry/context": "^0.5.2"
"@wry/context": "^0.5.2",
"@wry/trie": "^0.2.1"
}
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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