UNPKG

n-digit-token

Version:

Cryptographically secure pseudo-random token of n digits

12 lines (11 loc) 411 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.padTokenIfNecessary = void 0; /** * Left-pad token with zeros if necessary. * @param {number} length * @param {string} token * @return {string} padded token */ const padTokenIfNecessary = (length, token) => token.length === length ? token : token.padStart(length, '0'); exports.padTokenIfNecessary = padTokenIfNecessary;