caoge c760052ff9 机车状态修改 | hace 8 meses | |
---|---|---|
.. | ||
node_modules | hace 8 meses | |
LICENSE | hace 8 meses | |
README.md | hace 8 meses | |
index.js | hace 8 meses | |
package.json | hace 8 meses |
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.