UNPKG

esbuild-gas-plugin

Version:
42 lines (41 loc) 1 kB
"use strict"; // Copyright 2018-2023 the Deno authors. All rights reserved. MIT license. // This module is browser compatible. Object.defineProperty(exports, "__esModule", { value: true }); exports.StringReader = void 0; const buffer_js_1 = require("./buffer.js"); /** * Reader utility for strings. * * @example * ```ts * import { StringReader } from "https://deno.land/std@$STD_VERSION/io/string_reader.ts"; * * const data = new Uint8Array(6); * const r = new StringReader("abcdef"); * const res0 = await r.read(data); * const res1 = await r.read(new Uint8Array(6)); * * // Number of bytes read * console.log(res0); // 6 * console.log(res1); // null, no byte left to read. EOL * * // text * * console.log(new TextDecoder().decode(data)); // abcdef * ``` * * **Output:** * * ```text * 6 * null * abcdef * ``` */ class StringReader extends buffer_js_1.Buffer { constructor(s) { super(new TextEncoder().encode(s).buffer); } } exports.StringReader = StringReader;