diff --git a/types/node-timecodes/index.d.ts b/types/node-timecodes/index.d.ts new file mode 100644 index 0000000000..71d720d55a --- /dev/null +++ b/types/node-timecodes/index.d.ts @@ -0,0 +1,21 @@ +// Type definitions for node-timecodes 2.5 +// Project: https://github.com/Synchronized-TV/node-timecodes +// Definitions by: Mitsuka Hanakura a.k.a. ragg +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export interface TimecodeOptions { + frameRate?: number; + ms?: boolean; +} + +export function toSeconds(timecode: string, frameRate?: number): number; +export function fromSeconds(seconds: number, option?: TimecodeOptions): string; +export const constants: { framerate: number }; + +declare const _: { + toSeconds: typeof toSeconds; + fromSeconds: typeof fromSeconds; + constants: typeof constants; +}; + +export default _; diff --git a/types/node-timecodes/node-timecodes-tests.ts b/types/node-timecodes/node-timecodes-tests.ts new file mode 100644 index 0000000000..8581100225 --- /dev/null +++ b/types/node-timecodes/node-timecodes-tests.ts @@ -0,0 +1,11 @@ +import timecode, { fromSeconds, toSeconds, TimecodeOptions } from 'node-timecodes'; + +type Option = TimecodeOptions; + +timecode.fromSeconds(1); +timecode.fromSeconds(1, { frameRate: 30, ms: true }); +fromSeconds(1); +timecode.toSeconds('00:01:00:00'); +timecode.toSeconds('00:01:00:00', 30); +toSeconds('00:01:00:00', 30); +timecode.constants.framerate; diff --git a/types/node-timecodes/tsconfig.json b/types/node-timecodes/tsconfig.json new file mode 100644 index 0000000000..69c87993de --- /dev/null +++ b/types/node-timecodes/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictFunctionTypes": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "node-timecodes-tests.ts" + ] +} diff --git a/types/node-timecodes/tslint.json b/types/node-timecodes/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/node-timecodes/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }