@aredridel/svelte-lens-store
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

Svelte Lens Store

A functional lens into svelte stores

Use

bijectiveMapping

import { get, writable } from "svelte/store";

const base = writable(`{"hello":"world"}`);

const mapped = bijectiveMapping(base, JSON.parse, JSON.stringify);

get(mapped) // { hello: "world" }

mapped.set([1, 2, 3]);

get(base) // "[1,2,3]";

focusOnProperty

const base = writable({ hello: "world" } as { hello: any });

const mapped = focusOnProperty(base, "hello");

get(mapped) // "world";

mapped.set([1, 2, 3]);

get(base) // { hello: [1, 2, 3] }

Package Sidebar

Install

npm i @aredridel/svelte-lens-store

Weekly Downloads

1

Version

1.0.0

License

ISC

Unpacked Size

4.23 kB

Total Files

6

Last publish

Collaborators

  • aredridel