{"id":40828,"library":"document-number-formatter","title":"Document Number Formatter","description":"A lightweight TypeScript library for generating formatted document numbers such as bill numbers, invoice numbers, or custom identifiers. The current stable version is 1.0.33, and it is actively maintained with periodic updates. Key differentiators include support for date-based formatting (year, month, day), sequential value formatting with zero-padding, and fiscal year logic. It is designed for Node.js and browser environments and integrates easily with frameworks like Vue, React, and Angular. The library provides three main functions: formatDocumentNumber, fdnForDate, and formatDate. It is ESM and CJS compatible, ships TypeScript definitions, and has zero external dependencies.","status":"active","version":"1.0.33","language":"javascript","source_language":"en","source_url":"https://github.com/hariprasath-yadav/document-number-formatter","tags":["javascript","Document Number Formatter","Document Number Generator","Document Number Creator","Document Number Format","Document Number Maker","Document Number","Bill Number Formatter","Bill Number Generator","typescript"],"install":[{"cmd":"npm install document-number-formatter","lang":"bash","label":"npm"},{"cmd":"yarn add document-number-formatter","lang":"bash","label":"yarn"},{"cmd":"pnpm add document-number-formatter","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"Named export is available; default export does not exist. Use named import for ESM or destructure require for CJS.","wrong":"const formatDocumentNumber = require('document-number-formatter').formatDocumentNumber","symbol":"formatDocumentNumber","correct":"import { formatDocumentNumber } from 'document-number-formatter'"},{"note":"Named export for formatting numbers based on a specific date.","symbol":"fdnForDate","correct":"import { fdnForDate } from 'document-number-formatter'"},{"note":"Named export for formatting dates in a custom pattern.","symbol":"formatDate","correct":"import { formatDate } from 'document-number-formatter'"}],"quickstart":{"code":"import { formatDocumentNumber, fdnForDate, formatDate } from 'document-number-formatter';\n\n// Format with value and padding\nconst result1 = formatDocumentNumber('INV/[YYYY]/[MM]/[val:size:6]', 123);\nconsole.log(result1); // e.g., INV/2023/11/000123\n\n// Format with fiscal year\nconst result2 = formatDocumentNumber('DNF/[YY=apr]-[YY+1=apr]/[val:size:5]', 42, 5, 'apr');\nconsole.log(result2); // e.g., DNF/23-24/00042\n\n// Format with date object\nconst result3 = fdnForDate(new Date('2021-03-01'), 'BNO/[YYYY]/[MMM]/[val]', 789, 4);\nconsole.log(result3); // e.g., BNO/2021/MAR/0789\n\n// Format date directly\nconst result4 = formatDate('DD/MM/YYYY', '4', new Date('2020-03-28'));\nconsole.log(result4); // 28/03/2020","lang":"typescript","description":"Shows how to import and use the three main functions: formatDocumentNumber for generating numbers, fdnForDate for date-specific formatting, and formatDate for date-only formatting."},"warnings":[{"fix":"Replace [date:YYYY] with [YYYY] in your pattern strings.","message":"The [date:YYYY] format is removed in version 1.0.0. Use [YYYY] instead.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Ensure the numeric value does not exceed the padding size (max 10). Use a larger format or split the value.","message":"The val:size parameter has a maximum padding of 10 digits. Values larger than 9999999999 will overflow and produce incorrect output.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Use one of the recognized month abbreviations: jan, feb, mar, apr, may, jun, jul, aug, sep, oct, nov, dec.","message":"Fiscal year start month must be provided as a three-letter abbreviation (e.g., 'apr', 'jan'). Invalid abbreviations cause unexpected behavior.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"search_vec":"'1.0.33':27 'activ':31 'angular':76 'base':43 'bill':15,119,122 'browser':65 'cjs':91 'compat':92 'creator':110 'current':23 'custom':20 'date':42 'date-bas':41 'day':47 'definit':95 'depend':100 'design':61 'differenti':37 'document':1,11,102,105,108,111,114,117 'easili':69 'environ':66 'esm':89 'extern':99 'fdnfordat':84 'fiscal':56 'format':10,44,50,113 'formatd':86 'formatdocumentnumb':83 'formatt':3,104,121 'framework':71 'function':82 'generat':9,107,124 'identifi':21 'includ':38 'integr':68 'invoic':17 'javascript':101 'key':36 'librari':7,78 'lightweight':5 'like':72 'logic':58 'main':81 'maintain':32 'maker':116 'month':46 'node.js':63 'number':2,12,16,18,103,106,109,112,115,118,120,123 'pad':54 'period':34 'provid':79 'react':74 'sequenti':48 'ship':93 'stabl':24 'support':39 'three':80 'typescript':6,94,125 'updat':35 'valu':49 'version':25 'vue':73 'year':45,57 'zero':53,98 'zero-pad':52","created_at":"2026-06-04T18:49:27.775311+00:00","updated_at":"2026-06-04T18:49:27.775311+00:00","problems":[{"fix":"Use import { formatDocumentNumber } from 'document-number-formatter' instead of import formatDocumentNumber from 'document-number-formatter'.","cause":"Attempting default import instead of named import.","error":"TypeError: formatDocumentNumber is not a function"},{"fix":"Ensure every '[' has a corresponding ']'. To include a literal ']', do not use a preceding '['.","cause":"Format string contains a ']' without a matching '['.","error":"Error: Invalid format string: unmatched bracket"},{"fix":"Replace [date:YYYY] with [YYYY].","cause":"Using the deprecated [date:YYYY] syntax removed in v1.0.0.","error":"Error: Unknown format token: [date:YYYY]"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/hariprasath-yadav/document-number-formatter#readme","github":"https://github.com/hariprasath-yadav/document-number-formatter","docs":null,"changelog":null,"pypi":null,"npm":"document-number-formatter","openapi_spec":null,"status_page":null,"smithery":null,"categories":["productivity"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-04","next_check":"2026-09-02","install_tag":null}}