forked from DefinitelyTyped/DefinitelyTyped
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request DefinitelyTyped#2375 from Bartvds/def/type-detect
added definition for type-detect
- Loading branch information
Showing
2 changed files
with
38 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/// <reference path="type-detect.d.ts" /> | ||
|
||
import td = require('type-detect'); | ||
|
||
var str: string; | ||
var bool: boolean; | ||
var x: any; | ||
|
||
str = td(123); | ||
|
||
var lib: td.Library = new td.Library(); | ||
|
||
lib.define(str, /aa/); | ||
lib.define(str, (val) => { | ||
return bool; | ||
}); | ||
str = lib.of(x); | ||
bool = lib.test(x, str); | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// Type definitions for type-detect v0.1.2 | ||
// Project: https://github.com/chaijs/type-detect | ||
// Definitions by: Bart van der Schoor <https://github.com/Bartvds> | ||
// Definitions: https://github.com/borisyankov/DefinitelyTyped | ||
|
||
declare module 'type-detect' { | ||
function type(val: any): string; | ||
|
||
module type { | ||
export class Library { | ||
of(val: any): string; | ||
define (type: string, test: RegExp): void; | ||
define (type: string, test: (val: any) => boolean): void; | ||
test (val: any, type: string): boolean; | ||
} | ||
} | ||
export = type; | ||
} |