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.

esnext.array.is-template-object.js 963B

1234567891011121314151617181920212223242526272829
  1. 'use strict';
  2. var $ = require('../internals/export');
  3. var isArray = require('../internals/is-array');
  4. // eslint-disable-next-line es/no-object-isfrozen -- safe
  5. var isFrozen = Object.isFrozen;
  6. var isFrozenStringArray = function (array, allowUndefined) {
  7. if (!isFrozen || !isArray(array) || !isFrozen(array)) return false;
  8. var index = 0;
  9. var length = array.length;
  10. var element;
  11. while (index < length) {
  12. element = array[index++];
  13. if (!(typeof element == 'string' || (allowUndefined && element === undefined))) {
  14. return false;
  15. }
  16. } return length !== 0;
  17. };
  18. // `Array.isTemplateObject` method
  19. // https://github.com/tc39/proposal-array-is-template-object
  20. $({ target: 'Array', stat: true, sham: true, forced: true }, {
  21. isTemplateObject: function isTemplateObject(value) {
  22. if (!isFrozenStringArray(value, true)) return false;
  23. var raw = value.raw;
  24. return raw.length === value.length && isFrozenStringArray(raw, false);
  25. }
  26. });