mirror of
https://github.com/signalapp/Signal-Desktop.git
synced 2025-12-24 20:26:24 +00:00
Moves stringToArrayBuffer into util folder
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
// Copyright 2020 Signal Messenger, LLC
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
import { stringToArrayBuffer } from '../util/stringToArrayBuffer';
|
||||
|
||||
/* eslint-disable guard-for-in */
|
||||
/* eslint-disable no-restricted-syntax */
|
||||
/* eslint-disable no-proto */
|
||||
@@ -62,18 +64,6 @@ function ensureStringed(thing: any): any {
|
||||
throw new Error(`unsure of how to jsonify object of type ${typeof thing}`);
|
||||
}
|
||||
|
||||
function stringToArrayBuffer(string: string): ArrayBuffer {
|
||||
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;
|
||||
}
|
||||
|
||||
// Number formatting utils
|
||||
const utils = {
|
||||
getString,
|
||||
|
||||
Reference in New Issue
Block a user