23 lines
566 B
TypeScript
23 lines
566 B
TypeScript
// Copyright 2017-2021 @polkadot/util authors & contributors
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
import { hasBuffer } from '../has';
|
|
|
|
/**
|
|
* @name isBuffer
|
|
* @summary Tests for a `Buffer` object instance.
|
|
* @description
|
|
* Checks to see if the input object is an instance of `Buffer`.
|
|
* @example
|
|
* <BR>
|
|
*
|
|
* ```javascript
|
|
* import { isBuffer } from '@polkadot/util';
|
|
*
|
|
* console.log('isBuffer', isBuffer(Buffer.from([]))); // => true
|
|
* ```
|
|
*/
|
|
export function isBuffer (value: unknown): value is Buffer {
|
|
return hasBuffer && Buffer.isBuffer(value);
|
|
}
|