kagurajs - v0.2.7 / Exports / utils
Namespace: utils
Table of contents
Functions
Functions
range
▸ range(n
): Generator
<number
, void
, unknown
>
Returns n numbers from 0 to (n-1) in order.
Parameters
Name | Type | Description |
---|---|---|
n | number | Number to stop before that number |
Returns
Generator
<number
, void
, unknown
>
A sequential number generator
Remarks
A generator that returns n numbers from 0 to (n-1) in order.
what does it exist for?
Because doing that would require writing long code. Old:
ts
for(let i = 0; i < 10; i++){
console.log(`Count is ${i}.`)
}
Using this:
ts
for(const i of range(10)){
console.log(`Count is ${i}.`)
}
Example
ts
for(const i of range(1000)){
console.log(i)
}
Defined in
sleep
▸ sleep(time
): Promise
<unknown
>
Sleep for ms.
Parameters
Name | Type |
---|---|
time | number |
Returns
Promise
<unknown
>