|
Last change
on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 12 days ago |
|
Fix frontend appearance
|
-
Property mode
set to
100644
|
|
File size:
831 bytes
|
| Line | |
|---|
| 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 | var isObject = require('es-object-atoms/isObject');
|
|---|
| 9 |
|
|---|
| 10 | var $gOPN = GetIntrinsic('%Object.getOwnPropertyNames%', true);
|
|---|
| 11 | var $gOPS = hasSymbols && GetIntrinsic('%Object.getOwnPropertySymbols%', true);
|
|---|
| 12 | var keys = require('object-keys');
|
|---|
| 13 |
|
|---|
| 14 | // https://262.ecma-international.org/6.0/#sec-getownpropertykeys
|
|---|
| 15 |
|
|---|
| 16 | module.exports = function GetOwnPropertyKeys(O, Type) {
|
|---|
| 17 | if (!isObject(O)) {
|
|---|
| 18 | throw new $TypeError('Assertion failed: Type(O) is not Object');
|
|---|
| 19 | }
|
|---|
| 20 | if (Type === 'Symbol') {
|
|---|
| 21 | return $gOPS ? $gOPS(O) : [];
|
|---|
| 22 | }
|
|---|
| 23 | if (Type === 'String') {
|
|---|
| 24 | if (!$gOPN) {
|
|---|
| 25 | return keys(O);
|
|---|
| 26 | }
|
|---|
| 27 | return $gOPN(O);
|
|---|
| 28 | }
|
|---|
| 29 | throw new $TypeError('Assertion failed: `Type` must be `"String"` or `"Symbol"`');
|
|---|
| 30 | };
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.