data-store
Advanced tools
Comparing version 0.15.4 to 0.15.5
@@ -52,2 +52,3 @@ 'use strict'; | ||
Base.call(this); | ||
this.isStore = true; | ||
this.options = options || {}; | ||
@@ -96,2 +97,5 @@ this.initStore(name); | ||
Store.prototype.create = function(name, options) { | ||
if (utils.isStore(this, name)) { | ||
return this[name]; | ||
} | ||
utils.validateName(this, name); | ||
@@ -98,0 +102,0 @@ var cwd = path.join(path.dirname(this.path), this.name); |
{ | ||
"name": "data-store", | ||
"description": "Easily get, set and persist config data.", | ||
"version": "0.15.4", | ||
"version": "0.15.5", | ||
"homepage": "https://github.com/jonschlinkert/data-store", | ||
@@ -6,0 +6,0 @@ "author": "Jon Schlinkert (https://github.com/jonschlinkert)", |
@@ -71,3 +71,3 @@ # data-store [![NPM version](https://img.shields.io/npm/v/data-store.svg)](https://www.npmjs.com/package/data-store) [![Build Status](https://img.shields.io/travis/jonschlinkert/data-store.svg)](https://travis-ci.org/jonschlinkert/data-store) | ||
### [.create](index.js#L94) | ||
### [.create](index.js#L95) | ||
@@ -91,3 +91,3 @@ Create a namespaced "sub-store" that persists data to its file in a sub-folder of the same directory as the "parent" store. | ||
### [.set](index.js#L132) | ||
### [.set](index.js#L136) | ||
@@ -124,3 +124,3 @@ Assign `value` to `key` and save to disk. Can be a key-value pair or an object. | ||
### [.union](index.js#L148) | ||
### [.union](index.js#L152) | ||
@@ -144,3 +144,3 @@ Add or append an array of unique values to the given `key`. | ||
### [.get](index.js#L174) | ||
### [.get](index.js#L178) | ||
@@ -165,3 +165,3 @@ Get the stored `value` of `key`, or return the entire store if no `key` is defined. | ||
### [.has](index.js#L190) | ||
### [.has](index.js#L194) | ||
@@ -185,3 +185,3 @@ Returns `true` if the specified `key` has truthy value. | ||
### [.hasOwn](index.js#L211) | ||
### [.hasOwn](index.js#L215) | ||
@@ -210,3 +210,3 @@ Returns `true` if the specified `key` exists. | ||
### [.save](index.js#L232) | ||
### [.save](index.js#L236) | ||
@@ -225,3 +225,3 @@ Persist the store to disk. | ||
### [.clear](index.js#L247) | ||
### [.clear](index.js#L251) | ||
@@ -236,3 +236,3 @@ Clear in-memory cache. | ||
### [.del](index.js#L272) | ||
### [.del](index.js#L276) | ||
@@ -257,3 +257,3 @@ Delete `keys` from the store, or delete the entire store if no keys are passed. A `del` event is also emitted for each key deleted. | ||
### [.define](index.js#L334) | ||
### [.define](index.js#L338) | ||
@@ -317,2 +317,2 @@ Define a non-enumerable property on the instance. | ||
_This file was generated by [verb](https://github.com/verbose/verb), v0.9.0, on February 27, 2016._ | ||
_This file was generated by [verb](https://github.com/verbose/verb), v0.9.0, on March 02, 2016._ |
15
utils.js
@@ -34,4 +34,3 @@ 'use strict'; | ||
/** | ||
* Throw an error if sub-store `name` has non-word characters, or | ||
* `name` is the same as a key on `store`. | ||
* Throw an error if sub-store `name` is already a key on `store`. | ||
* | ||
@@ -43,3 +42,3 @@ * @param {Object} `store` | ||
utils.validateName = function(store, name) { | ||
if (~store.keys.indexOf(name) || /\W/.test(name)) { | ||
if (~store.keys.indexOf(name) && !utils.isStore(store, name)) { | ||
throw utils.formatConflictError(name); | ||
@@ -50,2 +49,12 @@ } | ||
/** | ||
* Return true if `name` is a store object. | ||
*/ | ||
utils.isStore = function(store, name) { | ||
return !!store[name] | ||
&& (typeof store[name] === 'object') | ||
&& store[name].isStore === true; | ||
}; | ||
/** | ||
* Format the error used when sub-store `name` is | ||
@@ -52,0 +61,0 @@ * invalid. |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
20103
402