GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - SMAKSS/random-string: Generates random dummy strings.

BranchesTags
Open more actions menu

Latest commit

 

History

80 Commits
80 Commits

Folders and files

NameName
Last commit message
Last commit date
.github
.github
 
 
.husky
.husky
 
 
playground
playground
 
 
src
src
 
 
test
test
 
 
type-tests
type-tests
 
 
.gitignore
.gitignore
 
 
.nvmrc
.nvmrc
 
 
.oxfmtrc.json
.oxfmtrc.json
 
 
.oxlintrc.json
.oxlintrc.json
 
 
.releaserc.js
.releaserc.js
 
 
AGENTS.md
AGENTS.md
 
 
CODE_OF_CONDUCT.md
CODE_OF_CONDUCT.md
 
 
CONTRIBUTING.md
CONTRIBUTING.md
 
 
LICENSE
LICENSE
 
 
Readme.md
Readme.md
 
 
commitlint.config.cjs
commitlint.config.cjs
 
 
create-declaration-entrypoints.js
create-declaration-entrypoints.js
 
 
lint-staged.config.cjs
lint-staged.config.cjs
 
 
package.json
package.json
 
 
pnpm-lock.yaml
pnpm-lock.yaml
 
 
pnpm-workspace.yaml
pnpm-workspace.yaml
 
 
tsconfig.build.json
tsconfig.build.json
 
 
tsconfig.json
tsconfig.json
 
 
tsconfig.package-types.json
tsconfig.package-types.json
 
 
vite.config.js
vite.config.js
 
 

Repository files navigation

Generate random string

npm NPM npm npm unpacked size

This package will generate a random dummy string based on the available set of characters or provided ones, and you can also indicate the length of your desired random string. In case you don't care about uniqueness and don't want to use UUID, this package will help you to achieve what you want.

Generated characters and the default length use the Web Crypto API. The function throws if secure randomness is unavailable rather than falling back to Math.random().

Node.js 20 or later is required. In browsers, the Web Crypto API must be available.

If you're in need of a UUID generation library, take a look at @smakss/uuid, which offers robust UUID creation capabilities. For those who require more tailored options, @smakss/password-generator provides a versatile solution for crafting custom passwords to fit a variety of needs.

Demo

View @smakss/random-string

How it works?

Install the package using npm or pnpm:

npm install @smakss/random-string
# or
pnpm add @smakss/random-string

To include it with a common js module you should do this:

const { default: randomString } = require('@smakss/random-string');

And to include it with an ECMAScript module you can simply do this one:

import randomString from '@smakss/random-string';

Examples of usage

Then to use it within your application you can do it just like this:

Generate a random string with default parameters:

randomString();

// Result example: 'GkL9#z$P!2'

NOTE: If the length is not provided, it will be selected randomly between 1 and 20.

Generate a random string with a specified length:

randomString({ length: 10 });

// Result example: 'Sg67&ZpQ8!'

You can provide both length and allowed characters:

randomString({ length: 10, allowedCharacters: 'abCD#@' });

// Result example: 'b@@#aDaC##'

Contributing

Interested in making contributions to this project? Please see CONTRIBUTING.md for guidelines and details.

Code of Conduct

We value and prioritize the well-being of all our contributors and users. To ensure that this project remains a welcoming space for everyone, please refer to our Code of Conduct.

Local playground

This repository includes a Vite playground linked to the package through the pnpm workspace. Try the current local build without publishing a package version:

pnpm install
pnpm run dev:playground

To build the playground app, run this from the package root:

pnpm run build:playground

About

Generates random dummy strings.

www.npmjs.com/package/@smakss/random-string

Topics

hacktoberfestjavascriptnpmnpm-installnpm-packagerandomrandom-generationrandom-stringrandom-string-generatorsrandom-stringsuuidyarnyarn-packageyarn-packages

Resources

Readme
MIT license

Code of conduct

Code of conduct

Contributing

Contributing
Activity

Stars

4 stars

Watchers

1 watching

Forks

0 forks
Report repository

Releases

Packages

Used by

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.