@silen/is-buffer
TypeScript icon, indicating that this package has built-in type declarations

1.0.3 • Public • Published

is-buffer

Determine if a value is Buffer

install

npm i @silen/is-buffer

api

  • declare function isBuffer(val: any): boolean;

usage

const { isBuffer } = require('@silen/is-buffer');
// or
import { isBuffer } from '@silen/is-buffer';

console.log(isBuffer(new Buffer(4)));
console.log(isBuffer(Buffer.alloc(4)));
console.log(isBuffer(undefined));
console.log(isBuffer(null));
console.log(isBuffer(''));
console.log(isBuffer(true));
console.log(isBuffer(0));
console.log(isBuffer(1));
console.log(isBuffer(1.0));
console.log(isBuffer('string'));
console.log(isBuffer({}));
console.log(isBuffer(function foo() {}));
console.log(isBuffer(Symbol()));
console.log(isBuffer(new Set));
console.log(isBuffer(new Map));
console.log(isBuffer(new WeakMap));
console.log(isBuffer(new WeakSet));

// or
console.log(window.Type.isBuffer(new WeakSet));

This is a demo for testing the usage of isBuffer from @silen/is-buffer module. You can try the others and do likewise.

others

Package Sidebar

Install

npm i @silen/is-buffer

Weekly Downloads

1

Version

1.0.3

License

MIT

Unpacked Size

8.41 kB

Total Files

9

Last publish

Collaborators

  • silentsun