JSPM

is-buffer-like

1.0.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 1
  • Score
    100M100P100Q45932F
  • License MIT

Checks if the given source is buffer-like

Package Exports

  • is-buffer-like
  • is-buffer-like/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (is-buffer-like) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

is-buffer-like

Checks if the given src is buffer-like object.

Example

const isBufferLike = require("is-buffer-like");

// Buffer like src
// these can be constructed into nodejs Buffer object using Buffer.from(x)
const ns = [
    Uint8ClampedArray,
    Uint8Array,
    Uint16Array,
    Uint32Array,
    Float32Array,
    Float64Array,
    Int16Array,
    Int32Array,
    Int8Array,
    ArrayBuffer,
    Array,
    SharedArrayBuffer,
    BigInt64Array,
    BigUint64Array,
    Array
];

console.log(ns.map(m => isBufferLike(new m)));
/*
[
  true, true, true, true,
  true, true, true, true,
  true, true, true, true,
  true, true, true
]
*/
console.log(isBufferLike(Buffer.from("test"))); // true
console.log(isBufferLike(null)); // false
console.log(isBufferLike(true)); // false
console.log(isBufferLike(0)); // false
console.log(isBufferLike("test")); // false
console.log(isBufferLike({})); // false
console.log(isBufferLike(undefined)); // false
console.log(isBufferLike(null)); // false
console.log(isBufferLike(function(){})); // false