mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-06-28 22:30:01 +00:00
Add subtitle definition
This commit is contained in:
18
types/subtitle/index.d.ts
vendored
Normal file
18
types/subtitle/index.d.ts
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
// Type definitions for subtitle 2.0
|
||||
// Project: https://github.com/gsantiago/subtitle.js#readme
|
||||
// Definitions by: Low Jeng Lam <https://github.com/jenglamlow>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
export interface subTitleType {
|
||||
start: number | string;
|
||||
end: number | string;
|
||||
text: string;
|
||||
setting?: string;
|
||||
}
|
||||
|
||||
export function parse(srtOrVtt: string): subTitleType[];
|
||||
export function stringify(captions: ReadonlyArray<subTitleType>): string;
|
||||
export function resync(captions: ReadonlyArray<subTitleType>, time: number): subTitleType[];
|
||||
export function toMs(timestamp: string): number;
|
||||
export function toSrtTime(timestamp: number): string;
|
||||
export function toVttTime(timestamp: number): string;
|
||||
27
types/subtitle/subtitle-tests.ts
Normal file
27
types/subtitle/subtitle-tests.ts
Normal file
@@ -0,0 +1,27 @@
|
||||
import * as Subtitle from 'subtitle';
|
||||
|
||||
Subtitle.parse("");
|
||||
|
||||
const subtitles = [
|
||||
{
|
||||
start: '00:00:20,000',
|
||||
end: '00:00:24,400',
|
||||
text: 'Bla Bla Bla Bla'
|
||||
},
|
||||
{
|
||||
start: 24600,
|
||||
end: 27800,
|
||||
text: 'Bla Bla Bla Bla',
|
||||
settings: 'align:middle line:90%'
|
||||
}
|
||||
];
|
||||
|
||||
const srt = Subtitle.stringify(subtitles);
|
||||
|
||||
const newSubtitles: Subtitle.subTitleType[] = Subtitle.resync(subtitles, 1000);
|
||||
|
||||
Subtitle.toMs('00:00:24,400');
|
||||
|
||||
Subtitle.toSrtTime(24400);
|
||||
|
||||
Subtitle.toVttTime(24400);
|
||||
23
types/subtitle/tsconfig.json
Normal file
23
types/subtitle/tsconfig.json
Normal file
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"subtitle-tests.ts"
|
||||
]
|
||||
}
|
||||
1
types/subtitle/tslint.json
Normal file
1
types/subtitle/tslint.json
Normal file
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Reference in New Issue
Block a user