@stagas/immutable-list
TypeScript icon, indicating that this package has built-in type declarations

1.1.0 • Public • Published

@stagas/immutable-list

Immutable list.

npm i @stagas/immutable-list pnpm add @stagas/immutable-list yarn add @stagas/immutable-list

Examples

# node
    # view source example/node.ts

    import { add } from '@stagas/immutable-list'
    
    console.log(add(1, 2))
# web
    # view source example/web.ts

    import { add } from '@stagas/immutable-list'
    
    const main = document.querySelector('main')!
    
    main.innerHTML = `<h1>1 + 2 = ${add(1, 2)}</h1>`

🥁 Use this template 🥁

Features

  • TypeScript with SWC
  • JSX/TSX out of the box
  • Outputs both CommonJS and ES Modules, ready to publish on npm
  • Automatic dist bundling using bunzee
  • Documentation generation using dokio
  • Isomorphic Node.js and real browser testing incl. coverage and snapshots with utr
  • Examples / Playground using devito
  • Evergreen using pull-configs
  • ESLint
  • dprint
  • Husky

API

# JSONAble

    # constructor(data)
    # onceSymbol

      symbol

    # emit(eventName, args)

      # eventName
      # args

        Parameters<T [K]>

      emit<K>(eventName, args)  =>

# off(eventName, callback)

    # eventName
    # callback

    off<K>(eventName, callback)  =>

# on(eventName, callback, options)

    # eventName
    # callback
    # options

      EventEmitterOptions

    on<K>(eventName, callback, options)  =>

      Off
# once(eventName, callback)

    # eventName
    # callback

    once<K>(eventName, callback)  =>

# toJSON(this)
# List

    # constructor(data)

      # new List()

        List<T, R>

        # data  =  {}

          Partial<List<T, Record<string, any>>>

    # ctor
    # items  =  []

      T []

    # onceSymbol

      symbol

    # add(item)

      # item

      add(item)  =>

# emit(eventName, args)

    # eventName
    # args

      Parameters<R [K]>

    emit<K>(eventName, args)  =>

# equals(other)

    # other

      List<T, Record<string, any>>

    equals(other)  =>

      boolean
# getById(itemId)

    # itemId

      string | false

    getById<U extends  ListItem>(itemId)  =>

# hasId(itemId)

    # itemId

      string

    hasId(itemId)  =>

      boolean
# insertAfterIndex(index, newItem)

    # index

      number

    # newItem

    insertAfterIndex(index, newItem)  =>

# insertAt(index, newItem)

    # index

      number

    # newItem

    insertAt(index, newItem)  =>

# mergeEach(data)

    # data

      Partial<T>

    mergeEach(data)  =>

# off(eventName, callback)

    # eventName
    # callback

    off<K>(eventName, callback)  =>

# on(eventName, callback, options)

    # eventName
    # callback
    # options

      EventEmitterOptions

    on<K>(eventName, callback, options)  =>

      Off
# once(eventName, callback)

    # eventName
    # callback

    once<K>(eventName, callback)  =>

# removeById(itemId)

    # itemId

      string

    removeById(itemId)  =>

# setById(itemId, newItem)

    # itemId

      string

    # newItem

    setById<U extends  ListItem>(itemId, newItem)  =>

# toJSON(this)
# updateById(itemId, updateData)

    # itemId

      string

    # updateData

      Partial<U>

    updateById<U extends  ListItem>(itemId, updateData)  =>

# ListItem

    object & {

    # id

      string

    }
# createOrReturn(ctor, prev, key, next)

    # ctor
    # prev
    # key
    # next

    createOrReturn<T extends  JSONAble<Record<string, any>, T>, TKey, TCtor extends  Class<T>>(ctor, prev, key, next)  =>

# getItemInListById(list, itemId)

    # list

      T []

    # itemId

      string | false

    getItemInListById<T extends  ListItem>(list, itemId)  =>

# insertItemInListAtIndex(list, index, newItem)

    # list

      T []

    # index

      number

    # newItem

    insertItemInListAtIndex<T extends  ListItem>(list, index, newItem)  =>

      T []
# removeItemInListById(list, itemId)

    # list

      T []

    # itemId

      string

    removeItemInListById<T extends  ListItem>(list, itemId)  =>

      T []
# setItemInListById(list, itemId, newItem)

    # list

      T []

    # itemId

      string

    # newItem

    setItemInListById<T extends  ListItem>(list, itemId, newItem)  =>

      T []
# updateItemInListById(list, itemId, updateData)

    # list

      T []

    # itemId

      string

    # updateData

      Partial<T>

    updateItemInListById<T extends  ListItem>(list, itemId, updateData)  =>

      any []
# updateOrReturn(target, updateData)

    # target
    # updateData

      Partial<T>

    updateOrReturn<T>(target, updateData)  =>

      any

Credits

Contributing

Fork or edit and submit a PR.

All contributions are welcome!

License

MIT © 2022 stagas

Readme

Keywords

none

Package Sidebar

Install

npm i @stagas/immutable-list

Weekly Downloads

9

Version

1.1.0

License

MIT

Unpacked Size

164 kB

Total Files

18

Last publish

Collaborators

  • stagas