mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-02-03 23:42:50 +00:00
Create a type definition for npm module hark (#38375)
* Create a type definition for npm module hark * Update index.d.ts * Update index.d.ts
This commit is contained in:
parent
444e10e486
commit
d544b41b87
22
types/hark/hark-tests.ts
Normal file
22
types/hark/hark-tests.ts
Normal file
@ -0,0 +1,22 @@
|
||||
import hark = require('hark');
|
||||
|
||||
navigator.mediaDevices.getUserMedia({ audio: true, video: true }).then(
|
||||
(stream) => {
|
||||
const option: hark.Option = {
|
||||
smoothing: 0.1,
|
||||
interval: 50,
|
||||
history: 10,
|
||||
threshold: -50
|
||||
};
|
||||
const h: hark.Harker = hark(stream, option);
|
||||
h.stop();
|
||||
h.resume();
|
||||
h.on('speaking', () => {
|
||||
console.log('speaking');
|
||||
});
|
||||
|
||||
h.on('stopped_speaking', () => {
|
||||
console.log('stop speaking');
|
||||
});
|
||||
}
|
||||
);
|
||||
34
types/hark/index.d.ts
vendored
Normal file
34
types/hark/index.d.ts
vendored
Normal file
@ -0,0 +1,34 @@
|
||||
// Type definitions for hark 1.2
|
||||
// Project: https://github.com/otalk/hark
|
||||
// Definitions by: baiyufei <https://github.com/baiyufei>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
export = hark;
|
||||
|
||||
declare function hark(stream: HTMLAudioElement | HTMLVideoElement | MediaStream, option?: hark.Option): hark.Harker;
|
||||
|
||||
declare namespace hark {
|
||||
interface Option {
|
||||
smoothing?: number;
|
||||
interval?: number;
|
||||
threshold?: number;
|
||||
play?: boolean;
|
||||
history?: number;
|
||||
}
|
||||
|
||||
interface Harker {
|
||||
speaking: boolean;
|
||||
suspend(): Promise<void>;
|
||||
resume(): Promise<void>;
|
||||
readonly state: AudioContextState;
|
||||
setThreshold(t: number): void;
|
||||
setInterval(i: number): void;
|
||||
stop(): void;
|
||||
speakingHistory: number[];
|
||||
|
||||
on(event: 'speaking' | 'stopped_speaking', listener: () => void): void;
|
||||
on(event: 'volume_change', listener: (currentVolume: number, threshold: number) => void): void;
|
||||
on(event: 'state_change', listener: (state: AudioContextState) => void): void;
|
||||
}
|
||||
}
|
||||
23
types/hark/tsconfig.json
Normal file
23
types/hark/tsconfig.json
Normal file
@ -0,0 +1,23 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6", "dom"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictFunctionTypes": true,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"hark-tests.ts"
|
||||
]
|
||||
}
|
||||
1
types/hark/tslint.json
Normal file
1
types/hark/tslint.json
Normal file
@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Loading…
Reference in New Issue
Block a user