Add extracted source directory and README navigation

This commit is contained in:
Shawn Bot
2026-03-31 14:56:06 +00:00
parent 6252bb6eb5
commit 91e01d755b
4757 changed files with 984951 additions and 0 deletions

View File

@@ -0,0 +1,264 @@
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
// src/index.ts
var src_exports = {};
__export(src_exports, {
FetchHttpHandler: () => FetchHttpHandler,
keepAliveSupport: () => keepAliveSupport,
streamCollector: () => streamCollector
});
module.exports = __toCommonJS(src_exports);
// src/fetch-http-handler.ts
var import_protocol_http = require("@smithy/protocol-http");
var import_querystring_builder = require("@smithy/querystring-builder");
// src/create-request.ts
function createRequest(url, requestOptions) {
return new Request(url, requestOptions);
}
__name(createRequest, "createRequest");
// src/request-timeout.ts
function requestTimeout(timeoutInMs = 0) {
return new Promise((resolve, reject) => {
if (timeoutInMs) {
setTimeout(() => {
const timeoutError = new Error(`Request did not complete within ${timeoutInMs} ms`);
timeoutError.name = "TimeoutError";
reject(timeoutError);
}, timeoutInMs);
}
});
}
__name(requestTimeout, "requestTimeout");
// src/fetch-http-handler.ts
var keepAliveSupport = {
supported: void 0
};
var FetchHttpHandler = class _FetchHttpHandler {
static {
__name(this, "FetchHttpHandler");
}
/**
* @returns the input if it is an HttpHandler of any class,
* or instantiates a new instance of this handler.
*/
static create(instanceOrOptions) {
if (typeof instanceOrOptions?.handle === "function") {
return instanceOrOptions;
}
return new _FetchHttpHandler(instanceOrOptions);
}
constructor(options) {
if (typeof options === "function") {
this.configProvider = options().then((opts) => opts || {});
} else {
this.config = options ?? {};
this.configProvider = Promise.resolve(this.config);
}
if (keepAliveSupport.supported === void 0) {
keepAliveSupport.supported = Boolean(
typeof Request !== "undefined" && "keepalive" in createRequest("https://[::1]")
);
}
}
destroy() {
}
async handle(request, { abortSignal } = {}) {
if (!this.config) {
this.config = await this.configProvider;
}
const requestTimeoutInMs = this.config.requestTimeout;
const keepAlive = this.config.keepAlive === true;
const credentials = this.config.credentials;
if (abortSignal?.aborted) {
const abortError = new Error("Request aborted");
abortError.name = "AbortError";
return Promise.reject(abortError);
}
let path = request.path;
const queryString = (0, import_querystring_builder.buildQueryString)(request.query || {});
if (queryString) {
path += `?${queryString}`;
}
if (request.fragment) {
path += `#${request.fragment}`;
}
let auth = "";
if (request.username != null || request.password != null) {
const username = request.username ?? "";
const password = request.password ?? "";
auth = `${username}:${password}@`;
}
const { port, method } = request;
const url = `${request.protocol}//${auth}${request.hostname}${port ? `:${port}` : ""}${path}`;
const body = method === "GET" || method === "HEAD" ? void 0 : request.body;
const requestOptions = {
body,
headers: new Headers(request.headers),
method,
credentials
};
if (this.config?.cache) {
requestOptions.cache = this.config.cache;
}
if (body) {
requestOptions.duplex = "half";
}
if (typeof AbortController !== "undefined") {
requestOptions.signal = abortSignal;
}
if (keepAliveSupport.supported) {
requestOptions.keepalive = keepAlive;
}
if (typeof this.config.requestInit === "function") {
Object.assign(requestOptions, this.config.requestInit(request));
}
let removeSignalEventListener = /* @__PURE__ */ __name(() => {
}, "removeSignalEventListener");
const fetchRequest = createRequest(url, requestOptions);
const raceOfPromises = [
fetch(fetchRequest).then((response) => {
const fetchHeaders = response.headers;
const transformedHeaders = {};
for (const pair of fetchHeaders.entries()) {
transformedHeaders[pair[0]] = pair[1];
}
const hasReadableStream = response.body != void 0;
if (!hasReadableStream) {
return response.blob().then((body2) => ({
response: new import_protocol_http.HttpResponse({
headers: transformedHeaders,
reason: response.statusText,
statusCode: response.status,
body: body2
})
}));
}
return {
response: new import_protocol_http.HttpResponse({
headers: transformedHeaders,
reason: response.statusText,
statusCode: response.status,
body: response.body
})
};
}),
requestTimeout(requestTimeoutInMs)
];
if (abortSignal) {
raceOfPromises.push(
new Promise((resolve, reject) => {
const onAbort = /* @__PURE__ */ __name(() => {
const abortError = new Error("Request aborted");
abortError.name = "AbortError";
reject(abortError);
}, "onAbort");
if (typeof abortSignal.addEventListener === "function") {
const signal = abortSignal;
signal.addEventListener("abort", onAbort, { once: true });
removeSignalEventListener = /* @__PURE__ */ __name(() => signal.removeEventListener("abort", onAbort), "removeSignalEventListener");
} else {
abortSignal.onabort = onAbort;
}
})
);
}
return Promise.race(raceOfPromises).finally(removeSignalEventListener);
}
updateHttpClientConfig(key, value) {
this.config = void 0;
this.configProvider = this.configProvider.then((config) => {
config[key] = value;
return config;
});
}
httpHandlerConfigs() {
return this.config ?? {};
}
};
// src/stream-collector.ts
var import_util_base64 = require("@smithy/util-base64");
var streamCollector = /* @__PURE__ */ __name(async (stream) => {
if (typeof Blob === "function" && stream instanceof Blob || stream.constructor?.name === "Blob") {
if (Blob.prototype.arrayBuffer !== void 0) {
return new Uint8Array(await stream.arrayBuffer());
}
return collectBlob(stream);
}
return collectStream(stream);
}, "streamCollector");
async function collectBlob(blob) {
const base64 = await readToBase64(blob);
const arrayBuffer = (0, import_util_base64.fromBase64)(base64);
return new Uint8Array(arrayBuffer);
}
__name(collectBlob, "collectBlob");
async function collectStream(stream) {
const chunks = [];
const reader = stream.getReader();
let isDone = false;
let length = 0;
while (!isDone) {
const { done, value } = await reader.read();
if (value) {
chunks.push(value);
length += value.length;
}
isDone = done;
}
const collected = new Uint8Array(length);
let offset = 0;
for (const chunk of chunks) {
collected.set(chunk, offset);
offset += chunk.length;
}
return collected;
}
__name(collectStream, "collectStream");
function readToBase64(blob) {
return new Promise((resolve, reject) => {
const reader = new FileReader();
reader.onloadend = () => {
if (reader.readyState !== 2) {
return reject(new Error("Reader aborted too early"));
}
const result = reader.result ?? "";
const commaIndex = result.indexOf(",");
const dataOffset = commaIndex > -1 ? commaIndex + 1 : result.length;
resolve(result.substring(dataOffset));
};
reader.onabort = () => reject(new Error("Read aborted"));
reader.onerror = () => reject(reader.error);
reader.readAsDataURL(blob);
});
}
__name(readToBase64, "readToBase64");
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
keepAliveSupport,
FetchHttpHandler,
streamCollector
});

