source: node_modules/ramda-adjunct/lib/internal/ponyfills/Array.from.js

main
Last change on this file was d24f17c, checked in by Aleksandar Panovski <apano77@…>, 15 months ago

Initial commit

  • Property mode set to 100644
File size: 2.4 KB
Line 
1"use strict";
2
3exports.__esModule = true;
4exports["default"] = void 0;
5var _ramda = require("ramda");
6var _isIterable = _interopRequireDefault(require("../../isIterable"));
7var _isNotUndefined = _interopRequireDefault(require("../../isNotUndefined"));
8var _isNotNil = _interopRequireDefault(require("../../isNotNil"));
9var _isNotFunction = _interopRequireDefault(require("../../isNotFunction"));
10function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
11function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
12function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
13function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
14function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
15function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
16function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
17var copyArray = function copyArray(items, mapFn, thisArg) {
18 var boundMapFn = (0, _isNotUndefined["default"])(thisArg) ? (0, _ramda.bind)(mapFn, thisArg) : mapFn;
19 return (0, _isNotUndefined["default"])(mapFn) ? _toConsumableArray(items).map(boundMapFn) : _toConsumableArray(items);
20};
21var fromArray = function fromArray(items, mapFn, thisArg) {
22 if (items == null) {
23 throw new TypeError('Array.from requires an array-like object - not null or undefined');
24 }
25 if ((0, _isNotNil["default"])(mapFn) && (0, _isNotFunction["default"])(mapFn)) {
26 throw new TypeError('Array.from: when provided, the second argument must be a function');
27 }
28 if ((0, _isIterable["default"])(items)) {
29 return copyArray(items, mapFn, thisArg);
30 }
31 return [];
32};
33var _default = fromArray;
34exports["default"] = _default;
Note: See TracBrowser for help on using the repository browser.