source: imaps-frontend/node_modules/es-abstract/2023/GetOwnPropertyKeys.js@ d565449

main
Last change on this file since d565449 was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago

Update repo after prototype presentation

  • Property mode set to 100644
File size: 822 bytes
Line 
1'use strict';
2
3var GetIntrinsic = require('get-intrinsic');
4
5var hasSymbols = require('has-symbols')();
6
7var $TypeError = require('es-errors/type');
8
9var $gOPN = GetIntrinsic('%Object.getOwnPropertyNames%', true);
10var $gOPS = hasSymbols && GetIntrinsic('%Object.getOwnPropertySymbols%', true);
11var keys = require('object-keys');
12
13var esType = require('./Type');
14
15// https://262.ecma-international.org/6.0/#sec-getownpropertykeys
16
17module.exports = function GetOwnPropertyKeys(O, Type) {
18 if (esType(O) !== 'Object') {
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.