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

pet-shop

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pet-shop - npm Package Compare versions

Comparing version 0.0.4 to 0.1.0

README.md

84

index.js

@@ -1,8 +0,12 @@

'use strict';
module.exports = function PetShop({ storage, namespace, json = false }) {
// @ts-nocheck
export function PetShop({ storage, namespace, json = false }) {
return Object.defineProperties(
{},
{
namespace: { value: namespace, enumerable: true },
namespace: {
value: namespace,
enumerable: true,
writable: false,
configurable: false,
},
get: {

@@ -12,9 +16,9 @@ enumerable: true,

? function get(key) {
const raw = storage.getItem(`${namespace}.${key}`);
return raw !== null ? JSON.parse(raw) : undefined;
}
const raw = storage.getItem(`${namespace}.${key}`);
return raw !== null ? JSON.parse(raw) : undefined;
}
: function get(key) {
const raw = storage.getItem(`${namespace}.${key}`);
return raw !== null ? raw : undefined;
}
const raw = storage.getItem(`${namespace}.${key}`);
return raw !== null ? raw : undefined;
},
},

@@ -25,18 +29,18 @@ set: {

? function set(key, value) {
if (value === undefined) {
this.remove(key);
} else {
storage.setItem(`${namespace}.${key}`, JSON.stringify(value));
if (value === undefined) {
this.remove(key);
} else {
storage.setItem(`${namespace}.${key}`, JSON.stringify(value));
}
}
}
: function set(key, value) {
if (value === undefined || value === null) {
this.remove(key);
} else {
if (typeof value !== 'string') {
throw new TypeError('The Value should be a string');
if (value === undefined || value === null) {
this.remove(key);
} else {
if (typeof value !== 'string') {
throw new TypeError('The Value should be a string');
}
storage.setItem(`${namespace}.${key}`, value);
}
storage.setItem(`${namespace}.${key}`, value);
}
}
},
},

@@ -47,3 +51,3 @@ remove: {

storage.removeItem(`${namespace}.${key}`);
}
},
},

@@ -60,3 +64,3 @@ rawKeys: {

return keys;
}
},
},

@@ -66,5 +70,6 @@ keys: {

get() {
return this.rawKeys.map(key =>
key.replace(new RegExp(`^${namespace}.`), ''));
}
return this.rawKeys.map((key) =>
key.replace(new RegExp(`^${namespace}.`), ''),
);
},
},

@@ -74,4 +79,4 @@ values: {

get() {
return this.keys.map(key => this.get(key));
}
return this.keys.map((key) => this.get(key));
},
},

@@ -81,7 +86,8 @@ valueOf: {

value: function valueOf() {
// eslint-disable-next-line unicorn/prefer-object-from-entries
return this.keys.reduce(
(io, key) => ({ [key]: this.get(key), ...io }),
{}
{},
);
}
},
},

@@ -92,3 +98,3 @@ size: {

return this.rawKeys.length;
}
},
},

@@ -99,3 +105,3 @@ has: {

return storage.getItem(`${namespace}.${key}`) !== null;
}
},
},

@@ -105,9 +111,9 @@ clear: {

value: function clear() {
this.rawKeys.forEach(key => {
this.rawKeys.forEach((key) => {
storage.removeItem(key);
});
}
}
}
},
},
},
);
};
}
{
"name": "pet-shop",
"version": "0.0.4",
"version": "0.1.0",
"description": "A simple wrapper of Web Storage API",

@@ -21,11 +21,13 @@ "license": "MIT",

],
"homepage": "https://github.com/airkro/frontend-toolkit/tree/master/packages/pet-shop",
"repository": {
"type": "git",
"url": "https://github.com/airkro/frontend-toolkit",
"url": "https://github.com/airkro/frontend-toolkit.git",
"directory": "packages/pet-shop"
},
"bugs": {
"url": "https://github.com/airkro/frontend-toolkit/issues"
},
"main": "index.js",
"engines": {
"node": ">=8.3.0"
}
}
"type": "module"
}
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