Node-Red configuration
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

object-to-array.js 1.6KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. 'use strict';
  2. var DESCRIPTORS = require('../internals/descriptors');
  3. var fails = require('../internals/fails');
  4. var uncurryThis = require('../internals/function-uncurry-this');
  5. var objectGetPrototypeOf = require('../internals/object-get-prototype-of');
  6. var objectKeys = require('../internals/object-keys');
  7. var toIndexedObject = require('../internals/to-indexed-object');
  8. var $propertyIsEnumerable = require('../internals/object-property-is-enumerable').f;
  9. var propertyIsEnumerable = uncurryThis($propertyIsEnumerable);
  10. var push = uncurryThis([].push);
  11. // in some IE versions, `propertyIsEnumerable` returns incorrect result on integer keys
  12. // of `null` prototype objects
  13. var IE_BUG = DESCRIPTORS && fails(function () {
  14. // eslint-disable-next-line es/no-object-create -- safe
  15. var O = Object.create(null);
  16. O[2] = 2;
  17. return !propertyIsEnumerable(O, 2);
  18. });
  19. // `Object.{ entries, values }` methods implementation
  20. var createMethod = function (TO_ENTRIES) {
  21. return function (it) {
  22. var O = toIndexedObject(it);
  23. var keys = objectKeys(O);
  24. var IE_WORKAROUND = IE_BUG && objectGetPrototypeOf(O) === null;
  25. var length = keys.length;
  26. var i = 0;
  27. var result = [];
  28. var key;
  29. while (length > i) {
  30. key = keys[i++];
  31. if (!DESCRIPTORS || (IE_WORKAROUND ? key in O : propertyIsEnumerable(O, key))) {
  32. push(result, TO_ENTRIES ? [key, O[key]] : O[key]);
  33. }
  34. }
  35. return result;
  36. };
  37. };
  38. module.exports = {
  39. // `Object.entries` method
  40. // https://tc39.es/ecma262/#sec-object.entries
  41. entries: createMethod(true),
  42. // `Object.values` method
  43. // https://tc39.es/ecma262/#sec-object.values
  44. values: createMethod(false)
  45. };