args-to-arr
Version:
converts arguments or any other array-like object into an array starting from specific index.
28 lines (20 loc) • 541 B
JavaScript
import isArrayLike from 'is-array-like';
function toArray(args, start) {
if (!isArrayLike(args)) {
throw new TypeError((args + " can't be converted to array."));
}
if (start == null) {
start = 0;
}
if (typeof start !== "number") {
throw new TypeError((start + " is not a number."));
}
var len = args.length;
var result = new Array(len - start);
for (var i = start; i < len; i++) {
result[i - start] = args[i];
}
return result;
}
export default toArray;
//# sourceMappingURL=args-to-arr.es.js.map