define-data-property (1.1.4)
Published 2026-02-24 13:55:17 +00:00 by atheaadmin
Installation
registry=npm install define-data-property@1.1.4"define-data-property": "1.1.4"About this package
define-data-property 
Define a data property on an object. Will fall back to assignment in an engine without descriptors.
The three non* argument can also be passed null, which will use the existing state if available.
The loose argument will mean that if you attempt to set a non-normal data property, in an environment without descriptor support, it will fall back to normal assignment.
Usage
var defineDataProperty = require('define-data-property');
var assert = require('assert');
var obj = {};
defineDataProperty(obj, 'key', 'value');
defineDataProperty(
obj,
'key2',
'value',
true, // nonEnumerable, optional
false, // nonWritable, optional
true, // nonConfigurable, optional
false // loose, optional
);
assert.deepEqual(
Object.getOwnPropertyDescriptors(obj),
{
key: {
configurable: true,
enumerable: true,
value: 'value',
writable: true,
},
key2: {
configurable: false,
enumerable: false,
value: 'value',
writable: true,
},
}
);
Dependencies
Dependencies
| ID | Version |
|---|---|
| es-define-property | ^1.0.0 |
| es-errors | ^1.3.0 |
| gopd | ^1.0.1 |
Development Dependencies
| ID | Version |
|---|---|
| @ljharb/eslint-config | ^21.1.0 |
| @types/call-bind | ^1.0.5 |
| @types/define-properties | ^1.1.5 |
| @types/es-value-fixtures | ^1.4.4 |
| @types/for-each | ^0.3.3 |
| @types/get-intrinsic | ^1.2.2 |
| @types/gopd | ^1.0.3 |
| @types/has-property-descriptors | ^1.0.3 |
| @types/object-inspect | ^1.8.4 |
| @types/object.getownpropertydescriptors | ^2.1.4 |
| @types/tape | ^5.6.4 |
| aud | ^2.0.4 |
| auto-changelog | ^2.4.0 |
| es-value-fixtures | ^1.4.2 |
| eslint | =8.8.0 |
| evalmd | ^0.0.19 |
| for-each | ^0.3.3 |
| hasown | ^2.0.1 |
| in-publish | ^2.0.1 |
| npmignore | ^0.3.1 |
| nyc | ^10.3.2 |
| object-inspect | ^1.13.1 |
| object.getownpropertydescriptors | ^2.1.7 |
| reflect.ownkeys | ^1.1.4 |
| safe-publish-latest | ^2.0.0 |
| tape | ^5.7.4 |
| typescript | next |
Keywords
define
data
property
object
accessor
javascript
ecmascript
enumerable
configurable
writable
