Replace values with paths, for use in test fixtures
npm install --save-dev valueless
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' }]
echo '[["Serialised"],["JSON"]]' | valueless
echo '[["Serialised"],["JSON"]]' | valueless --prefix CMS
echo '[["Serialised"],["JSON"]]' | valueless --excludes foo,bar,baz
See valueless --help
for more information.
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, which we are transforming using reselect.