pd link
A small utility for writing OO javascript.
pd is short for property descriptor.
It converts objects into property descriptors. So you can create objects like:
var o = Object.create(somePrototype, pd({
"someProp": "someValue"
get someGetter() {
},
set someSetter() {
}
}));
Examples link
Documentation link
See the annotated source code
pd link
pd converts all the values of your objects properties into propertydescriptors of those values.
pd({
"foo": "bar"
})
is the same as
{
"foo": {
"value": "bar",
"enumerable": true,
"writable": true,
"configurable": true
}
}
pd.merge link
pd.merge merges objects together. Any key clashes are given right preference
pd.merge(
{
"one": "faz",
"three": "bar"
},
{
"two": "ni",
"three": "baz"
},
{
"three": "bas",
"four": "four"
}
);
is the same as
{
"one": "faz",
"two": "ni",
"three": "bas",
"four": "four"
}
pd.object link
pd.object is a simple Object.create shorthand.
pd.object(o)
is the same as
Object.create(Object.prototype, pd(o));