New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More

itemsholdr

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

itemsholdr - npm Package Compare versions

Comparing version

to
0.5.0

@@ -1,54 +0,4 @@

const gulp = require("gulp");
const merge = require("merge2");
const mochaPhantomJS = require("gulp-mocha-phantomjs");
const runSequence = require("run-sequence");
const ts = require("gulp-typescript");
const tslint = require("gulp-tslint");
gulp.task("tslint", () => {
return gulp
.src(["src/**/*.ts", "!src/**/*.d.ts"])
.pipe(tslint())
.pipe(tslint.report("verbose"));
require("gulp-shenanigans").initialize({
gulp: require("gulp"),
packageName: "ItemsHoldr"
});
gulp.task("tsc", () => {
const tsProject = ts.createProject("tsconfig.json");
return tsProject
.src()
.pipe(ts(tsProject))
.js.pipe(gulp.dest("src"));
});
gulp.task("test", () => {
return gulp
.src("test/unit/index.html")
.pipe(mochaPhantomJS());
});
gulp.task("dist", function() {
const tsProject = ts.createProject(
"tsconfig.json",
{
outFile: "dist/ItemsHoldr.js"
});
const tsResult = tsProject
.src()
.pipe(ts(tsProject));
return merge([
tsResult.dts.pipe(gulp.dest("dist")),
tsResult.js.pipe(gulp.dest("dist"))
]);
});
gulp.task("watch", ["default"], () => {
gulp.watch("src/**/*.ts", ["default"]);
});
gulp.task("default", ["tsc", "tslint", "dist"], cb => {
runSequence(["test"], cb);
});
{
"name": "itemsholdr",
"description": "A cache-based wrapper around localStorage.",
"version": "0.4.2",
"version": "0.5.0",
"author": {

@@ -9,2 +9,3 @@ "name": "Josh Goldberg",

},
"main": "lib/ItemsHoldr.js",
"repository": {

@@ -19,14 +20,4 @@ "type": "git",

"devDependencies": {
"chai": "^3.5.0",
"gulp": "^3.9.1",
"gulp-mocha-phantomjs": "^0.11.0",
"gulp-tslint": "^5.0.0",
"gulp-typescript": "^2.13.4",
"merge2": "^1.0.2",
"mocha": "^2.4.5",
"requirejs": "^2.2.0",
"run-sequence": "^1.2.0",
"tslint": "^3.10.2",
"typescript": "^1.8.10"
"gulp-shenanigans": "^0.3.1"
}
}

@@ -14,2 +14,3 @@ # ItemsHoldr

```
npm install -g gulp-cli
npm install

@@ -16,0 +17,0 @@ gulp

import { IItemValue, IItemValueDefaults } from "./IItemValue";
/**
* A container to hold ItemValue objects, keyed by name.
*/
export interface IItems {
[i: string]: IItemValue;
}
/**
* Settings to initialize a new instance of the IItemsHoldr interface.

@@ -114,2 +121,7 @@ */

/**
* @returns All String keys of items.
*/
getItemKeys(): string[];
/**
* @param key The key for a known value.

@@ -144,3 +156,3 @@ * @returns The known value of a key, assuming that key exists.

*/
addItem(key: string, settings: any): IItemValue;
addItem(key: string, settings?: any): IItemValue;

@@ -147,0 +159,0 @@ /**

@@ -39,6 +39,7 @@ define(["require", "exports", "./ItemValue"], function (require, exports, ItemValue_1) {

];
this.container = this.makeContainer(settings.containersArguments);
this.container = this.makeContainer(this.containersArguments);
}
}
/**
* @param index An index for a key.
* @returns The indexed key.

@@ -110,2 +111,8 @@ */

/**
* @returns All String keys of items.
*/
ItemsHoldr.prototype.getItemKeys = function () {
return this.itemKeys;
};
/**
* @param key The key for a known value.

@@ -172,2 +179,3 @@ * @returns The known value of a key, assuming that key exists.

delete this.items[key];
delete this.localStorage[this.prefix + key];
};

@@ -213,7 +221,7 @@ /**

/**
* Increases the value for the ItemValue under the given key, via addition for
* Decreases the value for the ItemValue under the given key, via addition for
* Numbers or concatenation for Strings.
*
* @param key The key of the ItemValue.
* @param amount The amount to increase by (by default, 1).
* @param amount The amount to decrease by (by default, 1).
*/

@@ -479,7 +487,6 @@ ItemsHoldr.prototype.decrease = function (key, amount) {

this.items = {};
this.itemKeys = [];
if (!this.settings.values) {
this.itemKeys = [];
return;
}
this.itemKeys = Object.keys(this.settings.values);
for (var key in this.settings.values) {

@@ -486,0 +493,0 @@ if (this.settings.values.hasOwnProperty(key)) {

@@ -1,2 +0,2 @@

import { IItemsHoldr, IItemsHoldrSettings } from "./IItemsHoldr";
import { IItemsHoldr, IItemsHoldrSettings, IItems } from "./IItemsHoldr";
import { IItemValue, IItemValueDefaults } from "./IItemValue";

@@ -18,5 +18,3 @@ import { ItemValue } from "./ItemValue";

*/
private items: {
[i: string]: IItemValue
};
private items: IItems;

@@ -106,3 +104,3 @@ /**

];
this.container = this.makeContainer(settings.containersArguments);
this.container = this.makeContainer(this.containersArguments);
}

@@ -112,2 +110,3 @@ }

/**
* @param index An index for a key.
* @returns The indexed key.

@@ -190,2 +189,9 @@ */

/**
* @returns All String keys of items.
*/
public getItemKeys(): string[] {
return this.itemKeys;
}
/**
* @param key The key for a known value.

@@ -262,2 +268,3 @@ * @returns The known value of a key, assuming that key exists.

delete this.items[key];
delete this.localStorage[this.prefix + key];
}

@@ -310,7 +317,7 @@

/**
* Increases the value for the ItemValue under the given key, via addition for
* Decreases the value for the ItemValue under the given key, via addition for
* Numbers or concatenation for Strings.
*
* @param key The key of the ItemValue.
* @param amount The amount to increase by (by default, 1).
* @param amount The amount to decrease by (by default, 1).
*/

@@ -604,10 +611,8 @@ public decrease(key: string, amount: number = 1): void {

this.items = {};
this.itemKeys = [];
if (!this.settings.values) {
this.itemKeys = [];
return;
}
this.itemKeys = Object.keys(this.settings.values);
for (let key in this.settings.values) {

@@ -614,0 +619,0 @@ if (this.settings.values.hasOwnProperty(key)) {

@@ -165,4 +165,4 @@ define(["require", "exports"], function (require, exports) {

ItemValue.prototype.retrieveLocalStorage = function () {
var value = localStorage.getItem(this.ItemsHolder.getPrefix() + this.key);
if (value === "undefined") {
var value = this.ItemsHolder.getLocalStorage()[this.ItemsHolder.getPrefix() + this.key];
if (typeof value === "undefined") {
return undefined;

@@ -169,0 +169,0 @@ }

@@ -267,6 +267,6 @@ import { IItemValue, ITriggers } from "./IItemValue";

*/
private retrieveLocalStorage(): void {
const value: any = localStorage.getItem(this.ItemsHolder.getPrefix() + this.key);
private retrieveLocalStorage(): any {
const value: any = this.ItemsHolder.getLocalStorage()[this.ItemsHolder.getPrefix() + this.key];
if (value === "undefined") {
if (typeof value === "undefined") {
return undefined;

@@ -273,0 +273,0 @@ }

@@ -6,8 +6,11 @@ {

"noImplicitAny": true,
"declaration": true,
"declaration": false,
"outDir": "dist"
},
"exclude": [
"node_modules"
"files": [
"src/IItemsHoldr.ts",
"src/IItemValue.ts",
"src/ItemsHoldr.ts",
"src/ItemValue.ts"
]
}