Files
30-seconds-of-code/node_modules/space-separated-tokens/readme.md
2019-08-20 15:52:05 +02:00

95 lines
2.3 KiB
Markdown
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][].
## Installation
[npm][]:
```bash
npm install space-separated-tokens
```
## Usage
```javascript
var spaceSeparated = require('space-separated-tokens')
spaceSeparated.parse(' foo\tbar\nbaz ')
//=> ['foo', 'bar', 'baz']
spaceSeparated.stringify(['foo', 'bar', 'baz'])
//=> 'foo bar baz'
```
## API
### `spaceSeparated.parse(value)`
Parse space-separated tokens to an array of strings, according to the [spec][].
###### Parameters
* `value` (`string`) — space-separated tokens.
###### Returns
`Array.<string>` — List of tokens.
### `spaceSeparated.stringify(values)`
Compile an array of strings to space-separated tokens.
Note that its not possible to specify empty or white-space only values.
###### Parameters
* `values` (`Array.<string>`) — List of tokens.
###### Returns
`string` — Space-separated tokens.
## 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://img.shields.io/travis/wooorm/space-separated-tokens.svg
[build]: https://travis-ci.org/wooorm/space-separated-tokens
[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