Software zum Installieren eines Smart-Mirror Frameworks , zum Nutzen von hochschulrelevanten Informationen, auf einem Raspberry-Pi.
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.

array-from.js 1.8KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. 'use strict';
  2. var bind = require('../internals/function-bind-context');
  3. var toObject = require('../internals/to-object');
  4. var callWithSafeIterationClosing = require('../internals/call-with-safe-iteration-closing');
  5. var isArrayIteratorMethod = require('../internals/is-array-iterator-method');
  6. var toLength = require('../internals/to-length');
  7. var createProperty = require('../internals/create-property');
  8. var getIteratorMethod = require('../internals/get-iterator-method');
  9. // `Array.from` method implementation
  10. // https://tc39.es/ecma262/#sec-array.from
  11. module.exports = function from(arrayLike /* , mapfn = undefined, thisArg = undefined */) {
  12. var O = toObject(arrayLike);
  13. var C = typeof this == 'function' ? this : Array;
  14. var argumentsLength = arguments.length;
  15. var mapfn = argumentsLength > 1 ? arguments[1] : undefined;
  16. var mapping = mapfn !== undefined;
  17. var iteratorMethod = getIteratorMethod(O);
  18. var index = 0;
  19. var length, result, step, iterator, next, value;
  20. if (mapping) mapfn = bind(mapfn, argumentsLength > 2 ? arguments[2] : undefined, 2);
  21. // if the target is not iterable or it's an array with the default iterator - use a simple case
  22. if (iteratorMethod != undefined && !(C == Array && isArrayIteratorMethod(iteratorMethod))) {
  23. iterator = iteratorMethod.call(O);
  24. next = iterator.next;
  25. result = new C();
  26. for (;!(step = next.call(iterator)).done; index++) {
  27. value = mapping ? callWithSafeIterationClosing(iterator, mapfn, [step.value, index], true) : step.value;
  28. createProperty(result, index, value);
  29. }
  30. } else {
  31. length = toLength(O.length);
  32. result = new C(length);
  33. for (;length > index; index++) {
  34. value = mapping ? mapfn(O[index], index) : O[index];
  35. createProperty(result, index, value);
  36. }
  37. }
  38. result.length = index;
  39. return result;
  40. };