.. | |||
LICENSE | 3 years ago | ||
README.md | 3 years ago | ||
index.js | 3 years ago | ||
package.json | 3 years ago |
Define a non-enumerable property on an object.
Install with npm:
$ npm install --save define-property
Install with yarn:
$ yarn add define-property
Params
obj
: The object on which to define the property.prop
: The name of the property to be defined or modified.descriptor
: The descriptor for the property being defined or modified.var define = require('define-property'); var obj = {}; define(obj, 'foo', function(val) { return val.toUpperCase(); }); console.log(obj); //=> {} console.log(obj.foo('bar')); //=> 'BAR'
get/set
define(obj, 'foo', { get: function() {}, set: function() {} });
Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.
(This project's readme.md is generated by verb, please don't edit the readme directly. Any changes to the readme must be made in the .verb.md readme template.)
To generate the readme, run the following command:
$ npm install -g verbose/verb#dev verb-generate-readme && verb
Running and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command:
$ npm install && npm test
Jon Schlinkert
Copyright © 2017, Jon Schlinkert. Released under the MIT License.
This file was generated by verb-generate-readme, v0.5.0, on April 20, 2017.