main
Last change
on this file since 79a0317 was 79a0317, checked in by stefan toskovski <stefantoska84@…>, 3 days ago |
F4 Finalna Verzija
|
-
Property mode
set to
100644
|
File size:
827 bytes
|
Rev | Line | |
---|
[d565449] | 1 | 'use strict';
|
---|
| 2 |
|
---|
| 3 | var GetIntrinsic = require('get-intrinsic');
|
---|
| 4 |
|
---|
| 5 | var hasSymbols = require('has-symbols')();
|
---|
| 6 |
|
---|
| 7 | var $TypeError = require('es-errors/type');
|
---|
| 8 |
|
---|
| 9 | var $gOPN = GetIntrinsic('%Object.getOwnPropertyNames%', true);
|
---|
| 10 | var $gOPS = hasSymbols && GetIntrinsic('%Object.getOwnPropertySymbols%', true);
|
---|
| 11 | var keys = require('object-keys');
|
---|
| 12 |
|
---|
[79a0317] | 13 | var isObject = require('../helpers/isObject');
|
---|
[d565449] | 14 |
|
---|
| 15 | // https://262.ecma-international.org/6.0/#sec-getownpropertykeys
|
---|
| 16 |
|
---|
| 17 | module.exports = function GetOwnPropertyKeys(O, Type) {
|
---|
[79a0317] | 18 | if (!isObject(O)) {
|
---|
[d565449] | 19 | throw new $TypeError('Assertion failed: Type(O) is not Object');
|
---|
| 20 | }
|
---|
| 21 | if (Type === 'Symbol') {
|
---|
| 22 | return $gOPS ? $gOPS(O) : [];
|
---|
| 23 | }
|
---|
| 24 | if (Type === 'String') {
|
---|
| 25 | if (!$gOPN) {
|
---|
| 26 | return keys(O);
|
---|
| 27 | }
|
---|
| 28 | return $gOPN(O);
|
---|
| 29 | }
|
---|
| 30 | throw new $TypeError('Assertion failed: `Type` must be `"String"` or `"Symbol"`');
|
---|
| 31 | };
|
---|
Note:
See
TracBrowser
for help on using the repository browser.