Skip to content
Permalink
9bfb9ba527
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
26 lines (26 sloc) 645 Bytes
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
let encoder;
/**
* Returns a cached TextEncoder.
* @internal
*/
function getTextEncoder() {
if (encoder) {
return encoder;
}
if (typeof TextEncoder === "undefined") {
throw new Error(`Your browser environment is missing "TextEncoder".`);
}
encoder = new TextEncoder();
return encoder;
}
/**
* Converts a utf8 string into a byte array.
* @param content - The utf8 string to convert.
* @internal
*/
export function utf8ToBytes(content) {
return getTextEncoder().encode(content);
}
//# sourceMappingURL=utf8.browser.js.map