diff --git a/types/wav-encoder/index.d.ts b/types/wav-encoder/index.d.ts new file mode 100644 index 0000000000..c865d9f971 --- /dev/null +++ b/types/wav-encoder/index.d.ts @@ -0,0 +1,26 @@ +// Type definitions for wav-encoder 1.3 +// Project: https://github.com/mohayonao/wav-encoder/ +// Definitions by: Candid Dauth +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +declare namespace WavEncoder { + interface AudioData { + sampleRate: number; + channelData: Float32Array[]; + } + + interface Options { + bitDepth: number; + float: boolean; + symmetric: boolean; + } +} + +declare const WavEncoder: { + encode: { + (audioData: WavEncoder.AudioData, opts?: WavEncoder.Options): Promise; + sync: (audioData: WavEncoder.AudioData, opts?: WavEncoder.Options) => ArrayBuffer; + } +}; + +export = WavEncoder; diff --git a/types/wav-encoder/tsconfig.json b/types/wav-encoder/tsconfig.json new file mode 100644 index 0000000000..8cf26da348 --- /dev/null +++ b/types/wav-encoder/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", + "wav-encoder-tests.ts" + ] +} diff --git a/types/wav-encoder/tslint.json b/types/wav-encoder/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/wav-encoder/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/wav-encoder/wav-encoder-tests.ts b/types/wav-encoder/wav-encoder-tests.ts new file mode 100644 index 0000000000..f33a0617ce --- /dev/null +++ b/types/wav-encoder/wav-encoder-tests.ts @@ -0,0 +1,24 @@ +import WavEncoder = require('wav-encoder'); + +const left = new Float32Array(10); +const right = new Float32Array(10); + +function encode(): Promise { + return WavEncoder.encode({ + sampleRate: 44100, + channelData: [ + left, + right + ] + }); +} + +function encodeSync(): ArrayBuffer { + return WavEncoder.encode.sync({ + sampleRate: 44100, + channelData: [ + left, + right + ] + }); +}