describe-property
Advanced tools
Comparing version 1.0.0 to 1.0.1
{ | ||
"name": "describe-property", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "Define JavaScript object properties quickly with ES5 defaults", | ||
@@ -5,0 +5,0 @@ "main": "modules/describeProperty.js", |
@@ -19,3 +19,8 @@ [![npm package](https://img.shields.io/npm/v/describe-property.svg?style=flat-square)](https://www.npmjs.org/package/describe-property) | ||
Object.defineProperties(Person.prototype, { | ||
// Methods can be passed directly. | ||
sayHi: d(function () { | ||
console.log('Hello, my name is', this.fullName); | ||
}), | ||
// Getters are defined using d.gs. | ||
@@ -31,7 +36,2 @@ fullName: d.gs(function () { | ||
this._firstName = value.trim(); | ||
}), | ||
// Methods can be passed directly. | ||
sayHi: d(function () { | ||
console.log('Hello, my name is', this.fullName); | ||
}) | ||
@@ -42,2 +42,23 @@ | ||
By default property descriptors use ES5 attributes. | ||
```js | ||
{ | ||
configurable: true, | ||
enumerable: false, | ||
writable: true | ||
} | ||
``` | ||
But any of these can be overridden using an object literal. | ||
```js | ||
d({ | ||
enumerable: true, | ||
value: function () { | ||
// ... | ||
} | ||
}); // => { configurable: true, enumerable: true, writable: true, value: function () {} } | ||
``` | ||
### Installation | ||
@@ -62,3 +83,3 @@ | ||
This library was inspired by @medikoo's excellent [d](https://github.com/medikoo/d) library. It is intended to be a lighter-weight alternative with fewer features, but also only a single dependency. | ||
This library was inspired by [@medikoo](https://github.com/medikoo)'s excellent [d](https://github.com/medikoo/d) library. It is intended to be a lighter-weight alternative with fewer features, but also only a single dependency. | ||
@@ -65,0 +86,0 @@ ### License |
85
4280
4
22