New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@evokegroup/code-generator

Package Overview
Dependencies
Maintainers
4
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@evokegroup/code-generator

Generates codes

  • 1.0.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
24
Maintainers
4
Weekly downloads
 
Created
Source

@evokegroup/code-generator

Generates codes

Class: CodeGenerator

constructor(args)

ParameterTypeDefaultDescription
batchCodenumber, string0A batch code or length of a randomly generated batch code
batchCodeExcludestring[][]An array of batch codes that the random batch code generator should not allow
charsstringCodeGenerator.Charset.MicrosoftThe set of characters to used to generate codes
lengthnumber8The character length of the generated codes
formatstringnullA custom code format. Specify batch code characters with 'b'. Specify other code character with 'x'
dupsstring[][]Any previously generated codes that should not be duplicated. Codes must match the batchCode, chars, lenth, and format of those to be generated.
Usage
const CodeGenerator = require('@evokegroup/code-generator');
const generator1 = new CodeGenerator();
const generator2 = new CodeGenerator({
  chars: CodeGenerator.EChars.AlphaUpper | CodeGenerator.EChars.Numeric | CodeGenerator.EChars.Unambiguous,
  length: 8
});
const generator3 = new CodeGenerator({
  batchCode: 2,
  batchCodeExclude: ['BC', '9T', 'HX'],
  chars: CodeGenerator.CharacterSets.Microsoft,
  length: 10,
  format: 'bbxxx-xxxxx'
});

Methods

generate(count) ⇒ Array<string>

ParameterTypeDefaultDescription
countnumber1The number of codes to generate
Usage
const CodeGenerator = require('@evokegroup/code-generator');
const generator = new CodeGenerator({
  characters: CodeGenerator.EChars.AlphaUpper,
  length: 6,
  format: 'xx-xx-xx'
});
const codes = generator.generate(10);

totalCodes() ⇒ Number

The total number of possible codes given the code length, batch code length, and characters.

Static Properties

Charset

PropertyValueDescription
Microsoft2346789BCDFGHJKMPQRTVWXYThe characters Microsoft uses in it's product codes

EChars

See @evokegroup/string-generator -> StringGenerator.EChars

FAQs

Package last updated on 29 Feb 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc