An open API service indexing awesome lists of open source software.

https://github.com/xotic750/reflect-define-property-x

Sham for Reflect.defineProperty
https://github.com/xotic750/reflect-define-property-x

browser defineproperty javascript nodejs reflect

Last synced: 3 months ago
JSON representation

Sham for Reflect.defineProperty

Awesome Lists containing this project

README

        


Travis status


Dependency status


devDependency status


npm version


jsDelivr hits


bettercodehub score


Coverage Status

## reflect-define-property-x

Sham for Reflect.defineProperty

### `module.exports(target, propertyKey, attributes)` ⇒ Object

This method allows precise addition to or modification of a property on an object.
For more details see the Object.defineProperty which is similar.
Object.defineProperty returns the object or throws a TypeError if the property
has not been successfully defined. Reflect.defineProperty, however, simply returns
a Boolean indicating whether or not the property was successfully defined.

**Kind**: Exported function
**Returns**: Object - A Boolean indicating whether or not the property was successfully defined.
**Throws**:

- TypeError If target is not an Object.

| Param | Type | Description |
| ----------- | --------------- | ---------------------------------------------------------- |
| target | \* | The target object on which to define the property. |
| propertyKey | \* | The name of the property to be defined or modified. |
| attributes | \* | The attributes for the property being defined or modified. |

**Example**

```js
import reflectDefineProperty from 'reflect-define-property-x';

const obj = {};
reflectDefineProperty(obj, 'x', {value: 7}); // true
console.log(obj.x); // 7
```