-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.ts
30 lines (26 loc) · 798 Bytes
/
index.ts
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
// Copyright (c) Holly Stubbs (tgpholly) - Licensed under MIT
// Check LICENSE in repository root for more information.
import { IReader } from "./readers/IReader";
import { IWriter } from "./writers/IWriter";
import { ReaderBE } from "./readers/ReaderBE";
import { ReaderLE } from "./readers/ReaderLE";
import { WriterBE } from "./writers/WriterBE";
import { WriterLE } from "./writers/WriterLE";
export enum Endian {
LE,
BE
}
export function createReader(endianness:Endian, buffer:Buffer) : IReader {
if (endianness === Endian.LE) {
return new ReaderLE(buffer);
} else {
return new ReaderBE(buffer);
}
}
export function createWriter(endianness:Endian, size?:number) : IWriter {
if (endianness === Endian.LE) {
return new WriterLE(size);
} else {
return new WriterBE(size);
}
}