PHP WebShell

Текущая директория: /usr/lib/node_modules/bitgo/node_modules/viem/utils/data

Просмотр файла: size.ts

import type { ErrorType } from '../../errors/utils.js'
import type { ByteArray, Hex } from '../../types/misc.js'

import { type IsHexErrorType, isHex } from './isHex.js'

export type SizeErrorType = IsHexErrorType | ErrorType

/**
 * @description Retrieves the size of the value (in bytes).
 *
 * @param value The value (hex or byte array) to retrieve the size of.
 * @returns The size of the value (in bytes).
 */
export function size(value: Hex | ByteArray) {
  if (isHex(value, { strict: false })) return Math.ceil((value.length - 2) / 2)
  return value.length
}

Выполнить команду


Для локальной разработки. Не используйте в интернете!