From f1e34355814e30f94e0b80680a6c6863e0b07c32 Mon Sep 17 00:00:00 2001 From: Sam Saint-Pettersen Date: Thu, 16 Jul 2015 11:52:55 +0100 Subject: [PATCH] Type definitions and tests for node shortid module --- shortid/shortid-tests.ts | 10 ++++++++++ shortid/shortid.d.ts | 12 ++++++++++++ 2 files changed, 22 insertions(+) create mode 100644 shortid/shortid-tests.ts create mode 100644 shortid/shortid.d.ts diff --git a/shortid/shortid-tests.ts b/shortid/shortid-tests.ts new file mode 100644 index 0000000000..31ee0df1d1 --- /dev/null +++ b/shortid/shortid-tests.ts @@ -0,0 +1,10 @@ +/// + +import shortid = require('shortid'); + +var my_short_id: string = shortid.generate(); +console.log(my_short_id); + +console.log('Is valid short id? => %s', shortid.isValid(my_short_id)); // => true +console.log('Is valid short id? => %s', shortid.isValid(5)); // => false +console.log('Is valid short id? => %s', shortid.isValid('i have spaces')); // => false diff --git a/shortid/shortid.d.ts b/shortid/shortid.d.ts new file mode 100644 index 0000000000..049e539695 --- /dev/null +++ b/shortid/shortid.d.ts @@ -0,0 +1,12 @@ +// Type definitions for shortid +// Project: https://github.com/dylang/shortid +// Definitions by: Sam Saint-Pettersen +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +declare module "shortid" { + export function generate(): string; + export function characters(string: string): string; + export function isValid(id: any): boolean; + export function worker(integer: number): void; + export function seed(float: number): void; +}