View File

@@ -0,0 +1,262 @@
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
// src/index.ts
var src_exports = {};
__export(src_exports, {
Field: () => Field,
Fields: () => Fields,
HttpRequest: () => HttpRequest,
HttpResponse: () => HttpResponse,
IHttpRequest: () => import_types.HttpRequest,
getHttpHandlerExtensionConfiguration: () => getHttpHandlerExtensionConfiguration,
isValidHostname: () => isValidHostname,
resolveHttpHandlerRuntimeConfig: () => resolveHttpHandlerRuntimeConfig
});
module.exports = __toCommonJS(src_exports);
// src/extensions/httpExtensionConfiguration.ts
var getHttpHandlerExtensionConfiguration = /* @__PURE__ */ __name((runtimeConfig) => {
return {
setHttpHandler(handler) {
runtimeConfig.httpHandler = handler;
},
httpHandler() {
return runtimeConfig.httpHandler;
},
updateHttpClientConfig(key, value) {
runtimeConfig.httpHandler?.updateHttpClientConfig(key, value);
},
httpHandlerConfigs() {
return runtimeConfig.httpHandler.httpHandlerConfigs();
}
};
}, "getHttpHandlerExtensionConfiguration");
var resolveHttpHandlerRuntimeConfig = /* @__PURE__ */ __name((httpHandlerExtensionConfiguration) => {
return {
httpHandler: httpHandlerExtensionConfiguration.httpHandler()
};
}, "resolveHttpHandlerRuntimeConfig");
// src/Field.ts
var import_types = require("@smithy/types");
var Field = class {
static {
__name(this, "Field");
}
constructor({ name, kind = import_types.FieldPosition.HEADER, values = [] }) {
this.name = name;
this.kind = kind;
this.values = values;
}
/**
* Appends a value to the field.
*
* @param value The value to append.
*/
add(value) {
this.values.push(value);
}
/**
* Overwrite existing field values.
*
* @param values The new field values.
*/
set(values) {
this.values = values;
}
/**
* Remove all matching entries from list.
*
* @param value Value to remove.
*/
remove(value) {
this.values = this.values.filter((v) => v !== value);
}
/**
* Get comma-delimited string.
*
* @returns String representation of {@link Field}.
*/
toString() {
return this.values.map((v) => v.includes(",") || v.includes(" ") ? `"${v}"` : v).join(", ");
}
/**
* Get string values as a list
*
* @returns Values in {@link Field} as a list.
*/
get() {
return this.values;
}
};
// src/Fields.ts
var Fields = class {
constructor({ fields = [], encoding = "utf-8" }) {
this.entries = {};
fields.forEach(this.setField.bind(this));
this.encoding = encoding;
}
static {
__name(this, "Fields");
}
/**
* Set entry for a {@link Field} name. The `name`
* attribute will be used to key the collection.
*
* @param field The {@link Field} to set.
*/
setField(field) {
this.entries[field.name.toLowerCase()] = field;
}
/**
* Retrieve {@link Field} entry by name.
*
* @param name The name of the {@link Field} entry
* to retrieve
* @returns The {@link Field} if it exists.
*/
getField(name) {
return this.entries[name.toLowerCase()];
}
/**
* Delete entry from collection.
*
* @param name Name of the entry to delete.
*/
removeField(name) {
delete this.entries[name.toLowerCase()];
}
/**
* Helper function for retrieving specific types of fields.
* Used to grab all headers or all trailers.
*
* @param kind {@link FieldPosition} of entries to retrieve.
* @returns The {@link Field} entries with the specified
* {@link FieldPosition}.
*/
getByType(kind) {
return Object.values(this.entries).filter((field) => field.kind === kind);
}
};
// src/httpRequest.ts
var HttpRequest = class _HttpRequest {
static {
__name(this, "HttpRequest");
}
constructor(options) {
this.method = options.method || "GET";
this.hostname = options.hostname || "localhost";
this.port = options.port;
this.query = options.query || {};
this.headers = options.headers || {};
this.body = options.body;
this.protocol = options.protocol ? options.protocol.slice(-1) !== ":" ? `${options.protocol}:` : options.protocol : "https:";
this.path = options.path ? options.path.charAt(0) !== "/" ? `/${options.path}` : options.path : "/";
this.username = options.username;
this.password = options.password;
this.fragment = options.fragment;
}
/**
* Note: this does not deep-clone the body.
*/
static clone(request) {
const cloned = new _HttpRequest({
...request,
headers: { ...request.headers }
});
if (cloned.query) {
cloned.query = cloneQuery(cloned.query);
}
return cloned;
}
/**
* This method only actually asserts that request is the interface {@link IHttpRequest},
* and not necessarily this concrete class. Left in place for API stability.
*
* Do not call instance methods on the input of this function, and
* do not assume it has the HttpRequest prototype.
*/
static isInstance(request) {
if (!request) {
return false;
}
const req = request;
return "method" in req && "protocol" in req && "hostname" in req && "path" in req && typeof req["query"] === "object" && typeof req["headers"] === "object";
}
/**
* @deprecated use static HttpRequest.clone(request) instead. It's not safe to call
* this method because {@link HttpRequest.isInstance} incorrectly
* asserts that IHttpRequest (interface) objects are of type HttpRequest (class).
*/
clone() {
return _HttpRequest.clone(this);
}
};
function cloneQuery(query) {
return Object.keys(query).reduce((carry, paramName) => {
const param = query[paramName];
return {
...carry,
[paramName]: Array.isArray(param) ? [...param] : param
};
}, {});
}
__name(cloneQuery, "cloneQuery");
// src/httpResponse.ts
var HttpResponse = class {
static {
__name(this, "HttpResponse");
}
constructor(options) {
this.statusCode = options.statusCode;
this.reason = options.reason;
this.headers = options.headers || {};
this.body = options.body;
}
static isInstance(response) {
if (!response)
return false;
const resp = response;
return typeof resp.statusCode === "number" && typeof resp.headers === "object";
}
};
// src/isValidHostname.ts
function isValidHostname(hostname) {
const hostPattern = /^[a-z0-9][a-z0-9\.\-]*[a-z0-9]$/;
return hostPattern.test(hostname);
}
__name(isValidHostname, "isValidHostname");
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
getHttpHandlerExtensionConfiguration,
resolveHttpHandlerRuntimeConfig,
Field,
Fields,
HttpRequest,
HttpResponse,
isValidHostname
});

