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

x/ayonli_jsext/string/index.ts>random

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

Returns a random string restricted by length (character-wise).

Examples

Example 1

import { random } from "@ayonli/jsext/string";

console.log(random(8)); // "2n8G3z1A" for example
console.log(random(8, "01")); // "10010101" for example

Parameters

length: number

Default value: 0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ.

optional
chars = [UNSUPPORTED]

Returns

string