Security News
New Python Packaging Proposal Aims to Solve Phantom Dependency Problem with SBOMs
PEP 770 proposes adding SBOM support to Python packages to improve transparency and catch hidden non-Python dependencies that security tools often miss.
storage-typed
Advanced tools
Web Storage wrapper that provides automatic JSON parsing/stringifying and type-specific features.
Web Storage only accepts string value so you should write this verbose code everytime:
// get
try {
const value = window.localStorage.getItem(key);
return value ? JSON.parse(value) : null;
} catch (e) {
/* ... */
}
// set
window.localStorage.setItem(key, JSON.stringify(value));
And it does not provide any type-specific operation. (e.g. increasing number value, push to array)
// increasing count
const count = JSON.parse(window.localStorage.getItem(key));
window.localStorage.setItem(key, JSON.stringify(count + 1));
// push to array
const arr = JSON.parse(window.localStorage.getItem(key));
window.localStorage.setItem(key, JSON.stringify([...arr, value]));
So storage-typed
resolves all things above.
const count = TypedStorageFactory.create("count", 0); // NumberTypedStorage
count.increase();
count.get(); // 1
const arr = TypedStorageFactory.create("array", ["foo"]); // ArrayTypedStorage
arr.pop(); // "foo"
arr.push("bar");
arr.get(); // ["bar"]
/* and any other types... */
Creates TypedStorage by type of passed initial value. Note test code.
TypedStorageFactory.create<T>(key, initialValue, options);
(key, initialValue, options) => TypedStorage<T> | NumberTypedStorage | BooleanTypedStorage | ArrayTypedStorage<T[number]>
TypedStorage
by type of passed initial valuestring
T
TypedStorage
will be initialized withTypedStorageOptions<T>
Provides JSON parsing/stringifying. Note test code.
const storage = new TypedStorage<T>(key, initialValue, options);
storage.get();
storage.set(value);
constructor: (key, initialValue, options) => TypedStorage<T>
TypedStorage
by type of passed initial valuestring
T
TypedStorage
will be initialized withTypedStorageOptions<T>
get: () => T
set: (next) => void
T
interface TypedStorageOptions<T> {
storage?: Storage;
}
Storage
Storage
which TypedStorage
will useExtends number-specific methods based on TypedStorage
API. Note test code.
const storage = new NumberTypedStorage(key, initialValue, options);
storage.increase();
storage.decrease();
constructor: (key, initialValue, options) => TypedStorage<number>
TypedStorage
by type of passed initial valuestring
number
NumberTypedStorage
will be initialized withTypedStorageOptions<number>
increase: () => void
decrease: () => void
Extends boolean-specific methods based on TypedStorage
API. Note test code.
const storage = new BooleanTypedStorage(key, initialValue, options);
storage.toggle();
storage.true();
storage.false();
constructor: (key, initialValue, options) => TypedStorage<boolean>
TypedStorage
by type of passed initial valuestring
boolean
BooleanTypedStorage
will be initialized withTypedStorageOptions<boolean>
toggle: () => void
true: () => void
false: () => void
Extends number-specific methods based on TypedStorage
API. Note test code.
const storage = new ArrayTypedStorage<T>(key, initialValue, options);
storage.push(value);
storage.pop();
constructor: (key, initialValue, options) => TypedStorage<T[]>
TypedStorage
by type of passed initial valuestring
T[]
NumberTypedStorage
will be initialized withTypedStorageOptions<T[]>
push: (value: T) => void
pop: () => T | null
pop
returns null.FAQs
Web Storage wrapper that provides automatic JSON parsing/stringifying and type-specific features.
The npm package storage-typed receives a total of 0 weekly downloads. As such, storage-typed popularity was classified as not popular.
We found that storage-typed demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
PEP 770 proposes adding SBOM support to Python packages to improve transparency and catch hidden non-Python dependencies that security tools often miss.
Security News
Socket CEO Feross Aboukhadijeh discusses open source security challenges, including zero-day attacks and supply chain risks, on the Cyber Security Council podcast.
Security News
Research
Socket researchers uncover how threat actors weaponize Out-of-Band Application Security Testing (OAST) techniques across the npm, PyPI, and RubyGems ecosystems to exfiltrate sensitive data.