1 | ;
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | exports.isBuffer = void 0;
|
4 | const x_global_1 = require("@polkadot/x-global");
|
5 | const has_js_1 = require("../has.js");
|
6 | const function_js_1 = require("./function.js");
|
7 | /**
|
8 | * @name isBuffer
|
9 | * @summary Tests for a `Buffer` object instance.
|
10 | * @description
|
11 | * Checks to see if the input object is an instance of `Buffer`.
|
12 | * @example
|
13 | * <BR>
|
14 | *
|
15 | * ```javascript
|
16 | * import { isBuffer } from '@polkadot/util';
|
17 | *
|
18 | * console.log('isBuffer', isBuffer(Buffer.from([]))); // => true
|
19 | * ```
|
20 | */
|
21 | function isBuffer(value) {
|
22 | // we do check a function first, since it is slightly faster than isBuffer itself
|
23 | return has_js_1.hasBuffer && !!value && (0, function_js_1.isFunction)(value.readDoubleLE) && x_global_1.xglobal.Buffer.isBuffer(value);
|
24 | }
|
25 | exports.isBuffer = isBuffer;
|