@daiso-tech/core
Version:
The library offers flexible, framework-agnostic solutions for modern web applications, built on adaptable components that integrate seamlessly with popular frameworks like Next Js.
37 lines • 834 B
JavaScript
/**
* @module Collection
*/
/**
* @internal
*/
class RangeIterable {
from;
to;
constructor(from, to) {
this.from = from;
this.to = to;
}
*[Symbol.iterator]() {
for (let i = this.from; i <= this.to; i++) {
yield i;
}
}
}
/**
* The `range` function return a {@link Iterable | `Iterable`} of numbers, starting from `from`,increments by 1 and stops at `to`.
* @example
* ```ts
* import { ListCollection, range } from "@daiso-tech/core/collection";
*
* const collection = new ListCollection(range(1, 10))
* collection.toArray();
* // [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
* ```
*
* IMPORT_PATH: `"@daiso-tech/core/collection"`
* @group Utilities
*/
export function range(from, to) {
return new RangeIterable(from, to);
}
//# sourceMappingURL=_shared.js.map