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

itemsholdr

Package Overview
Dependencies
Maintainers
1
Versions
38
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

itemsholdr - npm Package Compare versions

Comparing version 0.7.7 to 0.7.8

2

package.json

@@ -83,3 +83,3 @@ {

"types": "./src/index.d.ts",
"version": "0.7.7"
"version": "0.7.8"
}
/**
* Matched only by strings returned by keyof TItems.
*/
export declare type IStringKeysOf<TItems> = keyof TItems & string;
/**
* Called when an item equals an interesting value.

@@ -112,3 +116,3 @@ *

*/
key(index: number): keyof TItems;
key(index: number): IStringKeysOf<TItems>;
/**

@@ -133,3 +137,3 @@ * Gets whether autoSave is enabled.

*/
addItem<TKey extends keyof TItems>(key: TKey, settings?: IItemSettings<TItems[TKey]>): void;
addItem<TKey extends IStringKeysOf<TItems>>(key: TKey, settings?: IItemSettings<TItems[TKey]>): void;
/**

@@ -142,3 +146,3 @@ * Gets a value under a key.

*/
getItem<TKey extends keyof TItems>(key: TKey): TItems[TKey];
getItem<TKey extends IStringKeysOf<TItems>>(key: TKey): TItems[TKey];
/**

@@ -150,3 +154,3 @@ * Clears a value from the listing.

*/
removeItem<TKey extends keyof TItems>(key: TKey): void;
removeItem<TKey extends IStringKeysOf<TItems>>(key: TKey): void;
/**

@@ -159,3 +163,3 @@ * Sets the value for an item under the given key.

*/
setItem<TKey extends keyof TItems>(key: TKey, value: TItems[TKey]): void;
setItem<TKey extends IStringKeysOf<TItems>>(key: TKey, value: TItems[TKey]): void;
/**

@@ -168,3 +172,3 @@ * Increases the value of an item as a number or string.

*/
increase<TKey extends keyof TItems>(key: TKey, amount?: number | string): void;
increase<TKey extends IStringKeysOf<TItems>>(key: TKey, amount?: number | string): void;
/**

@@ -177,3 +181,3 @@ * Decreases the value of an item as a number.

*/
decrease<TKey extends keyof TItems>(key: TKey, amount?: number): void;
decrease<TKey extends IStringKeysOf<TItems>>(key: TKey, amount?: number): void;
/**

@@ -185,3 +189,3 @@ * Toggles whether an item is true or false.

*/
toggle<TKey extends keyof TItems>(key: TKey): void;
toggle<TKey extends IStringKeysOf<TItems>>(key: TKey): void;
/**

@@ -194,3 +198,3 @@ * Gets whether an item exists under the key.

*/
hasKey<TKey extends keyof TItems>(key: TKey): boolean;
hasKey<TKey extends IStringKeysOf<TItems>>(key: TKey): boolean;
/**

@@ -212,3 +216,3 @@ * Gets a summary of keys and their values.

*/
saveItem<TKey extends keyof TItems>(key: TKey): void;
saveItem<TKey extends IStringKeysOf<TItems>>(key: TKey): void;
/**

@@ -215,0 +219,0 @@ * Manually saves all items to storage, ignoring autoSave settings.

/**
* Matched only by strings returned by keyof TItems.
*/
export type IStringKeysOf<TItems> = keyof TItems & string;
/**
* Called when an item equals an interesting value.

@@ -130,3 +135,3 @@ *

*/
key(index: number): keyof TItems;
key(index: number): IStringKeysOf<TItems>;

@@ -154,3 +159,3 @@ /**

*/
addItem<TKey extends keyof TItems>(key: TKey, settings?: IItemSettings<TItems[TKey]>): void;
addItem<TKey extends IStringKeysOf<TItems>>(key: TKey, settings?: IItemSettings<TItems[TKey]>): void;

@@ -164,3 +169,3 @@ /**

*/
getItem<TKey extends keyof TItems>(key: TKey): TItems[TKey];
getItem<TKey extends IStringKeysOf<TItems>>(key: TKey): TItems[TKey];

@@ -173,3 +178,3 @@ /**

*/
removeItem<TKey extends keyof TItems>(key: TKey): void;
removeItem<TKey extends IStringKeysOf<TItems>>(key: TKey): void;

@@ -183,3 +188,3 @@ /**

*/
setItem<TKey extends keyof TItems>(key: TKey, value: TItems[TKey]): void;
setItem<TKey extends IStringKeysOf<TItems>>(key: TKey, value: TItems[TKey]): void;

