Urara-Blog/node_modules/.pnpm-store/v3/files/bc/01a51b09976309c0c8cd128ff6af8f2e08468f47a3e8bb876e58d98056c214926fe6e70f70de3a7faa46398e9a6c4681e27ce19b42e25a1097420f9899689b
2022-08-14 01:14:53 +08:00

85 lines
2.2 KiB
Text
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# space-separated-tokens
[![Build][build-badge]][build]
[![Coverage][coverage-badge]][coverage]
[![Downloads][downloads-badge]][downloads]
[![Size][size-badge]][size]
Parse and stringify space-separated tokens according to the [spec][].
## Install
This package is ESM only: Node 12+ is needed to use it and it must be `import`ed
instead of `require`d.
[npm][]:
```sh
npm install space-separated-tokens
```
## Usage
```js
import {parse, stringify} from 'space-separated-tokens'
parse(' foo\tbar\nbaz ')
//=> ['foo', 'bar', 'baz']
stringify(['foo', 'bar', 'baz'])
//=> 'foo bar baz'
```
## API
This package exports the following identifiers: `parse`, `stringify`.
There is no default export.
### `parse(value)`
Parse space separated tokens (`string`) to an array of strings (`string[]`),
according to the [spec][].
### `stringify(values)`
Serialize an array of strings (`string[]`) to space separated tokens (`string`).
Note that its not possible to specify empty or whitespace only values.
## Related
* [`collapse-white-space`](https://github.com/wooorm/collapse-white-space)
— Replace multiple white-space characters with a single space
* [`property-information`](https://github.com/wooorm/property-information)
— Information on HTML properties
* [`comma-separated-tokens`](https://github.com/wooorm/comma-separated-tokens)
— Parse/stringify comma-separated tokens
## License
[MIT][license] © [Titus Wormer][author]
<!-- Definition -->
[build-badge]: https://github.com/wooorm/space-separated-tokens/workflows/main/badge.svg
[build]: https://github.com/wooorm/space-separated-tokens/actions
[coverage-badge]: https://img.shields.io/codecov/c/github/wooorm/space-separated-tokens.svg
[coverage]: https://codecov.io/github/wooorm/space-separated-tokens
[downloads-badge]: https://img.shields.io/npm/dm/space-separated-tokens.svg
[downloads]: https://www.npmjs.com/package/space-separated-tokens
[size-badge]: https://img.shields.io/bundlephobia/minzip/space-separated-tokens.svg
[size]: https://bundlephobia.com/result?p=space-separated-tokens
[npm]: https://docs.npmjs.com/cli/install
[license]: license
[author]: https://wooorm.com
[spec]: https://html.spec.whatwg.org/#space-separated-tokens