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

@solid-primitives/storage

Package Overview
Dependencies
Maintainers
2
Versions
45
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@solid-primitives/storage - npm Package Compare versions

Comparing version 0.0.106 to 1.0.0

dist/cjs/cookies.js

6

dist/storage.d.ts

@@ -31,7 +31,3 @@ import { Accessor, Setter } from "solid-js";

];
export declare function createStorage<O, T>(props?: AnyStorageProps<Storage | StorageWithOptions<O>, O, T>): [
store: StorageObject<T>,
setter: StorageSetter<T, O>,
actions: StorageActions<T>
];
export declare function createStorage<O, T>(props?: AnyStorageProps<Storage | StorageWithOptions<O>, O, T>): [store: StorageObject<T>, setter: StorageSetter<T, O>, actions: StorageActions<T>];
/**

@@ -38,0 +34,0 @@ * like createStore, but bound to an asynchronous localStorage-like API

import { createEffect, createSignal } from "solid-js";
export function createStorage(props) {
const apis = props?.api ? (Array.isArray(props.api) ? props.api : [props.api]) : [globalThis.localStorage].filter(Boolean);
const apis = props?.api
? Array.isArray(props.api)
? props.api
: [props.api]
: [globalThis.localStorage].filter(Boolean);
const prefix = props?.prefix ? `${props.prefix}.` : "";

@@ -49,3 +53,3 @@ const signals = new Map();

apis.forEach(api => {
if (typeof api.getAll === 'function') {
if (typeof api.getAll === "function") {
const values = api.getAll();

@@ -137,3 +141,3 @@ for (const key of values) {

await Promise.all(apis.map(async (api) => {
if (typeof api.getAll === 'function') {
if (typeof api.getAll === "function") {
const values = await api.getAll();

@@ -183,3 +187,7 @@ for (const key of values) {

export function createStorageSignal(key, initialValue, props) {
const apis = props?.api ? (Array.isArray(props.api) ? props.api : [props.api]) : [globalThis.localStorage].filter(Boolean);
const apis = props?.api
? Array.isArray(props.api)
? props.api
: [props.api]
: [globalThis.localStorage].filter(Boolean);
const prefix = props?.prefix ? `${props.prefix}.` : "";

@@ -186,0 +194,0 @@ const read = () => apis.reduce((result, api) => {

{
"name": "@solid-primitives/storage",
"version": "0.0.106",
"version": "1.0.0",
"description": "Primitive that provides reactive wrappers for storage access",

@@ -15,2 +15,7 @@ "author": "Alex Lohr <alex.lohr@logmein.com>",

],
"exports": {
"require": "./dist/cjs/index.js",
"import": "./dist/index.js",
"default": "./dist/index.js"
},
"sideEffects": "false",

@@ -20,3 +25,3 @@ "scripts": {

"clean": "rimraf dist/",
"build": "tsc",
"build": "tsc && tsc --target es5 --module commonjs --declaration false --outDir ./dist/cjs",
"test": "jest"

@@ -33,3 +38,3 @@ },

"@babel/preset-env": "7.15.6",
"@types/jest": "27.0.1",
"@types/jest": "^27.0.2",
"babel-preset-solid": "1.1.5",

@@ -43,3 +48,3 @@ "jest": "27.0.1",

"dependencies": {
"solid-js": "^1.1.5"
"solid-js": "^1.2.5"
},

@@ -46,0 +51,0 @@ "jest": {

@@ -0,4 +1,14 @@

---
Name: storage
Stage: 3
Package: "@solid-primitives/storage"
Primitives: createStorage, createAsyncStorage, createStorageSignal, createLocalStorage, createSessionStorage
Category: Browser APIs
---
# @solid-primitives/storage
[![lerna](https://img.shields.io/badge/maintained%20with-lerna-cc00ff.svg)](https://lerna.js.org/)
[![size](https://img.shields.io/bundlephobia/minzip/@solid-primitives/storage)](https://bundlephobia.com/package/@solid-primitives/storage)
[![size](https://img.shields.io/npm/v/@solid-primitives/storage)](https://www.npmjs.com/package/@solid-primitives/storage)

@@ -17,5 +27,5 @@ Creates a primitive to reactively access both synchronous and asynchronous persistent storage APIs similar to localStorage.

const [store, setStore, {
remove: (key: string) => void;
clear: () => void;
toJSON: () => ({ [key: string]: string });
remove: (key: string) => void;
clear: () => void;
toJSON: () => ({ [key: string]: string });
}] = createStorage({ api: sessionStorage, prefix: 'my-app' });

@@ -122,5 +132,5 @@

```ts
const [value, setValue] = createStorageSignal('value', { api: cookieStorage });
const [value, setValue] = createStorageSignal("value", { api: cookieStorage });
setValue('value');
setValue("value");
value(); // 'value'

@@ -154,2 +164,6 @@ ```

1.0.0
First proper release of storage engine with CJS support.
</details>
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