CoolFace
Datasetpublic

basant307/AI_Governance_Project

sourceHugging Faceapache-2.0updated 2mo agoView on Hugging Face
0likes48downloads
1# micromark-util-chunked2 3[![Build][build-badge]][build]4[![Coverage][coverage-badge]][coverage]5[![Downloads][downloads-badge]][downloads]6[![Size][bundle-size-badge]][bundle-size]7[![Sponsors][sponsors-badge]][opencollective]8[![Backers][backers-badge]][opencollective]9[![Chat][chat-badge]][chat]10 11[micromark][] utility to splice and push with giant arrays.12 13## Contents14 15* [What is this?](#what-is-this)16* [When should I use this?](#when-should-i-use-this)17* [Install](#install)18* [Use](#use)19* [API](#api)20  * [`push(list, items)`](#pushlist-items)21  * [`splice(list, start, remove, items)`](#splicelist-start-remove-items)22* [Types](#types)23* [Compatibility](#compatibility)24* [Security](#security)25* [Contribute](#contribute)26* [License](#license)27 28## What is this?29 30This package exposes an algorithm to splice for giant arrays, which V8 bugs31out on.32 33## When should I use this?34 35This package might be useful when you are making your own micromark extensions.36 37## Install38 39This package is [ESM only][esm].40In Node.js (version 16+), install with [npm][]:41 42```sh43npm install micromark-util-chunked44```45 46In Deno with [`esm.sh`][esmsh]:47 48```js49import {push, splice} from 'https://esm.sh/micromark-util-chunked@1'50```51 52In browsers with [`esm.sh`][esmsh]:53 54```html55<script type="module">56  import {push, splice} from 'https://esm.sh/micromark-util-chunked@1?bundle'57</script>58```59 60## Use61 62```js63import {push, splice} from 'micromark-util-chunked'64 65// …66 67nextEvents = push(nextEvents, [68  ['enter', events[open][1], context],69  ['exit', events[open][1], context]70])71 72// …73 74splice(events, open - 1, index - open + 3, nextEvents)75 76// …77```78 79## API80 81This module exports the identifiers [`push`][api-push]82and [`splice`][api-splice].83There is no default export.84 85### `push(list, items)`86 87Append `items` (an array) at the end of `list` (another array).88When `list` was empty, returns `items` instead.89 90This prevents a potentially expensive operation when `list` is empty,91and adds items in batches to prevent V8 from hanging.92 93###### Parameters94 95* `list` (`Array<unknown>`)96  — list to operate on97* `items` (`Array<unknown>`)98  — items to add to `list`99 100###### Returns101 102Either `list` or `items` (`Array<unknown>`).103 104### `splice(list, start, remove, items)`105 106Like `Array#splice`, but smarter for giant arrays.107 108`Array#splice` takes all items to be inserted as individual argument which109causes a stack overflow in V8 when trying to insert 100k items for instance.110 111Otherwise, this does not return the removed items, and takes `items` as an112array instead of rest parameters.113 114###### Parameters115 116* `list` (`Array<unknown>`)117  — list to operate on118* `start` (`number`)119  — index to remove/insert at (can be negative)120* `remove` (`number`)121  — number of items to remove122* `items` (`Array<unknown>`)123  — items to inject into `list`124 125###### Returns126 127Nothing (`undefined`).128 129## Types130 131This package is fully typed with [TypeScript][].132It exports no additional types.133 134## Compatibility135 136Projects maintained by the unified collective are compatible with maintained137versions of Node.js.138 139When we cut a new major release, we drop support for unmaintained versions of140Node.141This means we try to keep the current release line,142`micromark-util-chunked@2`, compatible with Node.js 16.143This package works with `micromark@3`.144 145## Security146 147This package is safe.148See [`security.md`][securitymd] in [`micromark/.github`][health] for how to149submit a security report.150 151## Contribute152 153See [`contributing.md`][contributing] in [`micromark/.github`][health] for ways154to get started.155See [`support.md`][support] for ways to get help.156 157This project has a [code of conduct][coc].158By interacting with this repository, organisation, or community you agree to159abide by its terms.160 161## License162 163[MIT][license] © [Titus Wormer][author]164 165<!-- Definitions -->166 167[build-badge]: https://github.com/micromark/micromark/workflows/main/badge.svg168 169[build]: https://github.com/micromark/micromark/actions170 171[coverage-badge]: https://img.shields.io/codecov/c/github/micromark/micromark.svg172 173[coverage]: https://codecov.io/github/micromark/micromark174 175[downloads-badge]: https://img.shields.io/npm/dm/micromark-util-chunked.svg176 177[downloads]: https://www.npmjs.com/package/micromark-util-chunked178 179[bundle-size-badge]: https://img.shields.io/badge/dynamic/json?label=minzipped%20size&query=$.size.compressedSize&url=https://deno.bundlejs.com/?q=micromark-util-chunked180 181[bundle-size]: https://bundlejs.com/?q=micromark-util-chunked182 183[sponsors-badge]: https://opencollective.com/unified/sponsors/badge.svg184 185[backers-badge]: https://opencollective.com/unified/backers/badge.svg186 187[opencollective]: https://opencollective.com/unified188 189[npm]: https://docs.npmjs.com/cli/install190 191[esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c192 193[esmsh]: https://esm.sh194 195[chat-badge]: https://img.shields.io/badge/chat-discussions-success.svg196 197[chat]: https://github.com/micromark/micromark/discussions198 199[license]: https://github.com/micromark/micromark/blob/main/license200 201[author]: https://wooorm.com202 203[health]: https://github.com/micromark/.github204 205[securitymd]: https://github.com/micromark/.github/blob/main/security.md206 207[contributing]: https://github.com/micromark/.github/blob/main/contributing.md208 209[support]: https://github.com/micromark/.github/blob/main/support.md210 211[coc]: https://github.com/micromark/.github/blob/main/code-of-conduct.md212 213[typescript]: https://www.typescriptlang.org214 215[micromark]: https://github.com/micromark/micromark216 217[api-push]: #pushlist-items218 219[api-splice]: #splicelist-start-remove-items220 
basant307/AI_Governance_Project · CoolFace