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

node-persist

Package Overview
Dependencies
Maintainers
3
Versions
41
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-persist - npm Package Compare versions

Comparing version 4.0.2 to 4.0.3

2

package.json
{
"name": "node-persist",
"version": "4.0.2",
"version": "4.0.3",
"description": "Super-easy (and fast) persistent data structures in Node.js, modeled after HTML5 localStorage",

@@ -5,0 +5,0 @@ "main": "./src/node-persist.js",

@@ -23,9 +23,21 @@ /*

*/
nodePersist.init = async function (userOptions) {
const localStorage = nodePersist.defaultInstance = nodePersist.create(userOptions);
let ret = await localStorage.init(userOptions);
mixin(nodePersist, localStorage, {skip: ['init', 'create']});
mixin(nodePersist, localStorage, {skip: ['init', 'initSync', 'create']});
return ret;
};
/*
* This function, (or initSync) must be called before the library can be used.
* An options hash can be optionally passed.
*/
nodePersist.initSync = function (userOptions) {
const localStorage = nodePersist.defaultInstance = nodePersist.create(userOptions);
let ret = localStorage.initSync(userOptions);
mixin(nodePersist, localStorage, {skip: ['init', 'initSync', 'create']});
return ret;
};
// expose all the API methods on the main module using a default instance

@@ -32,0 +44,0 @@ function mixin (target, source, options) {

@@ -89,3 +89,3 @@

it('should create the default instance of LocalStorage sync and use it', async function() {
it('should create the default instance of LocalStorage async and use it', async function() {
await nodePersist.init({dir: randDir()});

@@ -97,2 +97,9 @@ assert.ok(nodePersist.defaultInstance instanceof LocalStorage);

it('should create the default instance of LocalStorage sync and use it', async function() {
nodePersist.initSync({dir: randDir()});
assert.ok(nodePersist.defaultInstance instanceof LocalStorage);
await nodePersist.setItem('item8887', 'hello');
assert.equal(await nodePersist.getItem('item8887'), 'hello', `write/read didn't work`);
});
it('should create a default instance', async function() {

@@ -103,2 +110,8 @@ let dir = randDir();

});
it('should create a default instance but initSync', async function() {
let dir = randDir();
let options = nodePersist.initSync({dir: dir});
assert.equal(options.dir, dir, `Options don't match`);
});
});

@@ -105,0 +118,0 @@

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