Add typings for wav-encoder 1.3 (#37727)

This commit is contained in:
Candid Dauth 2019-08-20 00:41:16 +02:00 committed by Sheetal Nandi
parent 00ac11f1e1
commit 7efed2a5e2
4 changed files with 74 additions and 0 deletions

26
types/wav-encoder/index.d.ts vendored Normal file
View File

@ -0,0 +1,26 @@
// Type definitions for wav-encoder 1.3
// Project: https://github.com/mohayonao/wav-encoder/
// Definitions by: Candid Dauth <https://github.com/cdauth>
// 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<ArrayBuffer>;
sync: (audioData: WavEncoder.AudioData, opts?: WavEncoder.Options) => ArrayBuffer;
}
};
export = WavEncoder;

View File

@ -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"
]
}

View File

@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }

View File

@ -0,0 +1,24 @@
import WavEncoder = require('wav-encoder');
const left = new Float32Array(10);
const right = new Float32Array(10);
function encode(): Promise<ArrayBuffer> {
return WavEncoder.encode({
sampleRate: 44100,
channelData: [
left,
right
]
});
}
function encodeSync(): ArrayBuffer {
return WavEncoder.encode.sync({
sampleRate: 44100,
channelData: [
left,
right
]
});
}