# turbo-storage

> Turbo Storage Shared storage cross domain for svelte in static applications

Latest version **0.0.3** (published 2022-09-19) · 0 weekly downloads

## Install

```sh
npm install turbo-storage
pnpm add turbo-storage
yarn add turbo-storage
bun add turbo-storage
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types; low quality score; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.3 |
| Published | 2022-09-19 |
| First published | 2022-09-15 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | ESM |
| Dependencies | 0 |
| Unpacked size | 10.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | davidponc-softengy |

## Links

- npm: https://www.npmjs.com/package/turbo-storage
- npm.io page: https://npm.io/package/turbo-storage

## Recent versions

- 0.0.3 (latest) — 2022-09-19
- 0.0.2 — 2022-09-19
- 0.0.1 — 2022-09-15

## README

<h1 align='center'>Turbo Storage</h1>
<p align='center'>Shared storage cross domain for svelte in static applications</p>

## Usage

...

## Provider

```html
<script>
	import { Provider } from 'turbo-storage/provider';
</script>

<Provider.Host consumers={['https://domain.com']} />
```

## Consumer

recommended initialize in `+layout.ts`.

```ts
import { createConsumer } from '$lib/consumer';
import { consumer } from '../stores/consumer';
import type { LayoutLoad } from './$types';
import { PUBLIC_CONSUMER_URL } from '$env/static/public';

export const ssr = false;
export const prerender = true;

export const load: LayoutLoad = () => {
	consumer.set(createConsumer(PUBLIC_CONSUMER_URL));
};
```

> we using svelte storages

## Persist data

The `persist` function recive an object with any keys and values.
The values can be primitives or complex.

```ts
await $consumer.persist({ count: 0, darkMode: false });
```

## Obtain data

The `obtain` function recive `n` string args.

```ts
const { count, darkMode } = await $consumer.obtain('count', 'darkMode');
```

The `obtain` function detect of arguments and build object returned with `unknown` values.

```ts
(method) Consumser.obtain<["key"]>(keys_0: "key"): Promise<{
    key: unknown;
}>
```

After. we recommend validates values of response.
Where the validate function return value with type

```ts
const count = validateCount(storagedCount);
```

## Delete data

To delete keys of storage, pass null as values in `persist` function.

```ts
await $consumer.persist({ count: null, darkMode: null });
```

---
_Source: https://npm.io/package/turbo-storage · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
