Skip to content

Commit

Permalink
Merge pull request DefinitelyTyped#2375 from Bartvds/def/type-detect
Browse files Browse the repository at this point in the history
added definition for type-detect
  • Loading branch information
Bartvds committed Jun 19, 2014
2 parents 8366381 + b4eb7a7 commit 1937051
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
20 changes: 20 additions & 0 deletions type-detect/type-detect-tests.ts
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);


18 changes: 18 additions & 0 deletions type-detect/type-detect.d.ts
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;
}

0 comments on commit 1937051

Please sign in to comment.