View File

@@ -0,0 +1,144 @@
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
// src/index.ts
var src_exports = {};
__export(src_exports, {
AlgorithmId: () => AlgorithmId,
EndpointURLScheme: () => EndpointURLScheme,
FieldPosition: () => FieldPosition,
HttpApiKeyAuthLocation: () => HttpApiKeyAuthLocation,
HttpAuthLocation: () => HttpAuthLocation,
IniSectionType: () => IniSectionType,
RequestHandlerProtocol: () => RequestHandlerProtocol,
SMITHY_CONTEXT_KEY: () => SMITHY_CONTEXT_KEY,
getDefaultClientConfiguration: () => getDefaultClientConfiguration,
resolveDefaultRuntimeConfig: () => resolveDefaultRuntimeConfig
});
module.exports = __toCommonJS(src_exports);
// src/auth/auth.ts
var HttpAuthLocation = /* @__PURE__ */ ((HttpAuthLocation2) => {
HttpAuthLocation2["HEADER"] = "header";
HttpAuthLocation2["QUERY"] = "query";
return HttpAuthLocation2;
})(HttpAuthLocation || {});
// src/auth/HttpApiKeyAuth.ts
var HttpApiKeyAuthLocation = /* @__PURE__ */ ((HttpApiKeyAuthLocation2) => {
HttpApiKeyAuthLocation2["HEADER"] = "header";
HttpApiKeyAuthLocation2["QUERY"] = "query";
return HttpApiKeyAuthLocation2;
})(HttpApiKeyAuthLocation || {});
// src/endpoint.ts
var EndpointURLScheme = /* @__PURE__ */ ((EndpointURLScheme2) => {
EndpointURLScheme2["HTTP"] = "http";
EndpointURLScheme2["HTTPS"] = "https";
return EndpointURLScheme2;
})(EndpointURLScheme || {});
// src/extensions/checksum.ts
var AlgorithmId = /* @__PURE__ */ ((AlgorithmId2) => {
AlgorithmId2["MD5"] = "md5";
AlgorithmId2["CRC32"] = "crc32";
AlgorithmId2["CRC32C"] = "crc32c";
AlgorithmId2["SHA1"] = "sha1";
AlgorithmId2["SHA256"] = "sha256";
return AlgorithmId2;
})(AlgorithmId || {});
var getChecksumConfiguration = /* @__PURE__ */ __name((runtimeConfig) => {
const checksumAlgorithms = [];
if (runtimeConfig.sha256 !== void 0) {
checksumAlgorithms.push({
algorithmId: () => "sha256" /* SHA256 */,
checksumConstructor: () => runtimeConfig.sha256
});
}
if (runtimeConfig.md5 != void 0) {
checksumAlgorithms.push({
algorithmId: () => "md5" /* MD5 */,
checksumConstructor: () => runtimeConfig.md5
});
}
return {
addChecksumAlgorithm(algo) {
checksumAlgorithms.push(algo);
},
checksumAlgorithms() {
return checksumAlgorithms;
}
};
}, "getChecksumConfiguration");
var resolveChecksumRuntimeConfig = /* @__PURE__ */ __name((clientConfig) => {
const runtimeConfig = {};
clientConfig.checksumAlgorithms().forEach((checksumAlgorithm) => {
runtimeConfig[checksumAlgorithm.algorithmId()] = checksumAlgorithm.checksumConstructor();
});
return runtimeConfig;
}, "resolveChecksumRuntimeConfig");
// src/extensions/defaultClientConfiguration.ts
var getDefaultClientConfiguration = /* @__PURE__ */ __name((runtimeConfig) => {
return getChecksumConfiguration(runtimeConfig);
}, "getDefaultClientConfiguration");
var resolveDefaultRuntimeConfig = /* @__PURE__ */ __name((config) => {
return resolveChecksumRuntimeConfig(config);
}, "resolveDefaultRuntimeConfig");
// src/http.ts
var FieldPosition = /* @__PURE__ */ ((FieldPosition2) => {
FieldPosition2[FieldPosition2["HEADER"] = 0] = "HEADER";
FieldPosition2[FieldPosition2["TRAILER"] = 1] = "TRAILER";
return FieldPosition2;
})(FieldPosition || {});
// src/middleware.ts
var SMITHY_CONTEXT_KEY = "__smithy_context";
// src/profile.ts
var IniSectionType = /* @__PURE__ */ ((IniSectionType2) => {
IniSectionType2["PROFILE"] = "profile";
IniSectionType2["SSO_SESSION"] = "sso-session";
IniSectionType2["SERVICES"] = "services";
return IniSectionType2;
})(IniSectionType || {});
// src/transfer.ts
var RequestHandlerProtocol = /* @__PURE__ */ ((RequestHandlerProtocol2) => {
RequestHandlerProtocol2["HTTP_0_9"] = "http/0.9";
RequestHandlerProtocol2["HTTP_1_0"] = "http/1.0";
RequestHandlerProtocol2["TDS_8_0"] = "tds/8.0";
return RequestHandlerProtocol2;
})(RequestHandlerProtocol || {});
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
HttpAuthLocation,
HttpApiKeyAuthLocation,
EndpointURLScheme,
AlgorithmId,
getDefaultClientConfiguration,
resolveDefaultRuntimeConfig,
FieldPosition,
SMITHY_CONTEXT_KEY,
IniSectionType,
RequestHandlerProtocol
});

