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

pkg-store

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pkg-store

Use package.json as a config store.

  • 0.1.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
23K
decreased by-2.34%
Maintainers
1
Weekly downloads
 
Created
Source

pkg-store NPM version Build Status

Use package.json as a config store.

Install

Install with npm:

$ npm i pkg-store --save

Usage

var pkg = require('pkg-store')(process.cwd());

API

All methods allow the optional use of dot-notation for property keys. See the data-store documentation for all available methods.

.set/.get

The .set method automatically persists values to package.json:

pkg.set('bin.foo', 'bar');

console.log(pkg.get('bin'));
//=> { foo: 'bar' }

console.log(pkg.get('bin.foo'));
//=> 'bar'

.has

Returns true if package.json has the given property:

console.log(pkg.has('name'));
//=> true

console.log(pkg.has('zzzzzzz'));
//=> false

.union

Add and append array values (automatically persists values to package.json):

pkg.union('keywords', 'foo');
pkg.union('keywords', 'bar');
pkg.union('keywords', 'baz');

console.log(pkg.get('keywords'));
//=> ['foo', 'bar', 'baz']

Events

Most methods also emit an event. See data-store for more details.

pkg.on('union', function(key, value) {
  console.log(arguments);
  // { '0': 'keywords', '1': 'foo' }
  // { '0': 'keywords', '1': 'bar' }
  // { '0': 'keywords', '1': 'baz' }
});

pkg.union('keywords', 'foo');
pkg.union('keywords', 'bar');
pkg.union('keywords', 'baz');
  • data-store: Easily get, set and persist config data. | homepage
  • find-pkg: Find the first directory with a package.json, recursing up, starting with the given directory. Similar… more | homepage
  • normalize-pkg: Normalize values in package.json to improve compatibility, programmatic readability and usefulness with third party libs. | homepage

Running tests

Install dev dependencies:

$ npm i -d && npm test

Contributing

Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.

Author

Jon Schlinkert

License

Copyright © 2016 Jon Schlinkert Released under the MIT license.


This file was generated by verb on January 23, 2016.

Keywords

FAQs

Package last updated on 04 Feb 2016

Did you know?

Socket

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.

Install

Related posts

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