type definitions for node-microphone (#45180)

* type definitions for node-microphone

* removed blank lines

* fixed export issue

* added the allowSyntheticDefaultImports tsc option
This commit is contained in:
Andreas May 2020-06-04 03:14:24 +02:00 committed by GitHub
parent 5ca78f269e
commit f58b03ab6e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 67 additions and 0 deletions

25
types/node-microphone/index.d.ts vendored Normal file
View File

@ -0,0 +1,25 @@
// Type definitions for node-microphone 0.1
// Project: https://github.com/MexXxo/node-microphone#readme
// Definitions by: Andreas May <https://github.com/Maanex>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference types="node" />
interface MicrophoneOptions {
endian?: 'big' | 'little';
bitwidth?: 8 | 16 | 24;
encoding?: 'signed-integer' | 'unsigned-integer';
rate?: 8000 | 16000 | 44100;
channels?: 1 | 2;
device?: 'hw:0,0' | 'plughw:1,0' | 'default';
additionalParameters?: any;
}
declare class Microphone {
constructor(options?: MicrophoneOptions);
startRecording(): NodeJS.WriteStream;
stopRecording(): void;
}
export = Microphone;

View File

@ -0,0 +1,16 @@
import Microphone from "node-microphone";
const mic = new Microphone({
channels: 1,
bitwidth: 16,
endian: "little",
device: "default",
encoding: "signed-integer",
rate: 44100,
additionalParameters: {}
});
const stream = mic.startRecording();
stream.pipe(process.stdout);
mic.stopRecording();

View File

@ -0,0 +1,25 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6",
"dom"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictFunctionTypes": true,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true,
"allowSyntheticDefaultImports": true
},
"files": [
"index.d.ts",
"node-microphone-tests.ts"
]
}

View File

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