A few JavaScript one-liners for rapid data transformation.
npm install
npm test
const input = { 1: { x: 1 }, 2: { x: 2 } };
const output = transformer.co2ar(input, 'id');
/* → [ { id: 1, x: 1}, { id: 2, x: 2 } ] */
const input = [ { id: 1, x: 1 }, { id: 2, x: 2 } ];
const output = transformer.ar2ar(input, 'id');
/* → [ { 1: { x: 1 } }, { 2: { x: 2 } } ] */
const input = [ { id: 1, x: 1 }, { id: 2, x: 2 } ];
const output = transformer.ar2ob(input, 'id');
/* → { 1: { x: 1 }, 2: { x: 2 } } */
const input1 = [ 1, 2, 3, 4 ];
const input2 = [ 0, 2, 4, 6 ];
const output = transformer.intersect(input1, input2);
/* → [ 2, 4 ] */
const input = { x: { y: { z: 1 } } };
const output = transformer.flatten(input, '');
/* → { xyz: 1 } */
const input = { xyz: 1 };
const output = transformer.unflatten(input, '');
/* → { x: { y: { z: 1 } } } */
const input1 = '${x} < ${y}';
const input2 = { x: 1, y: 2 };
const output = transformer.template(input1, input2);
/* → 1 < 2 */