Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@aws-sdk/util-buffer-from

Package Overview
Dependencies
Maintainers
5
Versions
57
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@aws-sdk/util-buffer-from - npm Package Compare versions

Comparing version 1.0.0-gamma.7 to 1.0.0-rc.1

11

CHANGELOG.md

@@ -6,2 +6,13 @@ # Change Log

# [1.0.0-rc.1](https://github.com/aws/aws-sdk-js-v3/compare/v1.0.0-gamma.11...v1.0.0-rc.1) (2020-10-19)
### Features
* ready for release candidate ([#1578](https://github.com/aws/aws-sdk-js-v3/issues/1578)) ([519f66c](https://github.com/aws/aws-sdk-js-v3/commit/519f66c6388b91d0bd750a511e6d1af56196835e))
# [1.0.0-gamma.7](https://github.com/aws/aws-sdk-js-v3/compare/@aws-sdk/util-buffer-from@1.0.0-gamma.6...@aws-sdk/util-buffer-from@1.0.0-gamma.7) (2020-10-07)

@@ -8,0 +19,0 @@

6

dist/cjs/index.d.ts

@@ -1,4 +0,4 @@

/// <reference types="node" />
export declare function fromArrayBuffer(input: ArrayBuffer, offset?: number, length?: number): Buffer;
import { Buffer } from "buffer";
export declare const fromArrayBuffer: (input: ArrayBuffer, offset?: number, length?: number) => Buffer;
export declare type StringEncoding = "ascii" | "utf8" | "utf16le" | "ucs2" | "base64" | "latin1" | "binary" | "hex";
export declare function fromString(input: string, encoding?: StringEncoding): Buffer;
export declare const fromString: (input: string, encoding?: "ascii" | "utf8" | "utf16le" | "ucs2" | "base64" | "latin1" | "binary" | "hex" | undefined) => Buffer;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.fromString = exports.fromArrayBuffer = void 0;
var is_array_buffer_1 = require("@aws-sdk/is-array-buffer");
var buffer_1 = require("buffer");
function fromArrayBuffer(input, offset, length) {
if (offset === void 0) { offset = 0; }
if (length === void 0) { length = input.byteLength - offset; }
const is_array_buffer_1 = require("@aws-sdk/is-array-buffer");
const buffer_1 = require("buffer");
exports.fromArrayBuffer = (input, offset = 0, length = input.byteLength - offset) => {
if (!is_array_buffer_1.isArrayBuffer(input)) {
throw new Error("argument passed to fromArrayBuffer was not an ArrayBuffer");
throw new TypeError(`The "input" argument must be ArrayBuffer. Received type ${typeof input} (${input})`);
}
if (typeof buffer_1.Buffer.from === "function" && buffer_1.Buffer.from !== Uint8Array.from) {
return buffer_1.Buffer.from(input, offset, length);
}
// Any version of node that supports the optional offset and length
// parameters, which were added in Node 6.0.0, will support Buffer.from and
// have already returned. Throw if offset is not 0 or if length differs from
// the underlying buffer's length.
if (offset !== 0 || length !== input.byteLength) {
throw new Error("Unable to convert TypedArray to Buffer in Node " + process.version);
}
return new buffer_1.Buffer(input);
}
exports.fromArrayBuffer = fromArrayBuffer;
function fromString(input, encoding) {
return buffer_1.Buffer.from(input, offset, length);
};
exports.fromString = (input, encoding) => {
if (typeof input !== "string") {
throw new Error("argument passed to fromString was not a string");
throw new TypeError(`The "input" argument must be of type string. Received type ${typeof input} (${input})`);
}
if (typeof buffer_1.Buffer.from === "function" && buffer_1.Buffer.from !== Uint8Array.from) {
return buffer_1.Buffer.from(input, encoding);
}
return new buffer_1.Buffer(input, encoding);
}
exports.fromString = fromString;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7O0FBQUEsNERBQXlEO0FBQ3pELGlDQUFnQztBQUVoQyxTQUFnQixlQUFlLENBQUMsS0FBa0IsRUFBRSxNQUFVLEVBQUUsTUFBMEM7SUFBdEQsdUJBQUEsRUFBQSxVQUFVO0lBQUUsdUJBQUEsRUFBQSxTQUFpQixLQUFLLENBQUMsVUFBVSxHQUFHLE1BQU07SUFDeEcsSUFBSSxDQUFDLCtCQUFhLENBQUMsS0FBSyxDQU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gfHwgbGVuZ3RoICE9PSBpbnB1dC5ieXRlTGVuZ3RoKSB7XG4gICAgdGhyb3cgbmV3IEVycm9yKGBVbmFibGUgdG8gY29udmVydCBUeXBlZEFycmF5IHRvIEJ1ZmZlciBpbiBOb2RlICR7cHJvY2Vzcy52ZXJzaW9ufWApO1xuICB9XG4gIHJldHVybiBuZXcgQnVmZmVyKGlucHV0KTtcbn1cbmV4cG9ydCB0eXBlIFN0cmluZ0VuY29kaW5nID0gXCJhc2NpaVwiIHwgXCJ1dGY4XCIgfCBcInV0ZjE2bGVcIiB8IFwidWNzMlwiIHwgXCJiYXNlNjRcIiB8IFwibGF0aW4xXCIgfCBcImJpbmFyeVwiIHwgXCJoZXhcIjtcbmV4cG9ydCBmdW5jdGlvbiBmcm9tU3RyaW5nKGlucHV0OiBzdHJpbmcsIGVuY29kaW5nPzogU3RyaW5nRW5jb2RpbmcpOiBCdWZmZXIge1xuICBpZiAodHlwZW9mIGlucHV0ICE9PSBcInN0cmluZ1wiKSB7XG4gICAgdGhyb3cgbmV3IEVycm9yKFwiYXJndW1lbnQgcGFzc2VkIHRvIGZyb21TdHJpbmcgd2FzIG5vdCBhIHN0cmluZ1wiKTtcbiAgfVxuXG4gIGlmICh0eXBlb2YgQnVmZmVyLmZyb20gPT09IFwiZnVuY3Rpb25cIiAmJiBCdWZmZXIuZnJvbSAhPT0gVWludDhBcnJheS5mcm9tKSB7XG4gICAgcmV0dXJuIEJ1ZmZlci5mcm9tKGlucHV0LCBlbmNvZGluZyBhcyBhbnkpO1xuICB9XG5cbiAgcmV0dXJuIG5ldyBCdWZmZXIoaW5wdXQsIGVuY29kaW5nIGFzIGFueSk7XG59XG4iXX0=
return encoding ? buffer_1.Buffer.from(input, encoding) : buffer_1.Buffer.from(input);
};
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvaW5kZX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set?: number, length?: number): Buffer;
import { Buffer } from "buffer";
export declare const fromArrayBuffer: (input: ArrayBuffer, offset?: number, length?: number) => Buffer;
export declare type StringEncoding = "ascii" | "utf8" | "utf16le" | "ucs2" | "base64" | "latin1" | "binary" | "hex";
export declare function fromString(input: string, encoding?: StringEncoding): Buffer;
export declare const fromString: (input: string, encoding?: "ascii" | "utf8" | "utf16le" | "ucs2" | "base64" | "latin1" | "binary" | "hex" | undefined) => Buffer;
import { isArrayBuffer } from "@aws-sdk/is-array-buffer";
import { Buffer } from "buffer";
export function fromArrayBuffer(input, offset, length) {
export var fromArrayBuffer = function (input, offset, length) {
if (offset === void 0) { offset = 0; }
if (length === void 0) { length = input.byteLength - offset; }
if (!isArrayBuffer(input)) {
throw new Error("argument passed to fromArrayBuffer was not an ArrayBuffer");
throw new TypeError("The \"input\" argument must be ArrayBuffer. Received type " + typeof input + " (" + input + ")");
}
if (typeof Buffer.from === "function" && Buffer.from !== Uint8Array.from) {
return Buffer.from(input, offset, length);
}
// Any version of node that supports the optional offset and length
// parameters, which were added in Node 6.0.0, will support Buffer.from and
// have already returned. Throw if offset is not 0 or if length differs from
// the underlying buffer's length.
if (offset !== 0 || length !== input.byteLength) {
throw new Error("Unable to convert TypedArray to Buffer in Node " + process.version);
}
return new Buffer(input);
}
export function fromString(input, encoding) {
return Buffer.from(input, offset, length);
};
export var fromString = function (input, encoding) {
if (typeof input !== "string") {
throw new Error("argument passed to fromString was not a string");
throw new TypeError("The \"input\" argument must be of type string. Received type " + typeof input + " (" + input + ")");
}
if (typeof Buffer.from === "function" && Buffer.from !== Uint8Array.from) {
return Buffer.from(input, encoding);
}
return new Buffer(input, encoding);
}
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxF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VyLmZyb20oaW5wdXQsIGVuY29kaW5nIGFzIGFueSk7XG4gIH1cblxuICByZXR1cm4gbmV3IEJ1ZmZlcihpbnB1dCwgZW5jb2RpbmcgYXMgYW55KTtcbn1cbiJdfQ==
return encoding ? Buffer.from(input, encoding) : Buffer.from(input);
};
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxFQUFFLGFBQWEsRUFBRSxNQUFNLDBCQUEwQixDQUFDO0FBQ3pELE9BQU8sRUFBRSxNQUFNLEVBQUUsTUFBTSxRQUFRLENBQUM7QUFFaEMsTUFBTSxDQUFDLElBQU0sZUFBZSxHQUFHLFVBQUMsS0FBa0IsRUFBRSxNQUFVLEVBQUUsTUFBMEM7SUFBdEQsdUJBQUEsRUFBQSxVQUFVO0lBQUUsdUJBQUEsRUFBQSxTQUFpQixLQUFLLENBQUMsVUFBVSxHQUFHLE1BQU07SUFDeEcsSUFBSSxDQUFDLGFBQWEsQ0FBQyxLQUFLLENBQUMsRUFBRTtRQUN6QixNQUFNLElBQUksU0FBUyxDQUFDLCtEQUEyRCxPQUFPLEtBQUssVUFBSyxLQUFLLE1BQUcsQ0FBQyxDQUFDO0tBQzNHO0lBRUQsT0FBTyxNQUFNLENBQUMsSUFBSSxDQUFDLEtBQUssRUFBRSxNQUFNLEVBQUUsTUFBTSxDQUFDLENBQUM7QUFDNUMsQ0FBQyxDQUFDO0FBSUYsTUFBTSxDQUFDLElBQU0sVUFBVSxHQUFHLFVBQUMsS0FBYSxFQUFFLFFBQXlCO0lBQ2pFLElBQUksT0FBTyxLQUFLLEtBQUssUUFBUSxFQUFFO1FBQzdCLE1BQU0sSUFBSSxTQUFTLENBQUMsa0VBQThELE9BQU8sS0FBSyxVQUFLLEtBQUssTUFBRy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VmZmVyID0+IHtcbiAgaWYgKHR5cGVvZiBpbnB1dCAhPT0gXCJzdHJpbmdcIikge1xuICAgIHRocm93IG5ldyBUeXBlRXJyb3IoYFRoZSBcImlucHV0XCIgYXJndW1lbnQgbXVzdCBiZSBvZiB0eXBlIHN0cmluZy4gUmVjZWl2ZWQgdHlwZSAke3R5cGVvZiBpbnB1dH0gKCR7aW5wdXR9KWApO1xuICB9XG5cbiAgcmV0dXJuIGVuY29kaW5nID8gQnVmZmVyLmZyb20oaW5wdXQsIGVuY29kaW5nKSA6IEJ1ZmZlci5mcm9tKGlucHV0KTtcbn07XG4iXX0=
{
"name": "@aws-sdk/util-buffer-from",
"version": "1.0.0-gamma.7",
"version": "1.0.0-rc.1",
"scripts": {

@@ -18,3 +18,3 @@ "prepublishOnly": "yarn build:cjs && yarn build:es",

"dependencies": {
"@aws-sdk/is-array-buffer": "1.0.0-gamma.7",
"@aws-sdk/is-array-buffer": "1.0.0-rc.1",
"tslib": "^1.8.0"

@@ -30,3 +30,6 @@ },

"module": "./dist/es/index.js",
"types": "./dist/cjs/index.d.ts"
"types": "./dist/cjs/index.d.ts",
"engines": {
"node": ">= 10.0.0"
}
}
import { isArrayBuffer } from "@aws-sdk/is-array-buffer";
import { Buffer } from "buffer";
export function fromArrayBuffer(input: ArrayBuffer, offset = 0, length: number = input.byteLength - offset): Buffer {
export const fromArrayBuffer = (input: ArrayBuffer, offset = 0, length: number = input.byteLength - offset): Buffer => {
if (!isArrayBuffer(input)) {
throw new Error("argument passed to fromArrayBuffer was not an ArrayBuffer");
throw new TypeError(`The "input" argument must be ArrayBuffer. Received type ${typeof input} (${input})`);
}
if (typeof Buffer.from === "function" && Buffer.from !== Uint8Array.from) {
return Buffer.from(input, offset, length);
}
return Buffer.from(input, offset, length);
};
// Any version of node that supports the optional offset and length
// parameters, which were added in Node 6.0.0, will support Buffer.from and
// have already returned. Throw if offset is not 0 or if length differs from
// the underlying buffer's length.
if (offset !== 0 || length !== input.byteLength) {
throw new Error(`Unable to convert TypedArray to Buffer in Node ${process.version}`);
}
return new Buffer(input);
}
export type StringEncoding = "ascii" | "utf8" | "utf16le" | "ucs2" | "base64" | "latin1" | "binary" | "hex";
export function fromString(input: string, encoding?: StringEncoding): Buffer {
export const fromString = (input: string, encoding?: StringEncoding): Buffer => {
if (typeof input !== "string") {
throw new Error("argument passed to fromString was not a string");
throw new TypeError(`The "input" argument must be of type string. Received type ${typeof input} (${input})`);
}
if (typeof Buffer.from === "function" && Buffer.from !== Uint8Array.from) {
return Buffer.from(input, encoding as any);
}
return new Buffer(input, encoding as any);
}
return encoding ? Buffer.from(input, encoding) : Buffer.from(input);
};
{
"compilerOptions": {
"declaration": true,
"sourceMap": false,
"strict": true,
"lib": ["es5", "es2015.collection"],
"rootDir": "./src",
"outDir": "./dist/cjs",
"importHelpers": true,
"noEmitHelpers": true,
"inlineSourceMap": true,
"inlineSources": true,
"baseUrl": "."

@@ -14,0 +6,0 @@ },

{
"compilerOptions": {
"declaration": true,
"sourceMap": false,
"strict": true,
"lib": ["es5", "es2015.collection"],
"rootDir": "./src",
"outDir": "./dist/es",
"importHelpers": true,
"noEmitHelpers": true,
"inlineSourceMap": true,
"inlineSources": true,
"baseUrl": "."

@@ -14,0 +7,0 @@ },

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc