Rocky_Mountain_Vending/.pnpm-store/v10/files/a4/7866059ece0e7fee637ab496f8ef6cd32d50120993343e595eb3fba041dd66ba389f3a4c59aea1bc0cd3fdc2258d513d617b3d508b7d7d544c95a44dcdc8d9
DMleadgen 46d973904b
Initial commit: Rocky Mountain Vending website
Next.js website for Rocky Mountain Vending company featuring:
- Product catalog with Stripe integration
- Service areas and parts pages
- Admin dashboard with Clerk authentication
- SEO optimized pages with JSON-LD structured data

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-12 16:22:15 -07:00

61 lines
No EOL
1.7 KiB
Text

/**
* @license
* Copyright 2024 Google Inc.
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @internal
*/
export function stringToTypedArray(string, base64Encoded = false) {
if (base64Encoded) {
// TODO: use
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array/fromBase64
// once available.
if (typeof Buffer === 'function') {
return Buffer.from(string, 'base64');
}
return Uint8Array.from(atob(string), m => {
return m.codePointAt(0);
});
}
return new TextEncoder().encode(string);
}
/**
* @internal
*/
export function stringToBase64(str) {
return typedArrayToBase64(new TextEncoder().encode(str));
}
/**
* @internal
*/
export function typedArrayToBase64(typedArray) {
// chunkSize should be less V8 limit on number of arguments!
// https://github.com/v8/v8/blob/d3de848bea727518aee94dd2fd42ba0b62037a27/src/objects/code.h#L444
const chunkSize = 65534;
const chunks = [];
for (let i = 0; i < typedArray.length; i += chunkSize) {
const chunk = typedArray.subarray(i, i + chunkSize);
chunks.push(String.fromCodePoint.apply(null, chunk));
}
const binaryString = chunks.join('');
return btoa(binaryString);
}
/**
* @internal
*/
export function mergeUint8Arrays(items) {
let length = 0;
for (const item of items) {
length += item.length;
}
// Create a new array with total length and merge all source arrays.
const result = new Uint8Array(length);
let offset = 0;
for (const item of items) {
result.set(item, offset);
offset += item.length;
}
return result;
}
//# sourceMappingURL=encoding.js.map