A helpful utility to pick data from a store by keys. If only one key is specified the derivative will be the value else the derivative will a partial record of the store value.


Store data:
  "name": "Svelte",
  "author": "Rich",
  "createdAt": 1695166985464
Picked Data 'name':
Picked Data 'name' and 'createdAt':
  "name": "Svelte",
  "createdAt": 1695166985464


<script lang="ts">
import { pick } from "svelte-legos";
import { writable } from "svelte/store";

const data = writable({
	name: "Svelte",
	author: "Rich",
	createdAt: Date.now(),

const name = pick(data, "name"); // $name => "Svelte"

const nameAndAuthor = pick(data, "name", "author");
// $nameAndCreatedAt => { name: "Svelte", author: "Rich" }