https://github.com/jamiemason/valueless
Replace values with paths, for use in test fixtures
https://github.com/jamiemason/valueless
fixtures reselect selectors testing transformation
Last synced: 12 days ago
JSON representation
Replace values with paths, for use in test fixtures
- Host: GitHub
- URL: https://github.com/jamiemason/valueless
- Owner: JamieMason
- License: mit
- Created: 2017-08-31T20:07:18.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2017-09-04T11:23:33.000Z (almost 9 years ago)
- Last Synced: 2024-10-18T19:33:53.555Z (over 1 year ago)
- Topics: fixtures, reselect, selectors, testing, transformation
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/valueless
- Size: 58.6 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# valueless
> Replace values with paths, for use in test fixtures
[](https://www.npmjs.com/package/valueless)
[](https://www.npmjs.com/package/valueless)
[](https://david-dm.org/JamieMason/valueless)
[](https://gitter.im/JamieMason/valueless)
[](https://www.paypal.me/foldleft)
[](https://gratipay.com/~JamieMason/)
[](https://github.com/igrigorik/ga-beacon)
[](https://github.com/JamieMason)
[](https://twitter.com/fold_left)
## Installation
```
npm install --save-dev valueless
```
## Usage
### Node.js
```js
import valueless from 'valueless';
const data = [{
id: 1,
name: 'Marloes'
}, {
id: 2,
name: 'Rutger'
}];
valueless(data);
// => [{ id: '0.id', name: '0.name' }, { id: '1.id', name: '1.name' }]
valueless(data, { excludes: ['id'] });
// => [{ id: 1, name: '0.name' }, { id: 2, name: '1.name' }]
valueless(data, { prefix: 'API' });
// => [{ id: 'API:0.id', name: 'API:0.name' }, { id: 'API:1.id', name: 'API:1.name' }]
valueless(data, { excludes: ['id'], prefix: 'API' });
// => [{ id: 1, name: 'API:0.name' }, { id: 2, name: 'API:1.name' }]
```
### Command Line
```
echo '[["Serialised"],["JSON"]]' | valueless
echo '[["Serialised"],["JSON"]]' | valueless --prefix CMS
echo '[["Serialised"],["JSON"]]' | valueless --excludes foo,bar,baz
```
See `valueless --help` for more information.
## Background
Not a common use-case _at all_, but created to see if it could reduce some of the overhead we have
when managing test fixtures for JSON returned by [contentstack](https://contentstack.built.io),
which we are transforming using [reselect](https://github.com/reactjs/reselect).