https://github.com/lamansky/own-all
[Node.js] Turns inherited properties into owned properties.
https://github.com/lamansky/own-all
Last synced: 3 months ago
JSON representation
[Node.js] Turns inherited properties into owned properties.
- Host: GitHub
- URL: https://github.com/lamansky/own-all
- Owner: lamansky
- License: mit
- Created: 2018-03-06T14:18:35.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2018-03-06T14:31:17.000Z (over 8 years ago)
- Last Synced: 2025-09-28T07:13:40.041Z (9 months ago)
- Language: JavaScript
- Size: 1.95 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: license.txt
Awesome Lists containing this project
README
# own-all
Turns inherited properties into owned properties.
Returns a new object. Does not modify the original.
## Installation
Requires [Node.js](https://nodejs.org/) 6.0.0 or above.
```bash
npm i own-all
```
## API
The module exports a single function.
### Parameter
`obj` (object): The object which may possess owned and/or inherited properties.
### Return Value
A new object which owns all of the properties, both owned and inherited, of `obj`.
## Example
```javascript
const ownAll = require('own-all')
Reflect.ownKeys(ownAll({a: 1})) /*
[
'a',
'constructor',
'__defineGetter__',
'__defineSetter__',
'hasOwnProperty',
'__lookupGetter__',
'__lookupSetter__',
'isPrototypeOf',
'propertyIsEnumerable',
'toString',
'valueOf',
'__proto__',
'toLocaleString'
]
*/
// If you only want enumerable properties, use `Object.keys()` etc:
Object.keys(ownAll({a: 1})) // ['a']
```