π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Add a merge function
Manav Rathi4510c14af2b1
diff --git a/web/packages/utils/array.ts b/web/packages/utils/array.tsindex 10030b189e..a27a955498 100644--- a/web/packages/utils/array.ts+++ b/web/packages/utils/array.ts@@ -28,3 +28,21 @@ export const firstNonEmpty = (ss: (string | undefined)[]) => {for (const s of ss) if (s && s.length > 0) return s;return undefined;};++/**+ * Merge the given array of {@link Uint8Array}s in order into a single+ * {@link Uint8Array}.+ *+ * @param as An array of {@link Uint8Array}.+ */+export const mergeUint8Arrays = (as: Uint8Array[]) => {+ // A longer but better performing replacement of+ //+ // new Uint8Array(as.reduce((acc, x) => acc.concat(...x), []))+ //++ const len = as.reduce((len, xs) => len + xs.length, 0);+ const result = new Uint8Array(len);+ as.reduce((n, xs) => (result.set(xs, n), n + xs.length), 0);+ return result;+};