source: imaps-frontend/node_modules/es-abstract/2020/EnumerableOwnPropertyNames.js@ 79a0317

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: 1002 bytes
RevLine 
[d565449]1'use strict';
2
3var $TypeError = require('es-errors/type');
4
5var objectKeys = require('object-keys');
[79a0317]6var safePushApply = require('safe-push-apply');
7var callBound = require('call-bound');
[d565449]8
9var $isEnumerable = callBound('Object.prototype.propertyIsEnumerable');
10
11var forEach = require('../helpers/forEach');
[79a0317]12var isObject = require('../helpers/isObject');
[d565449]13
14// https://262.ecma-international.org/8.0/#sec-enumerableownproperties
15
16module.exports = function EnumerableOwnPropertyNames(O, kind) {
[79a0317]17 if (!isObject(O)) {
[d565449]18 throw new $TypeError('Assertion failed: Type(O) is not Object');
19 }
20
21 var keys = objectKeys(O);
22 if (kind === 'key') {
23 return keys;
24 }
25 if (kind === 'value' || kind === 'key+value') {
26 var results = [];
27 forEach(keys, function (key) {
28 if ($isEnumerable(O, key)) {
[79a0317]29 safePushApply(results, [
[d565449]30 kind === 'value' ? O[key] : [key, O[key]]
31 ]);
32 }
33 });
34 return results;
35 }
36 throw new $TypeError('Assertion failed: "kind" is not "key", "value", or "key+value": ' + kind);
37};
Note: See TracBrowser for help on using the repository browser.