mirror of
https://github.com/pezkuwichain/pezkuwi-common.git
synced 2026-04-22 06:47:57 +00:00
a5542fdd87
- Fixed internal @polkadot references to @pezkuwi - Updated hw-ledger and hw-ledger-transports packages - Updated keyring and networks packages - Version 14.0.7
21 lines
624 B
TypeScript
21 lines
624 B
TypeScript
// Copyright 2017-2025 @pezkuwi/util authors & contributors
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
/**
|
|
* @name bufferToU8a
|
|
* @summary Creates a Uint8Array value from a Buffer object.
|
|
* @description
|
|
* `null` inputs returns an empty result, `Buffer` values return the actual value as a `Uint8Array`. Anything that is not a `Buffer` object throws an error.
|
|
* @example
|
|
* <BR>
|
|
*
|
|
* ```javascript
|
|
* import { bufferToU8a } from '@pezkuwi/util';
|
|
*
|
|
* bufferToU8a(Buffer.from([1, 2, 3]));
|
|
* ```
|
|
*/
|
|
export function bufferToU8a (buffer?: Uint8Array | number[] | null): Uint8Array {
|
|
return new Uint8Array(buffer || []);
|
|
}
|