@@ -193,3 +198,3 @@ /**

*/
increase<TKey extends keyof TItems>(key: TKey, amount?: number | string): void;
increase<TKey extends IStringKeysOf<TItems>>(key: TKey, amount?: number | string): void;

@@ -203,3 +208,3 @@ /**

*/
decrease<TKey extends keyof TItems>(key: TKey, amount?: number): void;
decrease<TKey extends IStringKeysOf<TItems>>(key: TKey, amount?: number): void;

@@ -212,3 +217,3 @@ /**

*/
toggle<TKey extends keyof TItems>(key: TKey): void;
toggle<TKey extends IStringKeysOf<TItems>>(key: TKey): void;

@@ -222,3 +227,3 @@ /**

*/
hasKey<TKey extends keyof TItems>(key: TKey): boolean;
hasKey<TKey extends IStringKeysOf<TItems>>(key: TKey): boolean;

@@ -243,3 +248,3 @@ /**

*/
saveItem<TKey extends keyof TItems>(key: TKey): void;
saveItem<TKey extends IStringKeysOf<TItems>>(key: TKey): void;

@@ -246,0 +251,0 @@ /**

@@ -26,3 +26,3 @@ define(["require", "exports", "./proliferate"], function (require, exports, proliferate_1) {

// If there exists an old version of this property, get it
if ({}.hasOwnProperty.call(settings.storage, settings.prefix + key)) {
if ({}.hasOwnProperty.call(settings.storage, "" + settings.prefix + key)) {
this.value = this.retrieveLocalStorage();

@@ -87,3 +87,3 @@ this.update();

if (overrideAutoSave || this.settings.autoSave) {
this.settings.storage.setItem(this.settings.prefix + this.key, JSON.stringify(this.value));
this.settings.storage.setItem("" + this.settings.prefix + this.key, JSON.stringify(this.value));
}

@@ -120,3 +120,3 @@ };

ItemContainer.prototype.retrieveLocalStorage = function () {
var value = this.settings.storage.getItem(this.settings.prefix + this.key);
var value = this.settings.storage.getItem("" + this.settings.prefix + this.key);
if (value === undefined || value === "undefined") {

@@ -123,0 +123,0 @@ return undefined;

@@ -41,3 +41,3 @@ import { IItemSettings, ITriggers } from "./IItemsHoldr";

*/
private readonly key: number | string | symbol;
private readonly key: string;

