node: Move TypeScript source files into ts/ directory

This way, files that reference the non-compiled Native.js/.d.ts can
consistently refer to it as '../Native' without having to copy
anything around.
This commit is contained in:
Jordan Rose
2021-11-08 16:17:00 -08:00
parent 1d216bf3a1
commit 734c0e02a3
48 changed files with 44 additions and 1077 deletions

View File

@@ -0,0 +1,37 @@
//
// Copyright 2020-2021 Signal Messenger, LLC.
// SPDX-License-Identifier: AGPL-3.0-only
//
import { SignalClientErrorBase } from '../../Errors';
export default class ByteArray {
contents: Buffer;
constructor(contents: Buffer, checkValid: (contents: Buffer) => void) {
checkValid(contents);
this.contents = Buffer.from(contents);
}
protected static checkLength(
expectedLength: number
): (contents: Buffer) => void {
return contents => {
if (contents.length !== expectedLength) {
throw new SignalClientErrorBase(
`Length of array supplied was ${contents.length} expected ${expectedLength}`,
undefined,
this.name
);
}
};
}
public getContents(): Buffer {
return this.contents;
}
public serialize(): Buffer {
return Buffer.from(this.contents);
}
}