Package Exports
- args-to-arr
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (args-to-arr) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
args-to-arr
Converts arguments
or any other array-like
object into an array starting from specific index.
Inspired by how Typescript handles ...rest
arguments.
Install
npm i args-to-arr
CDN
jsDelivr
<script src="https://cdn.jsdelivr.net/npm/args-to-arr@latest/dist/args-to-arr.umd.js"></script>
for production
<script src="https://cdn.jsdelivr.net/npm/args-to-arr@latest/dist/args-to-arr.umd.min.js"></script>
unpkg
<script src="https://unpkg.com/args-to-arr@latest/dist/args-to-arr.umd.js"></script>
for production
<script src="https://unpkg.com/args-to-arr@latest/dist/args-to-arr.umd.min.js"></script>
Usage
syntax
toArray<T>(arr: ArrayLike<T>, start: number = 0): T[];
Note that
args-to-arr
supports anyarray-like
object.
example
import toArray from "args-to-arr";
function anything(firstArg) {
// convert arguments to array
// starting from argument 1
// it won't include firstArg
const args = toArray(arguments, 1);
// do something with the array
}
License
MIT © Manuel Fernández