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

dict

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dict - npm Package Compare versions

Comparing version 1.0.2 to 1.1.0

74

dict.js
"use strict";
function mangle(key) {
return "~" + key;
return "~" + key;
}
function methods(obj, methodHash) {
for (var methodName in methodHash) {
Object.defineProperty(obj, methodName, {
value: methodHash[methodName],
configurable: true,
writable: true
});
}
for (var methodName in methodHash) {
Object.defineProperty(obj, methodName, {
value: methodHash[methodName],
configurable: true,
writable: true
});
}
}
function assertString(key) {
if (typeof key !== "string") {
throw new TypeError("key must be a string.");
}
if (typeof key !== "string") {
throw new TypeError("key must be a string.");
}
}
module.exports = function () {
var store = Object.create(null);
module.exports = function (initializer) {
var store = Object.create(null);
var dict = {};
methods(dict, {
get: function (key, defaultValue) {
assertString(key);
var mangled = mangle(key);
return mangled in store ? store[mangled] : defaultValue;
},
set: function (key, value) {
assertString(key);
store[mangle(key)] = value;
},
has: function (key) {
assertString(key);
return mangle(key) in store;
},
delete: function (key) {
assertString(key);
delete store[mangle(key)];
}
});
var dict = {};
methods(dict, {
get: function (key, defaultValue) {
assertString(key);
var mangled = mangle(key);
return mangled in store ? store[mangled] : defaultValue;
},
set: function (key, value) {
assertString(key);
store[mangle(key)] = value;
},
has: function (key) {
assertString(key);
return mangle(key) in store;
},
delete: function (key) {
assertString(key);
delete store[mangle(key)];
}
});
return dict;
if (typeof initializer === "object" && initializer !== null) {
Object.keys(initializer).forEach(function (key) {
dict.set(key, initializer[key]);
});
}
return dict;
};

@@ -0,0 +0,0 @@ DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE

@@ -11,3 +11,3 @@ {

],
"version": "1.0.2",
"version": "1.1.0",
"author": "Domenic Denicola <domenic@domenicdenicola.com> (http://domenicdenicola.com)",

@@ -17,3 +17,3 @@ "license": "WTFPL",

"type": "git",
"url": "https://github.com/domenic/dict"
"url": "git://github.com/domenic/dict.git"
},

@@ -26,14 +26,10 @@ "bugs": {

"test": "mocha",
"lint": "jshint --show-non-errors dict.js"
"lint": "jshint dict.js"
},
"engines": {
"node": "*"
},
"dependencies": {},
"devDependencies": {
"coffee-script": "1",
"mocha": "1",
"chai": "1",
"jshint": "~0.7.1"
"chai": ">= 1.3.0",
"coffee-script": ">= 1.4.0",
"jshint": ">= 0.9.1",
"mocha": ">= 1.6.0"
}
}

@@ -0,0 +0,0 @@ An easy but safe string-keyed store

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