View File

@@ -0,0 +1,16 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.fromBase64 = void 0;
const util_buffer_from_1 = require("@smithy/util-buffer-from");
const BASE64_REGEX = /^[A-Za-z0-9+/]*={0,2}$/;
const fromBase64 = (input) => {
if ((input.length * 3) % 4 !== 0) {
throw new TypeError(`Incorrect padding on base64 string.`);
}
if (!BASE64_REGEX.exec(input)) {
throw new TypeError(`Invalid base64 string.`);
}
const buffer = (0, util_buffer_from_1.fromString)(input, "base64");
return new Uint8Array(buffer.buffer, buffer.byteOffset, buffer.byteLength);
};
exports.fromBase64 = fromBase64;

View File

@@ -0,0 +1,27 @@
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
// src/index.ts
var src_exports = {};
module.exports = __toCommonJS(src_exports);
__reExport(src_exports, require("././fromBase64"), module.exports);
__reExport(src_exports, require("././toBase64"), module.exports);
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
fromBase64,
toBase64
});

View File

@@ -0,0 +1,19 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.toBase64 = void 0;
const util_buffer_from_1 = require("@smithy/util-buffer-from");
const util_utf8_1 = require("@smithy/util-utf8");
const toBase64 = (_input) => {
let input;
if (typeof _input === "string") {
input = (0, util_utf8_1.fromUtf8)(_input);
}
else {
input = _input;
}
if (typeof input !== "object" || typeof input.byteOffset !== "number" || typeof input.byteLength !== "number") {
throw new Error("@smithy/util-base64: toBase64 encoder function only accepts string | Uint8Array.");
}
return (0, util_buffer_from_1.fromArrayBuffer)(input.buffer, input.byteOffset, input.byteLength).toString("base64");
};
exports.toBase64 = toBase64;

View File

@@ -0,0 +1,20 @@
'use strict';
var isArrayBuffer = require('@smithy/is-array-buffer');
var buffer = require('buffer');
const fromArrayBuffer = (input, offset = 0, length = input.byteLength - offset) => {
if (!isArrayBuffer.isArrayBuffer(input)) {
throw new TypeError(`The "input" argument must be ArrayBuffer. Received type ${typeof input} (${input})`);
}
return buffer.Buffer.from(input, offset, length);
};
const fromString = (input, encoding) => {
if (typeof input !== "string") {
throw new TypeError(`The "input" argument must be of type string. Received type ${typeof input} (${input})`);
}
return encoding ? buffer.Buffer.from(input, encoding) : buffer.Buffer.from(input);
};
exports.fromArrayBuffer = fromArrayBuffer;
exports.fromString = fromString;

View File

@@ -0,0 +1,6 @@
'use strict';
const isArrayBuffer = (arg) => (typeof ArrayBuffer === "function" && arg instanceof ArrayBuffer) ||
Object.prototype.toString.call(arg) === "[object ArrayBuffer]";
exports.isArrayBuffer = isArrayBuffer;