Skip to content

Latest commit

 

History

History
40 lines (29 loc) · 990 Bytes

.verb.md

File metadata and controls

40 lines (29 loc) · 990 Bytes

Release history

See the CHANGELOG for updates.

Usage

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() {}
});