Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/ayonli_jsext/number/index.ts>serial

A JavaScript extension package for building strong and modern applications.
Latest
function serial
import { serial } from "https://deno.land/x/ayonli_jsext@v0.9.72/number/index.ts";

Creates a generator that produces sequential numbers from 1 to Number.MAX_SAFE_INTEGER, useful for generating unique IDs.

Examples

Example 1

import { serial } from "@ayonli/jsext/number";

const idGenerator = serial();

console.log(idGenerator.next().value); // 1
console.log(idGenerator.next().value); // 2
console.log(idGenerator.next().value); // 3

Parameters

optional
loop = [UNSUPPORTED]

Repeat the sequence when the end is reached.

Returns

Generator<number, void, unknown>