constantina
v0.1.1
Published
Recursive, namespaced, key-mirror without `foo: null`.
Downloads
5
Maintainers
Readme
constantina
Recursive, namespaced key mirror without foo: null
.
keymirror
is cool, recursive key mirrors are better, but
I don't like that mess with *: null
:
require('keymirror')({
"foo": null,
"bar": null,
"baz": null
});
Recursive key-mirrors exist but none, to my knowledge, avoid the null
stuff.
constantina
s approach is different:
var constantina = require('constantina');
constantina({
"foo": ["bar", "baz"],
"quux": "beep"
});
// or use this syntax...
constantina([
{ "foo": ["bar", "baz"] },
{ "quux": "beep"}
]);
// => { "foo": { "bar" : "bar@foo", "baz" : "baz@foo" }, "quux": { "beep": "beep@quux" } }
More examples:
$ node
> var f = require('constantina');
undefined
> f
[Function: ƒ]
> f({"foo": ["bar", "baz"], "quux": "beep"});
{ foo: { bar: 'bar@foo', baz: 'baz@foo' },
quux: { beep: 'beep@quux' } }
> f([{foo: ["bar", "baz"]}, { "quux": "beep" }]);
{ foo: { bar: 'bar@foo', baz: 'baz@foo' },
quux: { beep: 'beep@quux' } }
> f(["one", "two", "three"]);
{ one: 'one', two: 'two', three: 'three' }
> f({"foo": [{ "bar": ["one", "two", "three"]}, "baz", {"bazzier": "bazziest"}], "quux": {"beep": "boop"}});
{ foo:
{ bar:
{ one: '[email protected]',
two: '[email protected]',
three: '[email protected]' },
baz: 'baz@foo',
bazzier: { bazziest: '[email protected]' } },
quux: { beep: { boop: '[email protected]' } } }
>