get-set-default
v0.1.0
Published
Get an object property, setting and returning default value if does not exist yet.
Downloads
241
Readme
get-set-default
Get an object property, setting and returning default value if does not exist yet.
Implementation:
module.exports = (object, key, defaultValue) => {
if (object[key] === undefined) {
object[key] = defaultValue;
}
return object[key];
}