basant307/AI_Governance_Project
045
1# define-data-property <sup>[![Version Badge][npm-version-svg]][package-url]</sup>2 3[![github actions][actions-image]][actions-url]4[![coverage][codecov-image]][codecov-url]5[![License][license-image]][license-url]6[![Downloads][downloads-image]][downloads-url]7 8[![npm badge][npm-badge-png]][package-url]9 10Define a data property on an object. Will fall back to assignment in an engine without descriptors.11 12The three `non*` argument can also be passed `null`, which will use the existing state if available.13 14The `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.15 16## Usage17 18```javascript19var defineDataProperty = require('define-data-property');20var assert = require('assert');21 22var obj = {};23defineDataProperty(obj, 'key', 'value');24defineDataProperty(25 obj,26 'key2',27 'value',28 true, // nonEnumerable, optional29 false, // nonWritable, optional30 true, // nonConfigurable, optional31 false // loose, optional32);33 34assert.deepEqual(35 Object.getOwnPropertyDescriptors(obj),36 {37 key: {38 configurable: true,39 enumerable: true,40 value: 'value',41 writable: true,42 },43 key2: {44 configurable: false,45 enumerable: false,46 value: 'value',47 writable: true,48 },49 }50);51```52 53[package-url]: https://npmjs.org/package/define-data-property54[npm-version-svg]: https://versionbadg.es/ljharb/define-data-property.svg55[deps-svg]: https://david-dm.org/ljharb/define-data-property.svg56[deps-url]: https://david-dm.org/ljharb/define-data-property57[dev-deps-svg]: https://david-dm.org/ljharb/define-data-property/dev-status.svg58[dev-deps-url]: https://david-dm.org/ljharb/define-data-property#info=devDependencies59[npm-badge-png]: https://nodei.co/npm/define-data-property.png?downloads=true&stars=true60[license-image]: https://img.shields.io/npm/l/define-data-property.svg61[license-url]: LICENSE62[downloads-image]: https://img.shields.io/npm/dm/define-data-property.svg63[downloads-url]: https://npm-stat.com/charts.html?package=define-data-property64[codecov-image]: https://codecov.io/gh/ljharb/define-data-property/branch/main/graphs/badge.svg65[codecov-url]: https://app.codecov.io/gh/ljharb/define-data-property/66[actions-image]: https://img.shields.io/endpoint?url=https://github-actions-badge-u3jn4tfpocch.runkit.sh/ljharb/define-data-property67[actions-url]: https://github.com/ljharb/define-data-property/actions68 