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
- type
- isArray
- isUndefined
- isNull
- isBoolean
- isArrayBuffer
- isFormData
- isArrayBufferView
- isString
- isNumber
- isObject
- isPlainObject
- isDate
- isArguments
- isFile
- isBlob
- isFunction
- isSymbol
- isRegExp
- isInt8Array
- isUint8Array
- isUint8ClampedArray
- isInt16Array
- isUint16Array
- isInt32Array
- isUint32Array
- isFloat32Array
- isFloat64Array
- isError
- isPromise
- isSet
- isWeakSet
- isMap
- isWeakMap
- isStream
- isURLSearchParams