summaryrefslogtreecommitdiff
path: root/lib/epub.js/types/locations.d.ts
blob: be314dafadac6629be0f1c5b7ad30b30c511c13a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import Spine from "./spine";
import Section from "./section";
import EpubCFI from "./epubcfi";

export default class Locations {
  constructor(spine: Spine, request?: Function, pause?: number);

  generate(chars: number): object;

  process(section: Section): Promise<Array<string>>;

	locationFromCfi(cfi: string | EpubCFI): Location;

	percentageFromCfi(cfi: string | EpubCFI): number;

  percentageFromLocation(loc: number): number;

  cfiFromLocation(loc: number): string;

  cfiFromPercentage(percentage: number): string;

	load(locations: string): Array<string>;

  save(): string;

  currentLocation(): Location;
  currentLocation(curr: string | number): void;

  length(): number;

  destroy(): void;

  private createRange(): {
    startContainer: Element,
    startOffset: number,
    endContainer: Element,
    endOffset: number
  };

  private parse(contents: Node, cfiBase: string, chars: number) : Array<string>;
}