first

A helpful utility to pick first item in your array of data.

Demo

Store data:
	[
  {
    "name": "Svelte",
    "author": "Rich",
    "createdAt": 1695166985458
  },
  {
    "name": "Vue",
    "author": "Evan",
    "createdAt": 1695166985458
  }
]
					
First item:
	{
  "name": "Svelte",
  "author": "Rich",
  "createdAt": 1695166985458
}
					

Usage

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

const data = writable([
	{
		name: "Svelte",
		author: "Rich",
		createdAt: Date.now(),
	},
	{
		name: "Vue",
		author: "Evan",
		createdAt: Date.now(),
	},
]);

const firstElement = first(data);

// $firstElement => { name: "Svelte", author: "Rich", createdAt: number }
</script>