A simple method that takes an object and returns a new object where all of the top-level keys have been prefixed by some string.
npm install --save object-key-prefixer
var prefixer = require('object-key-prefixer');
var obj = {
one: 'foo',
two: {
bar: 'baz'
}
}
prefixer(obj, 'awesome_')
Output:
{
awesome_one: 'foo',
awesome_two: {
bar: 'baz'
}
}
PRs accepted. Note that code uses standard styling.
MIT © Dan Caddigan