Merge pull request #4943 from stpettersens/master

Type definitions and tests for node shortid module
This commit is contained in:
Masahiro Wakame
2015-07-17 00:51:26 +09:00
2 changed files with 22 additions and 0 deletions

10
shortid/shortid-tests.ts Normal file
View File

@@ -0,0 +1,10 @@
/// <reference path="shortid.d.ts" />
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

12
shortid/shortid.d.ts vendored Normal file
View File

@@ -0,0 +1,12 @@
// Type definitions for shortid
// Project: https://github.com/dylang/shortid
// Definitions by: Sam Saint-Pettersen <https://github.com/stpettersens>
// 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;
}