Repositorio del curso CCOM4030 el semestre B91 del proyecto kilometro0

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. 'use strict';
  2. var hasSymbols = require('has-symbols')();
  3. var ES2015 = require('./es2015');
  4. var assign = require('./helpers/assign');
  5. var callBound = require('./helpers/callBound');
  6. var $arrayPush = callBound('Array.prototype.push');
  7. var $arraySlice = callBound('Array.prototype.slice');
  8. var $arrayJoin = callBound('Array.prototype.join');
  9. var ES2016 = assign(assign({}, ES2015), {
  10. // https://www.ecma-international.org/ecma-262/7.0/#sec-samevaluenonnumber
  11. SameValueNonNumber: function SameValueNonNumber(x, y) {
  12. if (typeof x === 'number' || typeof x !== typeof y) {
  13. throw new TypeError('SameValueNonNumber requires two non-number values of the same type.');
  14. }
  15. return this.SameValue(x, y);
  16. },
  17. // https://www.ecma-international.org/ecma-262/7.0/#sec-iterabletoarraylike
  18. IterableToArrayLike: function IterableToArrayLike(items) {
  19. var usingIterator;
  20. if (hasSymbols) {
  21. usingIterator = this.GetMethod(items, Symbol.iterator);
  22. } else if (this.IsArray(items)) {
  23. usingIterator = function () {
  24. var i = -1;
  25. var arr = this; // eslint-disable-line no-invalid-this
  26. return {
  27. next: function () {
  28. i += 1;
  29. return {
  30. done: i >= arr.length,
  31. value: arr[i]
  32. };
  33. }
  34. };
  35. };
  36. } else if (this.Type(items) === 'String') {
  37. var ES = this;
  38. usingIterator = function () {
  39. var i = 0;
  40. return {
  41. next: function () {
  42. var nextIndex = ES.AdvanceStringIndex(items, i, true);
  43. var value = $arrayJoin($arraySlice(items, i, nextIndex), '');
  44. i = nextIndex;
  45. return {
  46. done: nextIndex > items.length,
  47. value: value
  48. };
  49. }
  50. };
  51. };
  52. }
  53. if (typeof usingIterator !== 'undefined') {
  54. var iterator = this.GetIterator(items, usingIterator);
  55. var values = [];
  56. var next = true;
  57. while (next) {
  58. next = this.IteratorStep(iterator);
  59. if (next) {
  60. var nextValue = this.IteratorValue(next);
  61. $arrayPush(values, nextValue);
  62. }
  63. }
  64. return values;
  65. }
  66. return this.ToObject(items);
  67. }
  68. });
  69. module.exports = ES2016;