See the CHANGELOG for updates.
Params
object
: The object on which to define the property.key
: The name of the property to be defined or modified.value
: The value or descriptor of the property being defined or modified.
var define = require('{%= name %}');
var obj = {};
define(obj, 'foo', function(val) {
return val.toUpperCase();
});
// by default, defined properties are non-enumberable
console.log(obj);
//=> {}
console.log(obj.foo('bar'));
//=> 'BAR'
defining setters/getters
Pass the same properties you would if using Object.defineProperty or Reflect.defineProperty.
define(obj, 'foo', {
set: function() {},
get: function() {}
});