Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

docnumbering

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

docnumbering

Document Number/ID Generator with ability to auto increment

latest
npmnpm
Version
0.0.4
Version published
Weekly downloads
9
125%
Maintainers
1
Weekly downloads
 
Created
Source

Docnumbering

docnumbering is a flexible and customizable identity generation library. It allows you to define a sequence of rules to generate structured IDs dynamically.

Features

  • Static values, input-based, datetime, and incrementing ID components.
  • Customizable ID structure using predefined rule types.
  • Supports different formats such as year-based numbering.
  • Memory-based storage for ID tracking.

Installation

npm install docnumbering

Usage

import { factory, MemoryStore, Rule, RuleFormat, RuleType } from "docnumbering";

const rules: Rule[] = [
  { type: RuleType.STATIC, value: "IT" },
  { type: RuleType.STATIC, value: "-" },
  { type: RuleType.INPUT },
  { type: RuleType.STATIC, value: "-" },
  { type: RuleType.DATETIME, format: RuleFormat.YEAR_4 },
  { type: RuleType.STATIC, value: "-" },
  { type: RuleType.INCREMENT, format: RuleFormat.BASE_10, fixedLength: 3 },
];

const store = new MemoryStore();
const idgen = factory(rules, store, { now: new Date("2025") });

async function generateId() {
  console.log(await idgen.nextId(["LAPTOP"])); // IT-LAPTOP-2025-001
}

generateId();

Example Patterns

  • IT-LAPTOP-2025-001: A structured ID with category, year, and incrementing number.
  • IT-ANDROID-2024-002: Uses dynamic input for category.
  • IT-BAG-2023-005: Automatically increments for each new ID.

Demo

Try out the ID generator at: numbering demo

FAQs

Package last updated on 31 Jan 2026

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