Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

@bbc/psammead-detokeniser

BBC-News471Apache-2.01.0.7

Replaces % delimited tokens with a value from the dictionary object

bbc, utilities, detokeniser

readme

psammead-detokeniser - Known Vulnerabilities Dependency Status peerDependencies Status Storybook GitHub license npm version PRs Welcome

Description

The detokeniser utility operates on strings and replaces % delimited tokens with a value from the dictionary object.

Installation

npm install @bbc/psammead-detokeniser --save

Props

Argument Type Required Default Example
text string yes N/A 'Foo %token%'
dictionary object yes N/A { '%token%': 'Bar' }

dictionary is an object which maps keys as tokens to values. For example, in psammead-social-embeds, all social media providers in the data are in lowercase which corresponds as the token to be interpolated into the full name. E.g. '%youtube%' -> 'YouTube'

Usage

import detokenise from "@bbc/psammead-detokeniser"

// This will return 'Duration: 20 minutes'
detokenise('Duration: %token%', { '%token%': '20 minutes' });

When to use this utility

When not to use this utility

Accessibility notes

Roadmap

Contributing

Psammead is completely open source. We are grateful for any contributions, whether they be new utilities, bug fixes or general improvements. Please see our primary contributing guide which can be found at the root of the Psammead repository.

Code of Conduct

We welcome feedback and help on this work. By participating in this project, you agree to abide by the code of conduct. Please take a moment to read it.

License

Psammead is Apache 2.0 licensed.

changelog

Detokeniser Changelog

Version Description
1.0.7 PR#4511 removes empty dependency key
1.0.6 PR#4486 upgrade minor/patch dependencies
1.0.5 PR#4420 bumps 3rd-party dependencies
1.0.4 PR#4368 use Yarn Workspaces
1.0.3 PR#4335 switch to yarn for package management
1.0.2 PR#4303 Trigger rebuild following babel config update for emotion 11
1.0.1 PR#4271 change react peer dep to >=16.9.0
1.0.0 PR#3393 Initial creation of package.