@personnummer/generate
TypeScript icon, indicating that this package has built-in type declarations

1.0.3 • Public • Published

generate Build Status NPM Downloads

Generate Swedish Personal Identity Numbers.

Installation

npm install @personnummer/generate

Usage

import generate from '@personnummer/generate';

const today = new Date();

// generate with date object
let pin = generate(today);

// generate with random date between now and the previous hundred years and the next hundred years
pin = generate();

// generate with specific gender
pin = generate({ gender: 'male' }); // or 'female'

// generate with date object and with specific gender
pin = generate(today, { gender: 'male' }); // or 'female'

Options

{
  gender: '',    // '' (random), 'male' or 'female',
  format: 'long' // 'long' or 'short'
}

This package follows the output format specification.

License

MIT

Package Sidebar

Install

npm i @personnummer/generate

Weekly Downloads

7,633

Version

1.0.3

License

MIT

Unpacked Size

8.68 kB

Total Files

6

Last publish

Collaborators

  • frozzare
  • johannestegner