basant307/AI_Governance_Project
048
1# space-separated-tokens2 3[![Build][build-badge]][build]4[![Coverage][coverage-badge]][coverage]5[![Downloads][downloads-badge]][downloads]6[![Size][size-badge]][size]7 8Parse and stringify space-separated tokens.9 10## Contents11 12* [What is this?](#what-is-this)13* [When should I use this?](#when-should-i-use-this)14* [Install](#install)15* [Use](#use)16* [API](#api)17 * [`parse(value)`](#parsevalue)18 * [`stringify(values)`](#stringifyvalues)19* [Types](#types)20* [Compatibility](#compatibility)21* [Related](#related)22* [Contribute](#contribute)23* [Security](#security)24* [License](#license)25 26## What is this?27 28This is a tiny package that can parse and stringify space-separated tokens, as29used for example in the HTML `class` attribute, according to the30[WHATWG spec][spec].31 32## When should I use this?33 34This package is rather niche, it’s low-level and particularly useful when35working with [hast][].36 37## Install38 39This package is [ESM only][esm].40In Node.js (version 14.14+, 16.0+), install with [npm][]:41 42```sh43npm install space-separated-tokens44```45 46In Deno with [`esm.sh`][esmsh]:47 48```js49import {parse, stringify} from 'https://esm.sh/space-separated-tokens@2'50```51 52In browsers with [`esm.sh`][esmsh]:53 54```html55<script type="module">56 import {parse, stringify} from 'https://esm.sh/space-separated-tokens@2?bundle'57</script>58```59 60## Use61 62```js63import {parse, stringify} from 'space-separated-tokens'64 65parse(' foo\tbar\nbaz ')66//=> ['foo', 'bar', 'baz']67 68stringify(['foo', 'bar', 'baz'])69//=> 'foo bar baz'70```71 72## API73 74This package exports the identifiers `parse` and `stringify`.75There is no default export.76 77### `parse(value)`78 79Parse space-separated tokens (`string`) to an array of strings80(`Array<string>`), according to the [WHATWG spec][spec].81 82### `stringify(values)`83 84Serialize an array of strings or numbers (`Array<string|number>`) to85space-separated tokens (`string`).86 87> 👉 **Note**: it’s not possible to specify empty or whitespace only values.88 89## Types90 91This package is fully typed with [TypeScript][].92It exports no additional types.93 94## Compatibility95 96This package is at least compatible with all maintained versions of Node.js.97As of now, that is Node.js 14.14+ and 16.0+.98It also works in Deno and modern browsers.99 100## Related101 102* [`comma-separated-tokens`](https://github.com/wooorm/comma-separated-tokens)103 — parse/stringify comma-separated tokens104* [`collapse-white-space`](https://github.com/wooorm/collapse-white-space)105 — replace multiple white-space characters with a single space106* [`property-information`](https://github.com/wooorm/property-information)107 — info on HTML properties108 109## Contribute110 111Yes please!112See [How to Contribute to Open Source][contribute].113 114## Security115 116This package is safe.117 118## License119 120[MIT][license] © [Titus Wormer][author]121 122<!-- Definition -->123 124[build-badge]: https://github.com/wooorm/space-separated-tokens/workflows/main/badge.svg125 126[build]: https://github.com/wooorm/space-separated-tokens/actions127 128[coverage-badge]: https://img.shields.io/codecov/c/github/wooorm/space-separated-tokens.svg129 130[coverage]: https://codecov.io/github/wooorm/space-separated-tokens131 132[downloads-badge]: https://img.shields.io/npm/dm/space-separated-tokens.svg133 134[downloads]: https://www.npmjs.com/package/space-separated-tokens135 136[size-badge]: https://img.shields.io/bundlephobia/minzip/space-separated-tokens.svg137 138[size]: https://bundlephobia.com/result?p=space-separated-tokens139 140[npm]: https://docs.npmjs.com/cli/install141 142[esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c143 144[esmsh]: https://esm.sh145 146[typescript]: https://www.typescriptlang.org147 148[contribute]: https://opensource.guide/how-to-contribute/149 150[license]: license151 152[author]: https://wooorm.com153 154[spec]: https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#space-separated-tokens155 156[hast]: https://github.com/syntax-tree/hast157 