@xylabs/arraybuffer
Advanced tools
Comparing version
{ | ||
"name": "@xylabs/arraybuffer", | ||
"version": "4.8.9", | ||
"version": "4.9.0", | ||
"description": "Base functionality used throughout XY Labs TypeScript/JavaScript libraries", | ||
@@ -38,10 +38,11 @@ "keywords": [ | ||
"dependencies": { | ||
"@xylabs/assert": "^4.8.9", | ||
"@xylabs/hex": "^4.8.9" | ||
"@xylabs/assert": "^4.9.0", | ||
"@xylabs/hex": "^4.9.0", | ||
"@xylabs/typeof": "^4.9.0" | ||
}, | ||
"devDependencies": { | ||
"@xylabs/ts-scripts-yarn3": "^6.4.5", | ||
"@xylabs/tsconfig": "^6.4.5", | ||
"@xylabs/ts-scripts-yarn3": "^6.5.5", | ||
"@xylabs/tsconfig": "^6.5.5", | ||
"typescript": "^5.8.3", | ||
"vitest": "^3.1.2" | ||
"vitest": "^3.1.3" | ||
}, | ||
@@ -48,0 +49,0 @@ "engines": { |
import { assertEx } from '@xylabs/assert' | ||
import type { Hex } from '@xylabs/hex' | ||
import { toHex } from '@xylabs/hex' | ||
import { isUndefined } from '@xylabs/typeof' | ||
@@ -35,4 +36,4 @@ function hexToArrayBuffer(value: Hex): Uint8Array { | ||
export function toArrayBuffer(value: ArrayBufferLike | bigint | string | undefined, padLength?: number, base?: number): ArrayBufferLike | undefined | ||
export function toArrayBuffer(value?: ArrayBufferLike | bigint | string, padLength?: number, base?: number): ArrayBufferLike | undefined { | ||
if (value === undefined) return undefined | ||
export function toArrayBuffer(value?: ArrayBufferLike | bigint | string, padLength = 0, base?: number): ArrayBufferLike | undefined { | ||
if (isUndefined(value)) return undefined | ||
@@ -52,3 +53,3 @@ if (typeof value === 'bigint' && value < 0) { | ||
if (padLength && result.length < padLength) { | ||
if (result.length < padLength) { | ||
result = new Uint8Array([...new Uint8Array(padLength - result.length), ...result]) | ||
@@ -55,0 +56,0 @@ assertEx(result?.length <= padLength, () => 'Resulting length is greater than padLength') |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
25399
0.58%173
1.17%222
5.21%21
110%46
31.43%13
160%152
7.8%3
50%+ Added
+ Added
+ Added
+ Added
- Removed
- Removed
- Removed
Updated
Updated