mirror of
https://github.com/FlipsideCrypto/DefinitelyTyped.git
synced 2026-02-06 10:56:53 +00:00
added definition for type-detect
This commit is contained in:
parent
6745ac3279
commit
b4eb7a76f3
20
type-detect/type-detect-tests.ts
Normal file
20
type-detect/type-detect-tests.ts
Normal file
@ -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
type-detect/type-detect.d.ts
vendored
Normal file
18
type-detect/type-detect.d.ts
vendored
Normal file
@ -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;
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user