@smithy/util-stream
Advanced tools
Comparing version 2.0.24 to 2.1.0
@@ -1,20 +0,1 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.transformFromString = exports.transformToString = void 0; | ||
const util_base64_1 = require("@smithy/util-base64"); | ||
const util_utf8_1 = require("@smithy/util-utf8"); | ||
const Uint8ArrayBlobAdapter_1 = require("./Uint8ArrayBlobAdapter"); | ||
function transformToString(payload, encoding = "utf-8") { | ||
if (encoding === "base64") { | ||
return (0, util_base64_1.toBase64)(payload); | ||
} | ||
return (0, util_utf8_1.toUtf8)(payload); | ||
} | ||
exports.transformToString = transformToString; | ||
function transformFromString(str, encoding) { | ||
if (encoding === "base64") { | ||
return Uint8ArrayBlobAdapter_1.Uint8ArrayBlobAdapter.mutate((0, util_base64_1.fromBase64)(str)); | ||
} | ||
return Uint8ArrayBlobAdapter_1.Uint8ArrayBlobAdapter.mutate((0, util_utf8_1.fromUtf8)(str)); | ||
} | ||
exports.transformFromString = transformFromString; | ||
module.exports = require("../index.js"); |
@@ -1,22 +0,1 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.Uint8ArrayBlobAdapter = void 0; | ||
const transforms_1 = require("./transforms"); | ||
class Uint8ArrayBlobAdapter extends Uint8Array { | ||
static fromString(source, encoding = "utf-8") { | ||
switch (typeof source) { | ||
case "string": | ||
return (0, transforms_1.transformFromString)(source, encoding); | ||
default: | ||
throw new Error(`Unsupported conversion from ${typeof source} to Uint8ArrayBlobAdapter.`); | ||
} | ||
} | ||
static mutate(source) { | ||
Object.setPrototypeOf(source, Uint8ArrayBlobAdapter.prototype); | ||
return source; | ||
} | ||
transformToString(encoding = "utf-8") { | ||
return (0, transforms_1.transformToString)(this, encoding); | ||
} | ||
} | ||
exports.Uint8ArrayBlobAdapter = Uint8ArrayBlobAdapter; | ||
module.exports = require("../index.js"); |
@@ -1,6 +0,87 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const tslib_1 = require("tslib"); | ||
tslib_1.__exportStar(require("./blob/Uint8ArrayBlobAdapter"), exports); | ||
tslib_1.__exportStar(require("./getAwsChunkedEncodingStream"), exports); | ||
tslib_1.__exportStar(require("./sdk-stream-mixin"), exports); | ||
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 __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 = {}; | ||
__export(src_exports, { | ||
Uint8ArrayBlobAdapter: () => Uint8ArrayBlobAdapter | ||
}); | ||
module.exports = __toCommonJS(src_exports); | ||
// src/blob/transforms.ts | ||
var import_util_base64 = require("@smithy/util-base64"); | ||
var import_util_utf8 = require("@smithy/util-utf8"); | ||
function transformToString(payload, encoding = "utf-8") { | ||
if (encoding === "base64") { | ||
return (0, import_util_base64.toBase64)(payload); | ||
} | ||
return (0, import_util_utf8.toUtf8)(payload); | ||
} | ||
__name(transformToString, "transformToString"); | ||
function transformFromString(str, encoding) { | ||
if (encoding === "base64") { | ||
return Uint8ArrayBlobAdapter.mutate((0, import_util_base64.fromBase64)(str)); | ||
} | ||
return Uint8ArrayBlobAdapter.mutate((0, import_util_utf8.fromUtf8)(str)); | ||
} | ||
__name(transformFromString, "transformFromString"); | ||
// src/blob/Uint8ArrayBlobAdapter.ts | ||
var _Uint8ArrayBlobAdapter = class _Uint8ArrayBlobAdapter extends Uint8Array { | ||
/** | ||
* @param source - such as a string or Stream. | ||
* @returns a new Uint8ArrayBlobAdapter extending Uint8Array. | ||
*/ | ||
static fromString(source, encoding = "utf-8") { | ||
switch (typeof source) { | ||
case "string": | ||
return transformFromString(source, encoding); | ||
default: | ||
throw new Error(`Unsupported conversion from ${typeof source} to Uint8ArrayBlobAdapter.`); | ||
} | ||
} | ||
/** | ||
* @param source - Uint8Array to be mutated. | ||
* @returns the same Uint8Array but with prototype switched to Uint8ArrayBlobAdapter. | ||
*/ | ||
static mutate(source) { | ||
Object.setPrototypeOf(source, _Uint8ArrayBlobAdapter.prototype); | ||
return source; | ||
} | ||
/** | ||
* @param encoding - default 'utf-8'. | ||
* @returns the blob as string. | ||
*/ | ||
transformToString(encoding = "utf-8") { | ||
return transformToString(this, encoding); | ||
} | ||
}; | ||
__name(_Uint8ArrayBlobAdapter, "Uint8ArrayBlobAdapter"); | ||
var Uint8ArrayBlobAdapter = _Uint8ArrayBlobAdapter; | ||
// src/index.ts | ||
__reExport(src_exports, require("././getAwsChunkedEncodingStream"), module.exports); | ||
__reExport(src_exports, require("././sdk-stream-mixin"), module.exports); | ||
// Annotate the CommonJS export names for ESM import in node: | ||
0 && (module.exports = { | ||
Uint8ArrayBlobAdapter, | ||
...require("././getAwsChunkedEncodingStream"), | ||
...require("././sdk-stream-mixin") | ||
}); |
{ | ||
"name": "@smithy/util-stream", | ||
"version": "2.0.24", | ||
"version": "2.1.0", | ||
"scripts": { | ||
"build": "concurrently 'yarn:build:cjs' 'yarn:build:es' 'yarn:build:types && yarn build:types:downlevel'", | ||
"build:cjs": "yarn g:tsc -p tsconfig.cjs.json", | ||
"build:cjs": "node ../../scripts/inline util-stream", | ||
"build:es": "yarn g:tsc -p tsconfig.es.json", | ||
@@ -27,13 +27,13 @@ "build:types": "yarn g:tsc -p tsconfig.types.json", | ||
"dependencies": { | ||
"@smithy/fetch-http-handler": "^2.3.2", | ||
"@smithy/node-http-handler": "^2.2.2", | ||
"@smithy/types": "^2.8.0", | ||
"@smithy/util-base64": "^2.0.1", | ||
"@smithy/util-buffer-from": "^2.0.0", | ||
"@smithy/util-hex-encoding": "^2.0.0", | ||
"@smithy/util-utf8": "^2.0.2", | ||
"@smithy/fetch-http-handler": "^2.4.0", | ||
"@smithy/node-http-handler": "^2.3.0", | ||
"@smithy/types": "^2.9.0", | ||
"@smithy/util-base64": "^2.1.0", | ||
"@smithy/util-buffer-from": "^2.1.0", | ||
"@smithy/util-hex-encoding": "^2.1.0", | ||
"@smithy/util-utf8": "^2.1.0", | ||
"tslib": "^2.5.0" | ||
}, | ||
"devDependencies": { | ||
"@smithy/util-test": "^0.1.12", | ||
"@smithy/util-test": "^0.1.13", | ||
"@types/chai-as-promised": "^7.1.2", | ||
@@ -40,0 +40,0 @@ "@types/node": "^14.14.31", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
39652
581