Security News
JSR Working Group Kicks Off with Ambitious Roadmap and Plans for Open Governance
At its inaugural meeting, the JSR Working Group outlined plans for an open governance model and a roadmap to enhance JavaScript package management.
data-store
Advanced tools
Easily get, set and persist config data.
npm i data-store --save
npm test
var Store = require('data-store');
var store = new Store('foo');
store
.set('a', 'b')
.set('c', 'd')
.set('e', 'f');
store.save();
store.omit('a');
console.log(store.get());
Initialize a new Store
with the given name
and options
.
name
{String}: Store name. foo
would result in .foo.json
base
{String}: Dest base. If not defined, the user home directory is used, based on OS.var store = new Store('bar', 'foo');
//=> './foo/.bar.json'
var store = new Store('baz');
//=> '~/data-store/.baz.json'
Assign value
to key
and save to disk. Can be a key-value pair or an object.
key
{String}val
{*}: The value to save to key
. Must be a valid JSON type: String, Number, Array or Object.returns
{Object} Store
: for chainingstore.set('foo', 'bar');
// or
store.set({foo: 'bar'});
Get the stored value
of key
, or return all stored values if no key
is defined.
key
{String}returns
{*}: The stored value of key
.store.set('foo', 'bar');
store.get('foo');
//=> 'bar'
Returns true
if the specified key
exists.
key
{String}returns
{Boolean}: Returns true if key
existsstore.set('foo', 'bar');
store.exists('foo');
//=> true
Save the store to disk.
dest
{String}: Optionally define an alternate destination.store.save();
Delete a property or array of properties from the store then re-save the store.
key
{String|Array}: The key(s) to omit from the storereturns
{Object} Store
: for chainingstore.omit('foo');
// or
store.omit(['foo', 'bar']);
Delete the entire store. You must pass {force: true}
if the path is outside the current working directory.
store.delete({force: true});
Pull requests and stars are always welcome. For bugs and feature requests, please create an issue
Jon Schlinkert
Copyright (c) 2015-2015 Jon Schlinkert
Released under the MIT license
This file was generated by verb on February 08, 2015.
[0.3.3] - 2015-02-09
FAQs
Easily persist and load config data. No dependencies.
The npm package data-store receives a total of 23,360 weekly downloads. As such, data-store popularity was classified as popular.
We found that data-store demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
At its inaugural meeting, the JSR Working Group outlined plans for an open governance model and a roadmap to enhance JavaScript package management.
Security News
Research
An advanced npm supply chain attack is leveraging Ethereum smart contracts for decentralized, persistent malware control, evading traditional defenses.
Security News
Research
Attackers are impersonating Sindre Sorhus on npm with a fake 'chalk-node' package containing a malicious backdoor to compromise developers' projects.