args-to-arr
Advanced tools
Comparing version 0.0.1 to 1.0.0
'use strict'; | ||
function toArray(args, start) { | ||
start = start || 0; | ||
if (!(args && "length" in args && typeof args.length === "number")) { | ||
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 params = []; | ||
for (var index = start, len = args.length; index < len; index++) { | ||
params[index - start] = args[index]; | ||
} | ||
return params; | ||
} | ||
@@ -11,0 +26,0 @@ |
function toArray(args, start) { | ||
start = start || 0; | ||
if (!(args && "length" in args && typeof args.length === "number")) { | ||
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 params = []; | ||
for (var index = start, len = args.length; index < len; index++) { | ||
params[index - start] = args[index]; | ||
} | ||
return params; | ||
} | ||
@@ -9,0 +24,0 @@ |
{ | ||
"name": "args-to-arr", | ||
"version": "0.0.1", | ||
"version": "1.0.0", | ||
"description": "Arguments to array, the easy way", | ||
@@ -8,7 +8,14 @@ "main": "dist/index.cjs.js", | ||
"types": "types/index.d.ts", | ||
"keywords": [], | ||
"keywords": [ | ||
"arguments", | ||
"params", | ||
"array", | ||
"convert", | ||
"slice" | ||
], | ||
"scripts": { | ||
"dev": "rollup -cw", | ||
"build": "rollup -c", | ||
"test": "jest" | ||
"clean": "rm -rf dist coverage", | ||
"test": "jest --colors" | ||
}, | ||
@@ -15,0 +22,0 @@ "files": [ |
# args-to-arr | ||
[](https://circleci.com/gh/manferlo81/args-to-arr) [](https://greenkeeper.io/) [](https://www.npmjs.com/package/args-to-arr) [](https://codecov.io/gh/manferlo81/args-to-arr) [](https://github.com/manferlo81/args-to-arr/blob/master/LICENSE) | ||
Arguments to array, the easy way | ||
@@ -16,3 +18,3 @@ | ||
```typescript | ||
toArray<T>(arr: ArrayLike<T>, start?: number): T[]; | ||
toArray<T>(arr: ArrayLike<T>, start: number = 0): T[]; | ||
``` | ||
@@ -41,2 +43,2 @@ | ||
MIT License | ||
[MIT License](https://github.com/manferlo81/args-to-arr/blob/master/LICENSE) |
export default function toArray(args, start) { | ||
start = start || 0; | ||
if (!(args && "length" in args && typeof args.length === "number")) { | ||
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.`); | ||
} | ||
const params = []; | ||
for (let index = start, len = args.length; index < len; index++) { | ||
params[index - start] = args[index]; | ||
} | ||
return params; | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
7281
55
0
43