odin-js-fundamentals-part-4/node_modules/object.entries/implementation.js

18 lines
504 B
JavaScript
Raw Permalink Normal View History

2024-01-05 19:30:21 +00:00
'use strict';
var RequireObjectCoercible = require('es-abstract/2022/RequireObjectCoercible');
var callBound = require('call-bind/callBound');
var $isEnumerable = callBound('Object.prototype.propertyIsEnumerable');
var $push = callBound('Array.prototype.push');
module.exports = function entries(O) {
var obj = RequireObjectCoercible(O);
var entrys = [];
for (var key in obj) {
if ($isEnumerable(obj, key)) { // checks own-ness as well
$push(entrys, [key, obj[key]]);
}
}
return entrys;
};