@@ -98,3 +98,3 @@ /**

*/
public constructor(settings: IItemContainerSettings, key: number | string | symbol, item: IItemSettings<TItem> = {}) {
public constructor(settings: IItemContainerSettings, key: string, item: IItemSettings<TItem> = {}) {
this.settings = settings;

@@ -101,0 +101,0 @@

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

import { IItemSettings, IItemsHoldr, IItemsHoldrSettings } from "./IItemsHoldr";
import { IItemSettings, IItemsHoldr, IItemsHoldrSettings, IStringKeysOf } from "./IItemsHoldr";
/**

@@ -56,3 +56,3 @@ * Cache-based wrapper around localStorage.

*/
key(index: number): keyof TItems;
key(index: number): IStringKeysOf<TItems>;
/**

@@ -77,3 +77,3 @@ * Gets whether autoSave is enabled.

*/
addItem<TKey extends keyof TItems>(key: TKey, settings?: IItemSettings<TItems[TKey]>): void;
addItem<TKey extends IStringKeysOf<TItems>>(key: TKey, settings?: IItemSettings<TItems[TKey]>): void;
/**

@@ -86,3 +86,3 @@ * Gets the value under a key.

*/
getItem<TKey extends keyof TItems>(key: TKey): TItems[TKey];
getItem<TKey extends IStringKeysOf<TItems>>(key: TKey): TItems[TKey];
/**

@@ -95,3 +95,3 @@ * Clears a value from the listing, and removes its element from the

*/
removeItem<TKey extends keyof TItems>(key: TKey): void;
removeItem<TKey extends IStringKeysOf<TItems>>(key: TKey): void;
/**

@@ -104,3 +104,3 @@ * Sets the value for an item under the given key.

*/
setItem<TKey extends keyof TItems>(key: TKey, value: TItems[TKey]): void;
setItem<TKey extends IStringKeysOf<TItems>>(key: TKey, value: TItems[TKey]): void;
/**

@@ -113,3 +113,3 @@ * Increases the value of an item as a number or string.

*/
increase<TKey extends keyof TItems>(key: TKey, amount?: number | string): void;
increase<TKey extends IStringKeysOf<TItems>>(key: TKey, amount?: number | string): void;
/**

@@ -122,3 +122,3 @@ * Decreases the value of an item as a number

*/
decrease<TKey extends keyof TItems>(key: TKey, amount?: number): void;
decrease<TKey extends IStringKeysOf<TItems>>(key: TKey, amount?: number): void;
/**

@@ -130,3 +130,3 @@ * Toggles whether an item is true or false.

*/
toggle<TKey extends keyof TItems>(key: TKey): void;
toggle<TKey extends IStringKeysOf<TItems>>(key: TKey): void;
/**

@@ -156,3 +156,3 @@ * Gets whether an item exists under the key.

*/
saveItem<TKey extends keyof TItems>(key: TKey): void;
saveItem<TKey extends IStringKeysOf<TItems>>(key: TKey): void;
/**

@@ -170,5 +170,5 @@ * Manually saves all items to storage, ignoring autoSave settings.

*
* @param key
* @param key Key to guarantee existence of.
*/
private checkExistence;
}

@@ -233,3 +233,3 @@ define(["require", "exports", "./createStorage", "./ItemContainer"], function (require, exports, createStorage_1, ItemContainer_1) {

*
* @param key
* @param key Key to guarantee existence of.
*/

@@ -236,0 +236,0 @@ ItemsHoldr.prototype.checkExistence = function (key) {

import { createStorage } from "./createStorage";
import { IItemSettings, IItemsHoldr, IItemsHoldrSettings, IItemValues } from "./IItemsHoldr";
import { IItemSettings, IItemsHoldr, IItemsHoldrSettings, IItemValues, IStringKeysOf } from "./IItemsHoldr";
import { IItemContainerSettings, ItemContainer } from "./ItemContainer";

@@ -51,3 +51,3 @@

*/
private itemKeys: (keyof TItems)[];
private itemKeys: IStringKeysOf<TItems>[];

@@ -101,3 +101,3 @@ /**

*/
public key(index: number): keyof TItems {
public key(index: number): IStringKeysOf<TItems> {
return this.itemKeys[index];

@@ -131,3 +131,3 @@ }

*/
public addItem<TKey extends keyof TItems>(key: TKey, settings?: IItemSettings<TItems[TKey]>): void {
public addItem<TKey extends IStringKeysOf<TItems>>(key: TKey, settings?: IItemSettings<TItems[TKey]>): void {
this.items[key] = new ItemContainer(this.containerSettings, key, settings);

@@ -144,3 +144,3 @@ this.itemKeys.push(key);

*/
public getItem<TKey extends keyof TItems>(key: TKey): TItems[TKey] {
public getItem<TKey extends IStringKeysOf<TItems>>(key: TKey): TItems[TKey] {
this.checkExistence(key);

@@ -158,3 +158,3 @@

*/
public removeItem<TKey extends keyof TItems>(key: TKey): void {
public removeItem<TKey extends IStringKeysOf<TItems>>(key: TKey): void {
if (!{}.hasOwnProperty.call(this.items, key)) {

@@ -181,3 +181,3 @@ return;

*/
public setItem<TKey extends keyof TItems>(key: TKey, value: TItems[TKey]): void {
public setItem<TKey extends IStringKeysOf<TItems>>(key: TKey, value: TItems[TKey]): void {
this.checkExistence(key);

@@ -195,3 +195,3 @@

*/
public increase<TKey extends keyof TItems>(key: TKey, amount: number | string = 1): void {
public increase<TKey extends IStringKeysOf<TItems>>(key: TKey, amount: number | string = 1): void {
this.checkExistence(key);

@@ -212,3 +212,3 @@

*/
public decrease<TKey extends keyof TItems>(key: TKey, amount: number = 1): void {
public decrease<TKey extends IStringKeysOf<TItems>>(key: TKey, amount: number = 1): void {
this.checkExistence(key);

@@ -227,3 +227,3 @@

*/
public toggle<TKey extends keyof TItems>(key: TKey): void {
public toggle<TKey extends IStringKeysOf<TItems>>(key: TKey): void {
this.checkExistence(key);

@@ -286,3 +286,3 @@

*/
public saveItem<TKey extends keyof TItems>(key: TKey): void {
public saveItem<TKey extends IStringKeysOf<TItems>>(key: TKey): void {
if (!{}.hasOwnProperty.call(this.items, key)) {

@@ -316,5 +316,5 @@ throw new Error(`Unknown key given to ItemsHoldr: '${key}'.`);

*
* @param key
* @param key Key to guarantee existence of.
*/
private checkExistence(key: keyof TItems): void {
private checkExistence(key: IStringKeysOf<TItems>): void {
if (!{}.hasOwnProperty.call(this.items, key)) {

@@ -321,0 +321,0 @@ this.addItem(key, this.values[key]);

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