JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 10422
  • Score
    100M100P100Q162624F
  • License ISC

A writable derived store for objects and arrays

Package Exports

  • svelte-keyed
  • svelte-keyed/dist/index.es.js
  • svelte-keyed/dist/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (svelte-keyed) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

svelte-keyed-banner

svelte-keyed

npm version npm downloads license build coverage size

A writable derived store for objects and arrays!

Objects are keyed

const name = writable({ first: "Rich", last: "Harris" });
const firstName = keyed(name, "first");

$firstName = "Bryan";
console.log($name); // { first: "Bryan", last: "Harris" };

Arrays are indexed

const history = writable(["one", "two", "three"]);
const previousEdit = indexed(history, 1);

$previousEdit = "four";
console.log($history); // ["one", "four", "three"];

Installation

$ npm i -D svelte-keyed

Since Svelte automatically bundles all required dependencies, you only need to install this package as a dev dependency with the -D flag.

API

keyed takes a writable object store and a property name, while indexed takes a writable array store and an index value.

Both return a writable store whose changes are reflected on the original store.