🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Sign inDemoInstall
Socket

@xylabs/arraybuffer

Package Overview
Dependencies
Maintainers
5
Versions
222
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@xylabs/arraybuffer - npm Package Compare versions

Comparing version

to
4.9.0

13

package.json
{
"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