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
|
Rev | Line | |
---|
[d565449] | 1 | 'use strict';
|
---|
| 2 |
|
---|
| 3 | var $TypeError = require('es-errors/type');
|
---|
| 4 |
|
---|
| 5 | var objectKeys = require('object-keys');
|
---|
[79a0317] | 6 | var safePushApply = require('safe-push-apply');
|
---|
| 7 | var callBound = require('call-bound');
|
---|
[d565449] | 8 |
|
---|
| 9 | var $isEnumerable = callBound('Object.prototype.propertyIsEnumerable');
|
---|
| 10 |
|
---|
| 11 | var forEach = require('../helpers/forEach');
|
---|
[79a0317] | 12 | var isObject = require('../helpers/isObject');
|
---|
[d565449] | 13 |
|
---|
| 14 | // https://262.ecma-international.org/8.0/#sec-enumerableownproperties
|
---|
| 15 |
|
---|
| 16 | module.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.