Options
All
  • Public
  • Public/Protected
  • All
Menu

select-list

Build Status Coverage Status Size

Highlights

  • 📦 Tiny (~500b minified + gzipped ES5)
  • 📖 Documented
  • ✅ Fully tested
  • 🚫 Zero dependencies
  • 😎 Immutable*

Inspiration / Credits

This module is directly inspired by the selectlist elm package by Richard Feldman.

Installation

$ npm install select-list

Usage

import SelectList from 'select-list'

const s = SelectList([1, 2, 3, 4], 5, [6, 7, 8, 9, 10])

s.selected // -> 5
s.size // -> 10

/* Set the next selected item with a function */
const { before, selected, after } = s.select(x => x === 7)
before // -> [1, 2, 3, 4, 5, 6]
selected // -> 7
after // -> [8, 9]

/* Impossible to move beyond the contents of the SelectList */
s.select(x => x > 42).selected // -> 7

/* Original SelectList remains unchanged */
s.selected // -> 5

Documentation

All documentation has been automatically generated by TypeDoc and is available online here and locally in the /docs directory.

Considerations

Of course JavaScript lacks true immutability by default — and in order to keep this module as small as possible, no runtime safeguards exists to ensure true immutability. For this same reason, all public properties must be treated as read-only. Immutability for this package is in reference to how each method that applies a transformation will do so in a manner that returns a new copy of a SelectList.

Index

External modules

Legend

  • Module
  • Object literal
  • Variable
  • Function
  • Function with type parameter
  • Index signature
  • Type alias
  • Enumeration
  • Enumeration member
  • Property
  • Method
  • Interface
  • Interface with type parameter
  • Constructor
  • Property
  • Method
  • Index signature
  • Class
  • Class with type parameter
  • Constructor
  • Property
  • Method
  • Accessor
  • Index signature
  • Inherited constructor
  • Inherited property
  • Inherited method
  • Inherited accessor
  • Protected property
  • Protected method
  • Protected accessor
  • Private property
  • Private method
  • Private accessor
  • Static property
  • Static method

Generated using TypeDoc