Comparing version 1.0.4 to 1.0.5
@@ -12,2 +12,3 @@ "use strict"; | ||
var EventName = require("./EventName"); | ||
var StoreitError = require("./StoreitError"); | ||
@@ -19,5 +20,11 @@ var NS_SEPARATOR_CHAR = "#"; | ||
function throwUninitializedError() { | ||
throw new Error("[Storeit] you must first call `load`"); | ||
throw new StoreitError(StoreitError.loadUninitialized); | ||
} | ||
function throwIfUndefined(value) { | ||
if (value === undefined) { | ||
throw new StoreitError(StoreitError.undefinedValue); | ||
} | ||
} | ||
function Storeit(namespace, storageProvider, logger) { | ||
@@ -28,3 +35,3 @@ var that = this; | ||
if (namespace.indexOf(NS_SEPARATOR_CHAR) !== -1) { | ||
throw new Error("[Storeit] namespace can not contain a hash character (#)"); | ||
throw new StoreitError(StoreitError.invalidNamespace); | ||
} | ||
@@ -46,3 +53,3 @@ | ||
if (typeof key !== "string") { | ||
throw new TypeError("[Storeit] key must be a string."); | ||
throw new StoreitError(StoreitError.invalidKey); | ||
} | ||
@@ -170,5 +177,3 @@ } | ||
set: function (value) { | ||
if (typeof value === "undefined") { | ||
throw new TypeError("[Storeit] metadata value must not be undefined."); | ||
} | ||
throwIfUndefined(value); | ||
setMetadata(key, value); | ||
@@ -181,3 +186,3 @@ }, | ||
} else { | ||
throw new Error("[Storeit.metadata] key doesn't exist"); | ||
throw new StoreitError(StoreitError.nonexistentKey); | ||
} | ||
@@ -187,5 +192,3 @@ }; | ||
that.set = function (key, value, metadata) { | ||
if (typeof value === "undefined") { | ||
throw new TypeError("[Storeit] value must not be undefined."); | ||
} | ||
throwIfUndefined(value); | ||
var results = set(key, value, metadata); | ||
@@ -216,3 +219,3 @@ if (results.action === Action.added) { | ||
} else { | ||
throw new Error("[Storeit.delete] key doesn't exist"); | ||
throw new StoreitError(StoreitError.nonexistentKey); | ||
} | ||
@@ -232,3 +235,2 @@ } | ||
that.clear = function () { | ||
throwIfUninitialized(); | ||
if (options.publishRemoveOnClear) { // Publish removed events only for things that the domain knows about. | ||
@@ -285,3 +287,4 @@ Object.keys(cache).reverse().forEach(deleteKey); | ||
Storeit.EventName = EventName; | ||
Storeit.StoreitError = StoreitError; | ||
module.exports = Storeit; |
{ | ||
"name": "storeit", | ||
"version": "1.0.4", | ||
"version": "1.0.5", | ||
"description": "A key/value storage system that publishes events.", | ||
@@ -11,3 +11,10 @@ "main": "./lib/Storeit.js", | ||
"keywords": [ | ||
"storeit" | ||
"storeit", | ||
"webstorage", | ||
"localstorage", | ||
"sessionstorage", | ||
"key", | ||
"value", | ||
"pair", | ||
"kvp" | ||
], | ||
@@ -14,0 +21,0 @@ "contributors": [ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
45223
16
341