MCPcopy Create free account
hub / github.com/awslabs/llrt / BufferConstructor

Interface BufferConstructor

types/buffer.d.ts:79–315  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

77 valueOf(): T;
78 };
79 interface BufferConstructor {
80 /**
81 * Returns the byte length of a string when encoded using `encoding`.
82 * This is not the same as [`String.prototype.length`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/length), which does not account
83 * for the encoding that is used to convert the string into bytes.
84 *
85 * ```js
86 * import { Buffer } from 'buffer';
87 *
88 * const str = '\u00bd + \u00bc = \u00be';
89 *
90 * console.log(`${str}: ${str.length} characters, ` +
91 * `${Buffer.byteLength(str, 'utf8')} bytes`);
92 * // Prints: ½ + ¼ = ¾: 9 characters, 12 bytes
93 * ```
94 *
95 * When `string` is a
96 * `Buffer`/[`DataView`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView)/[`TypedArray`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/-
97 * Reference/Global_Objects/TypedArray)/[`ArrayBuffer`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer)/[`SharedArrayBuffer`](https://develop-
98 * er.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer), the byte length as reported by `.byteLength`is returned.
99 * @param string A value to calculate the length of.
100 * @param [encoding='utf8'] If `string` is a string, this is its encoding.
101 * @return The number of bytes contained within `string`.
102 */
103 byteLength(
104 string:
105 | string
106 | Buffer
107 | QuickJS.ArrayBufferView
108 | ArrayBuffer
109 | SharedArrayBuffer,
110 encoding?: BufferEncoding
111 ): number;
112 /**
113 * Returns a new `Buffer` which is the result of concatenating all the `Buffer` instances in the `list` together.
114 *
115 * If the list has no items, or if the `totalLength` is 0, then a new zero-length `Buffer` is returned.
116 *
117 * If `totalLength` is not provided, it is calculated from the `Buffer` instances
118 * in `list` by adding their lengths.
119 *
120 * If `totalLength` is provided, it is coerced to an unsigned integer. If the
121 * combined length of the `Buffer`s in `list` exceeds `totalLength`, the result is
122 * truncated to `totalLength`.
123 *
124 * ```js
125 * import { Buffer } from 'buffer';
126 *
127 * // Create a single `Buffer` from a list of three `Buffer` instances.
128 *
129 * const buf1 = Buffer.alloc(10);
130 * const buf2 = Buffer.alloc(14);
131 * const buf3 = Buffer.alloc(18);
132 * const totalLength = buf1.length + buf2.length + buf3.length;
133 *
134 * console.log(totalLength);
135 * // Prints: 42
136 *

Callers 29

buffer.test.tsFile · 0.80
readFilesRecursiveFunction · 0.80
url_to_http_optionsFunction · 0.80
path_to_file_urlFunction · 0.80
convert_trailing_spaceFunction · 0.80
strip_path_sentinelFunction · 0.80
from_strMethod · 0.80
set_prototypeFunction · 0.80
lambda-server.jsFile · 0.65
index.mjsFile · 0.65
segmentArrayFunction · 0.65

Calls

no outgoing calls

Tested by

no test coverage detected