mark utility to splice and push into giant arrays.
This package exposes algorithms for splicing and pushing into giant arrays.
This package is useful when creating your own your own mark extensions and utilities.
This package is ESM only.
In Node.js with yarn:
yarn add @flex-development/mark-util-chunkedSee Git - Protocols | Yarn for details regarding installing from Git.
In Deno with esm.sh:
import { push, splice } from 'https://esm.sh/@flex-development/mark-util-chunked'In browsers with esm.sh:
<script type="module">
import { push, splice } from 'https://esm.sh/@flex-development/mark-util-chunked'
</script>import { push, splice } from '@flex-development/mark-util-chunked'
import { ev } from '@flex-development/mark-util-symbol'
import type { Token } from '@flex-development/mark'
// ...
const token: Token = events[open][1]
// ...
next = push(next, [[ev.enter, token, context], [ev.exit, token, context]])
// ...
splice(events, open - 1, index - open + 3, next)
// ...This package exports the identifiers push and splice.
There is no default export.
Append items to the end of list.
Items are added in batches to prevent V8 from hanging.
When list is empty, items is returned to prevent a potentially expensive operation.
T(any) — The list item type
list(T[]) — the list to operate onitems(T[]) — the items to inject intolist
(T[]) items when list is empty, list with appended items otherwise
Like Array#splice, but smarter.
Remove items from list and, if necessary, insert new items in their place, returning the deleted elements.
👉 Note:
Array#splicetakes all items to be inserted as individual arguments which causes a stack overflow in V8 when trying to insert a large number of items (i.e. 100k).
T(any) — The list item type
list(T[]) — the list to operate onstart(Numeric|number) — the index inlistto remove and/or insert items at (can be negative)remove(Numeric|number) — the number of items to removeitems(List<T>|null|undefined, optional) — the items to inject intolist
(T[]) The list of removed items
This package is fully typed with TypeScript. It exports no additional types.
mark-util-chunked adheres to semver.
See CONTRIBUTING.md.
This project has a code of conduct. By interacting with this repository, organization, or community you agree to abide by its terms.
Small primitives power larger systems. Support long-term stability by sponsoring Flex Development.
@flex-development/mark— the specification@flex-development/mark-compiler— finite state machine event compiler@flex-development/mark-parser— finite state machine parser