# srt-engine

> srt-engine

Latest version **0.0.9-beta.4** (published 2020-03-13) · MIT license · 0 weekly downloads

## Install

```sh
npm install srt-engine
pnpm add srt-engine
yarn add srt-engine
bun add srt-engine
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.9-beta.4 |
| Published | 2020-03-13 |
| First published | 2019-11-08 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 910.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | lego-web@qiyi.com |
| Maintainers | yinzhida |
| Keywords | srt |

## Links

- npm: https://www.npmjs.com/package/srt-engine
- npm.io page: https://npm.io/package/srt-engine

## Dependencies (3)

- [lodash.merge](https://npm.io/package/lodash.merge.md) ^4.6.2
- [query-string](https://npm.io/package/query-string.md) ^6.8.3
- [lodash.clonedeep](https://npm.io/package/lodash.clonedeep.md) ^4.5.0

## Recent versions

- 0.0.9-beta.4 (latest) — 2020-03-13
- 0.0.9-beta.1 — 2020-03-12
- 0.0.7 — 2019-11-08

## README

# srt engine
srt editor engine, improve performance by indexing

# install
```bash
npm i -S srt-engine
```

# usage
```js
import StrEngine from 'srt-engine';
let se = new SrtEngine();
se.load('your srt file url');
```
or you can load srt through `compile` method,
or `transform` a content array to a srt-engine instance.
```js
se.compile(text);
let dialogue = se.findByTime(10000); // milliseconds
const fileText = se.stringify({
  fontSize: 16,
  fontColor: #ffffff,
  bold: true,
  italic: true,
  underground: true,
  // align default 2, values: 
  // 7, 8, 9
  // 4, 5, 6
  // 1, 2, 3
  align: 2, 
})
```
dialogue object like this:
```js
{
  id: 1,
  uid: 1, // unique id
  startTimeInMilliSeconds: 0,
  endTimeInMilliSeconds: 3000,
  texts: ['an dialogue', '一个对话'],
}
```

# methods:
### load
param: url

return: promise --> SE instance
### compile
param: file text

return: SE instance
### transform
param: content Array

return: SE instance
### stringify
param: styles Object(all dialogue support fontSize, font), start, end

return: file text
### findByTime
param: milliseconds Number

return: dialogue Array
### findByText
param: text

return: dialogue Array
### findByUid
param: uid (an attribute of dialogue object)

return: an dialogue
### findByTimeRange
param: start end

return: dialogue Array
### addDialogue
param: dialogue index(position)

return: dialogue(cloneDeep)
### updateDialogueByUid
param: uid, dialogueInfos(like dialogue, not strict)

return: SE instance
### removeDialogueByUid
param: uid

return: SE instance
### sort
param: none

return: SE instance
### getContent
param: none

return: dialogue Array
### getOriginText
param: none

return: origin file text

---
_Source: https://npm.io/package/srt-engine · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
