Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

space-separated-tokens

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

space-separated-tokens - npm Package Compare versions

Comparing version 2.0.1 to 2.0.2

20

index.d.ts
/**
* Parse space separated tokens to an array of strings.
* Parse space-separated tokens to an array of strings.
*
* @param {string} value Space separated tokens
* @returns {Array.<string>} Tokens
* @param {string} value
* Space-separated tokens.
* @returns {Array<string>}
* List of tokens.
*/
export function parse(value: string): Array<string>;
export function parse(value: string): Array<string>
/**
* Serialize an array of strings as space separated tokens.
* Serialize an array of strings as space separated-tokens.
*
* @param {Array.<string|number>} values Tokens
* @returns {string} Space separated tokens
* @param {Array<string|number>} values
* List of tokens.
* @returns {string}
* Space-separated tokens.
*/
export function stringify(values: Array<string | number>): string;
export function stringify(values: Array<string | number>): string

16

index.js
/**
* Parse space separated tokens to an array of strings.
* Parse space-separated tokens to an array of strings.
*
* @param {string} value Space separated tokens
* @returns {Array.<string>} Tokens
* @param {string} value
* Space-separated tokens.
* @returns {Array<string>}
* List of tokens.
*/

@@ -13,6 +15,8 @@ export function parse(value) {

/**
* Serialize an array of strings as space separated tokens.
* Serialize an array of strings as space separated-tokens.
*
* @param {Array.<string|number>} values Tokens
* @returns {string} Space separated tokens
* @param {Array<string|number>} values
* List of tokens.
* @returns {string}
* Space-separated tokens.
*/

@@ -19,0 +23,0 @@ export function stringify(values) {

{
"name": "space-separated-tokens",
"version": "2.0.1",
"version": "2.0.2",
"description": "Parse and stringify space separated tokens",

@@ -34,20 +34,18 @@ "license": "MIT",

"devDependencies": {
"@types/tape": "^4.0.0",
"@types/node": "^18.0.0",
"c8": "^7.0.0",
"prettier": "^2.0.0",
"remark-cli": "^9.0.0",
"remark-preset-wooorm": "^8.0.0",
"rimraf": "^3.0.0",
"tape": "^5.0.0",
"remark-cli": "^11.0.0",
"remark-preset-wooorm": "^9.0.0",
"type-coverage": "^2.0.0",
"typescript": "^4.0.0",
"xo": "^0.39.0"
"xo": "^0.52.0"
},
"scripts": {
"prepublishOnly": "npm run build",
"prepack": "npm run build && npm run format",
"build": "tsc --build --clean && tsc --build && type-coverage",
"format": "remark . -qfo && prettier . -w --loglevel warn && xo --fix",
"prebuild": "rimraf \"*.d.ts\"",
"build": "tsc",
"test-api": "node test",
"test-coverage": "c8 --check-coverage --branches 100 --functions 100 --lines 100 --statements 100 --reporter lcov node test.js",
"test": "npm run format && npm run build && npm run test-coverage"
"test-api": "node --conditions development test.js",
"test-coverage": "c8 --check-coverage --100 --reporter lcov npm run test-api",
"test": "npm run build && npm run format && npm run test-coverage"
},

@@ -63,7 +61,3 @@ "prettier": {

"xo": {
"prettier": true,
"esnext": false,
"ignore": [
"space-separated-tokens.js"
]
"prettier": true
},

@@ -70,0 +64,0 @@ "remarkConfig": {

@@ -8,11 +8,36 @@ # space-separated-tokens

Parse and stringify space-separated tokens according to the [spec][].
Parse and stringify space-separated tokens.
## Contents
* [What is this?](#what-is-this)
* [When should I use this?](#when-should-i-use-this)
* [Install](#install)
* [Use](#use)
* [API](#api)
* [`parse(value)`](#parsevalue)
* [`stringify(values)`](#stringifyvalues)
* [Types](#types)
* [Compatibility](#compatibility)
* [Related](#related)
* [Contribute](#contribute)
* [Security](#security)
* [License](#license)
## What is this?
This is a tiny package that can parse and stringify space-separated tokens, as
used for example in the HTML `class` attribute, according to the
[WHATWG spec][spec].
## When should I use this?
This package is rather niche, it’s low-level and particularly useful when
working with [hast][].
## Install
This package is ESM only: Node 12+ is needed to use it and it must be `import`ed
instead of `require`d.
This package is [ESM only][esm].
In Node.js (version 14.14+, 16.0+), install with [npm][]:
[npm][]:
```sh

@@ -22,5 +47,19 @@ npm install space-separated-tokens

## Usage
In Deno with [`esm.sh`][esmsh]:
```js
import {parse, stringify} from 'https://esm.sh/space-separated-tokens@2'
```
In browsers with [`esm.sh`][esmsh]:
```html
<script type="module">
import {parse, stringify} from 'https://esm.sh/space-separated-tokens@2?bundle'
</script>
```
## Use
```js
import {parse, stringify} from 'space-separated-tokens'

@@ -37,3 +76,3 @@

This package exports the following identifiers: `parse`, `stringify`.
This package exports the identifiers `parse` and `stringify`.
There is no default export.

@@ -43,19 +82,41 @@

Parse space separated tokens (`string`) to an array of strings (`string[]`),
according to the [spec][].
Parse space-separated tokens (`string`) to an array of strings
(`Array<string>`), according to the [WHATWG spec][spec].
### `stringify(values)`
Serialize an array of strings (`string[]`) to space separated tokens (`string`).
Note that it’s not possible to specify empty or whitespace only values.
Serialize an array of strings or numbers (`Array<string|number>`) to
space-separated tokens (`string`).
> 👉 **Note**: it’s not possible to specify empty or whitespace only values.
## Types
This package is fully typed with [TypeScript][].
It exports no additional types.
## Compatibility
This package is at least compatible with all maintained versions of Node.js.
As of now, that is Node.js 14.14+ and 16.0+.
It also works in Deno and modern browsers.
## Related
* [`comma-separated-tokens`](https://github.com/wooorm/comma-separated-tokens)
— parse/stringify comma-separated tokens
* [`collapse-white-space`](https://github.com/wooorm/collapse-white-space)
— Replace multiple white-space characters with a single 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
— info on HTML properties
## Contribute
Yes please!
See [How to Contribute to Open Source][contribute].
## Security
This package is safe.
## License

@@ -85,2 +146,10 @@

[esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
[esmsh]: https://esm.sh
[typescript]: https://www.typescriptlang.org
[contribute]: https://opensource.guide/how-to-contribute/
[license]: license

@@ -90,2 +159,4 @@

[spec]: https://html.spec.whatwg.org/#space-separated-tokens
[spec]: https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#space-separated-tokens
[hast]: https://github.com/syntax-tree/hast
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc