The arguments to process, may be ArrayLike or an Iterable
Optional
start: numberZero-based index at which to start extraction, converted to an integer.
Optional
end: numberZero-based index at which to end extraction, converted to an integer. readArgs() extracts up to but not including end.
A new array with the extracted elements
function myFunc<T>(firstArg: T, ...otherArgs) {
// Read all of the arguments
let allArgs = readArgs(arguments);
// Get all of the arguments after the first
let optArgs = readArgs(arguments, 1);
}
myFunc("Hello");
myFunc("Hello", "Darkness", "my", "old", "friend", ".");
function* myGenerator() {
yield "Hello";
yield "Darkness";
yield "my";
yield "old";
yield "friend";
}
function* myGenerator2() {
yield "I've";
yield "come";
yield "to";
yield "talk";
yield "with";
yield "you";
yield "again";
}
readArgs(myGenerator());
// [ "Hello", "Darkness", "my", "old", "friend"]);
readArgs(myGenerator(), 1);
// [ "Darkness", "my", "old", "friend"]);
readArgs(myGenerator2());
// [ "I've", "come", "to", "talk", "with", "you", "again" ]);
readArgs(myGenerator2(), 0, -2);
// [ "I've", "come", "to", "talk", "with" ]);
readArgs(myGenerator2(), -3, -2);
// [ "with" ]);
Read the arguments from the provided array, iterator / or generator function When processing an Iterable and a negative start or end is provided the entire iterator will be processed into an array before applying the start / end restrictions and when undefined or >= 0 any iterator will not be fully processed.