UNPKG

args-to-arr

Version:

converts arguments or any other array-like object into an array starting from specific index.

30 lines (21 loc) 562 B
'use strict'; var isArrayLike = require('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; } module.exports = toArray; //# sourceMappingURL=args-to-arr.cjs.js.map