diff --git a/types/iopipe__iopipe/index.d.ts b/types/iopipe__iopipe/index.d.ts new file mode 100644 index 0000000000..338de9ca58 --- /dev/null +++ b/types/iopipe__iopipe/index.d.ts @@ -0,0 +1,28 @@ +// Type definitions for iopipe__iopipe 1.12 +// Project: https://github.com/iopipe/iopipe (Does not have to be to GitHub, but prefer linking to a source code repository rather than to a project website.) +// Definitions by: Javon Harper +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +declare function iopipe(config?: iopipe.LibraryConfig): iopipe.FunctionWrapper; + +declare namespace iopipe { + function label(label: string): void; + + function metric(label: string, value: number): void; + + namespace mark { + function start(label: string): void; + function end(label: string): void; + } + + interface LibraryConfig { + debug?: boolean; + token?: string; + networkTimeout?: number; + timeoutWindow?: number; + } + + type FunctionWrapper = (handler: any) => void; +} + +export = iopipe; diff --git a/types/iopipe__iopipe/iopipe__iopipe-tests.ts b/types/iopipe__iopipe/iopipe__iopipe-tests.ts new file mode 100644 index 0000000000..f5bd387dc8 --- /dev/null +++ b/types/iopipe__iopipe/iopipe__iopipe-tests.ts @@ -0,0 +1,17 @@ +import iopipe = require('iopipe__iopipe'); + +const config = { + token: "ABCDEFG" +}; + +function run(event: any, context: any, callback?: any) { + iopipe.label('my label'); + + iopipe.metric("magic number", 42); + + iopipe.mark.start("my-db-call"); + // an expensive database query + iopipe.mark.end("my-db-call"); +} + +iopipe(config)(run); diff --git a/types/iopipe__iopipe/tsconfig.json b/types/iopipe__iopipe/tsconfig.json new file mode 100644 index 0000000000..01d23ff29d --- /dev/null +++ b/types/iopipe__iopipe/tsconfig.json @@ -0,0 +1,26 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "iopipe__iopipe-tests.ts" + ], + "paths": { + "@iopipe/iopipe": ["iopipe__iopipe"] + } +} diff --git a/types/iopipe__iopipe/tslint.json b/types/iopipe__iopipe/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/iopipe__iopipe/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }