Skip to content

personnummer/js-generate

Repository files navigation

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