2.0.2 • Published 1 year ago

space-separated-tokens v2.0.2

Weekly downloads
2,787,533
License
MIT
Repository
github
Last release
1 year ago

space-separated-tokens

Build Coverage Downloads Size

Parse and stringify space-separated tokens.

Contents

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.

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. In Node.js (version 14.14+, 16.0+), install with npm:

npm install space-separated-tokens

In Deno with esm.sh:

import {parse, stringify} from 'https://esm.sh/space-separated-tokens@2'

In browsers with esm.sh:

<script type="module">
  import {parse, stringify} from 'https://esm.sh/space-separated-tokens@2?bundle'
</script>

Use

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 identifiers parse and stringify. There is no default export.

parse(value)

Parse space-separated tokens (string) to an array of strings (Array<string>), according to the WHATWG spec.

stringify(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

Contribute

Yes please! See How to Contribute to Open Source.

Security

This package is safe.

License

MIT © Titus Wormer

hastscriptremark-external-linkshast-util-to-parse5@daimond113/solid-markdowntmp-hast-util-to-jsxcogoportutils@saaspe/components@everything-registry/sub-chunk-2802nois-react-toastnovacap-components@skedulr/nebula-ui-libraryappcharge-checkoutappcharge-checkout-reactjs-sdk@azu/hast-util-to-html@beeswax/react-markdown-asynccommoditenetur@cute-apocalypse/react-tree@breadio/markdown@blkmarketco/components-libraryzzzxxxyyy321123qjc2-blockpolyglot-component-libraryreact-markdown-customkeypropreact-form-component-libraryreact-markdown-v8.0.3parvan_componentsparvan_reactjs_componentssequelcomponentunified-message-controltype-libaryu-libraryxast-util-selecttesting-storybooktldrawligninshainasvelte-component-libsolid-markdownremark-spoilersremark-alignremark-custom-blocksremark-text-alignmentrehype-extended-linksrehype-external-linksrehype-remove-meta-http-equivrehype-mermaidrehype-mermaidjsrehype-minify-enumerated-attributerehype-mdx-code-props@cquiroz/react-markdown@img-arena/img-ui-mui-theme@img-arena/ui-core@dimcheify/dimui@digitalrakesh/jsui@enyaxu/hast-util-to-html@furmeet/solid-markdown@freepress/core@frctl/fractal-plugin-preprocess-templatesantdsite@itayn-fireberry-org/itayn-testdesign-system-fitbank-450@kunet/solid-markdown-but-updated@juanaraneta/dept-central-lib-client@lego-js/tests@lskjs/markdowngformat-hast-to-htmlgformat-hast-to-html-tmp@newageerp/v3.utils.markdown@nppkg/react-dnd@podlubnaja/ui-kithast-util-properties-to-mdx-jsx-attributeshast-util-selecthast-util-to-estreehast-util-to-htmlhast-util-to-html-nshast-util-to-jsx-runtimehast-util-to-xasthastscript-case-sensitivehastscript-jsxhastscript-nshast-util-classnames@pretext-book/jsx@qihoo/wx2qh@rcpress/core@shivarajapple/first-library@starptech/prettyhtml-hast-to-html@starptech/prettyhtml-hastscript@skeetboothppq/component-library@swimlane/docspa-remark-preset@vitali_shcherbina/styled-lib@uivjs/vue-markdown-previewmarkdown-vue@wacoco/y@wayowe/prettyhtml-hast-to-html@wayowe/prettyhtml-hastscriptadarshsinghal-editor-preview@zentered/solid-markdownfn-lib-example
2.0.2

1 year ago

2.0.1

3 years ago

2.0.0

3 years ago

1.1.5

4 years ago

1.1.4

5 years ago

1.1.3

5 years ago

1.1.2

6 years ago

1.1.1

7 years ago

1.1.0

7 years ago

1.0.0

8 years ago