Moves stringToArrayBuffer into util folder
This commit is contained in:
parent
829e42ca6e
commit
e86a6119cd
8 changed files with 10 additions and 30 deletions
4
js/modules/string_to_array_buffer.d.ts
vendored
4
js/modules/string_to_array_buffer.d.ts
vendored
|
@ -1,4 +0,0 @@
|
|||
// Copyright 2020 Signal Messenger, LLC
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
export function stringToArrayBuffer(string: string): ArrayBuffer;
|
|
@ -1,14 +0,0 @@
|
|||
// Copyright 2018-2020 Signal Messenger, LLC
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
exports.stringToArrayBuffer = string => {
|
||||
if (typeof string !== 'string') {
|
||||
throw new TypeError("'string' must be a string");
|
||||
}
|
||||
|
||||
const array = new Uint8Array(string.length);
|
||||
for (let i = 0; i < string.length; i += 1) {
|
||||
array[i] = string.charCodeAt(i);
|
||||
}
|
||||
return array.buffer;
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue