How to use the @aws-sdk/util-buffer-from.fromArrayBuffer function in @aws-sdk/util-buffer-from

To help you get started, we’ve selected a few @aws-sdk/util-buffer-from examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github aws / aws-sdk-js-v3 / packages / hash-node / src / index.spec.ts View on Github external
it("should accept string data", async () => {
    const hash = new Hash("md5");
    hash.update("");
    const { buffer } = await hash.digest();
    expect(fromArrayBuffer(buffer).toString("hex")).toBe(
      "d41d8cd98f00b204e9800998ecf8427e"
    );
  });
github aws / aws-sdk-js-v3 / packages / hash-node / src / index.ts View on Github external
function castSourceData(toCast: SourceData, encoding?: string): Buffer {
  if (Buffer.isBuffer(toCast)) {
    return toCast;
  }

  if (typeof toCast === "string") {
    return fromString(toCast, encoding);
  }

  if (ArrayBuffer.isView(toCast)) {
    return fromArrayBuffer(toCast.buffer, toCast.byteOffset, toCast.byteLength);
  }

  return fromArrayBuffer(toCast);
}
github aws / aws-sdk-js-v3 / packages / hash-node / src / index.ts View on Github external
function castSourceData(toCast: SourceData, encoding?: string): Buffer {
  if (Buffer.isBuffer(toCast)) {
    return toCast;
  }

  if (typeof toCast === "string") {
    return fromString(toCast, encoding);
  }

  if (ArrayBuffer.isView(toCast)) {
    return fromArrayBuffer(toCast.buffer, toCast.byteOffset, toCast.byteLength);
  }

  return fromArrayBuffer(toCast);
}
github aws / aws-sdk-js-v3 / packages / util-utf8-node / src / index.ts View on Github external
export function toUtf8(input: Uint8Array): string {
  return fromArrayBuffer(
    input.buffer,
    input.byteOffset,
    input.byteLength
  ).toString("utf8");
}
github aws / aws-sdk-js-v3 / packages / util-base64-node / src / index.ts View on Github external
export function toBase64(input: Uint8Array): string {
  return fromArrayBuffer(
    input.buffer,
    input.byteOffset,
    input.byteLength
  ).toString("base64");
}

@aws-sdk/util-buffer-from

[![NPM version](https://img.shields.io/npm/v/@aws-sdk/util-buffer-from/latest.svg)](https://www.npmjs.com/package/@aws-sdk/util-buffer-from) [![NPM downloads](https://img.shields.io/npm/dm/@aws-sdk/util-buffer-from.svg)](https://www.npmjs.com/package/@aws

Apache-2.0
Latest version published 1 year ago

Package Health Score

72 / 100
Full package analysis

Similar packages