mirror of
https://github.com/pezkuwichain/pezkuwi-common.git
synced 2026-04-28 07:27:56 +00:00
chore: update to version 14.0.11 and align website URLs
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
import { compactFromU8a } from './fromU8a.js';
|
||||
/**
|
||||
* @name compactStripLength
|
||||
* @description Removes the length prefix, returning both the total length (including the value + compact encoding) and the decoded value with the correct length
|
||||
* @example
|
||||
* <BR>
|
||||
*
|
||||
* ```javascript
|
||||
* import { compactStripLength } from '@pezkuwi/util';
|
||||
*
|
||||
* console.log(compactStripLength(new Uint8Array([2 << 2, 0xde, 0xad]))); // [2, Uint8Array[0xde, 0xad]]
|
||||
* ```
|
||||
*/
|
||||
export function compactStripLength(input) {
|
||||
const [offset, length] = compactFromU8a(input);
|
||||
const total = offset + length.toNumber();
|
||||
return [
|
||||
total,
|
||||
input.subarray(offset, total)
|
||||
];
|
||||
}
|
||||
Reference in New Issue
Block a user