svelte-array-helper

2.0.2 • Public • Published

svelte-array-helper

A dead simple helper for modifying arrays in Svelte, and make the code more readable.

This library only contains the array methods, that mutate the array

Installation

npm install svelte-array-helper

Usage

// Import single static methods
import { push, pop, splice } from 'svelte-array-helper'

// Import class
import ArrayHelper from 'svelte-array-helper'
let arrayHelper = new ArrayHelper // <- Instaciate it

Example

import { push } from 'svelte-array-helper'

let list = [0,1,2,3]

function addToList(itemToAdd) {
  list = push(list, itemToAdd)
}

Note

All methods will return the modified array

push(array, value)

push(array, value)

pop()

push(array)

splice(array, ...args)

splice(array, 0, 1, 'item1', 'item2' etc..)

copyWithin(array, ...args)

copyWithin(array, ...arguments)

fill(array, ...args)

fill(array, ...arguments)

reverse(array)

reverse(array)

sort(array, ...args)

sort(array, ...arguments)

/svelte-array-helper/

    Package Sidebar

    Install

    npm i svelte-array-helper

    Weekly Downloads

    4

    Version

    2.0.2

    License

    MIT

    Unpacked Size

    5.12 kB

    Total Files

    4

    Last publish

    Collaborators

    • dasmikko