Skip to content

Commit

Permalink
Add flow-types
Browse files Browse the repository at this point in the history
  • Loading branch information
mikaello committed Apr 2, 2019
1 parent cd24ef9 commit a5b3a21
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 1 deletion.
48 changes: 48 additions & 0 deletions export.flow.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/**
* Flowtype definitions for index.ts
* Generated by Flowgen from a Typescript Definition
* Flowgen v1.8.0
* Author: [Joar Wilk](http://twitter.com/joarwilk)
* Repo: http://github.com/joarwilk/flowgen
*/

declare export function diffYears(startDate: Date, endDate: Date): void;
declare export function isValidDate(
date: Date,
expectedYear: string,
expectedMonth: string,
expectedDay: string
): boolean;
declare type IDNumberType = "birthNumber" | "DNumber" | "HNumber" | "FHNumber";
/**
* Checks if the given value is a valid Norwegian national identity number.
* @returns `true` for valid, and `false` for invalid ID-number.
*/
declare export function validateNorwegianIdNumber(idNumber: string): boolean;
declare export function possibleAgesOfPersonWithIdNumber(
elevenDigits: string
): number[];

/**
* Returns the age of a person with given Norwegian national identity number.
* Returns `undefined` when birth date could not be determined (e.g. for FH-numbers and invalid ID-numbers).
*/
declare export function possibleAgeOfPersonWithIdNumber(
elevenDigits: string
): number | void;
declare export function idNumberContainsBirthDate(
elevenDigits: string
): boolean;
declare function possibleBirthDateOfIdNumber(elevenDigits: string): Date | void;
declare function idNumberType(elevenDigits: string): IDNumberType;
declare function possibleBirthDateOfBirthNumber(
elevenDigits: string
): Date | void;
declare function possibleBirthDateOfHNumber(elevenDigits: string): Date | void;
declare function possibleBirthDateOfDNumber(elevenDigits: string): Date | void;
declare function getBirthDate(elevenDigitsWithDDMMYY: string): Date | void;
declare function isValidCheckDigits(elevenDigits: string): boolean;
declare function isValidCheckDigit(
staticSequence: number[],
elevenDigits: number[]
): boolean;
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"main": "dist/index.js",
"types": "dist/index.d.ts",
"scripts": {
"prepare": "npm run build",
"prepare": "npm run build && cp export.flow.js dist/index.flow.js",
"build": "tsc",
"start": "tsc --watch",
"test": "jest"
Expand Down

0 comments on commit a5b3a21

Please sign in to comment.