Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ox

Package Overview
Dependencies
Maintainers
0
Versions
237
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ox - npm Package Compare versions

Comparing version 0.0.0-20240814T041200 to 0.0.0-20240814T043527

2

_cjs/Bytes.d.ts

@@ -10,5 +10,5 @@ export { type ConcatErrorType, type ConcatReturnType, concat, } from './internal/data/concat.js';

export { type FromBytesErrorType, type FromBytesOptions, type FromBytesReturnType, type BytesToBigIntErrorType, type BytesToBigIntOptions, type BytesToBooleanErrorType, type BytesToBooleanOptions, type BytesToNumberErrorType, type BytesToNumberOptions, type BytesToStringErrorType, type BytesToStringOptions, fromBytes, fromBytes as to, bytesToBigInt, bytesToBigInt as toBigInt, bytesToBoolean, bytesToBoolean as toBoolean, bytesToNumber, bytesToNumber as toNumber, bytesToString, bytesToString as toString, } from './internal/bytes/fromBytes.js';
export { type BoolToBytesErrorType, type BoolToBytesOptions, type HexToBytesErrorType, type HexToBytesOptions, type NumberToBytesErrorType, type StringToBytesErrorType, type StringToBytesOptions, type ToBytesErrorType, type ToBytesOptions, boolToBytes, boolToBytes as fromBool, hexToBytes, hexToBytes as fromHex, numberToBytes, numberToBytes as fromNumber, stringToBytes, stringToBytes as fromString, toBytes, toBytes as from, } from './internal/bytes/toBytes.js';
export { type BooleanToBytesErrorType, type BooleanToBytesOptions, type HexToBytesErrorType, type HexToBytesOptions, type NumberToBytesErrorType, type StringToBytesErrorType, type StringToBytesOptions, type ToBytesErrorType, type ToBytesOptions, booleanToBytes, booleanToBytes as fromBoolean, hexToBytes, hexToBytes as fromHex, numberToBytes, numberToBytes as fromNumber, stringToBytes, stringToBytes as fromString, toBytes, toBytes as from, } from './internal/bytes/toBytes.js';
export { type BytesToHexErrorType, type BytesToHexOptions, bytesToHex, bytesToHex as toHex, } from './internal/hex/toHex.js';
export type { Bytes } from './internal/types/data.js';
//# sourceMappingURL=Bytes.d.ts.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.toHex = exports.bytesToHex = exports.from = exports.toBytes = exports.fromString = exports.stringToBytes = exports.fromNumber = exports.numberToBytes = exports.fromHex = exports.hexToBytes = exports.fromBool = exports.boolToBytes = exports.toString = exports.bytesToString = exports.toNumber = exports.bytesToNumber = exports.toBoolean = exports.bytesToBoolean = exports.toBigInt = exports.bytesToBigInt = exports.to = exports.fromBytes = exports.random = exports.randomBytes = exports.trimRight = exports.trimLeft = exports.size = exports.slice = exports.padRight = exports.padLeft = exports.isEqual = exports.isBytes = exports.concat = void 0;
exports.toHex = exports.bytesToHex = exports.from = exports.toBytes = exports.fromString = exports.stringToBytes = exports.fromNumber = exports.numberToBytes = exports.fromHex = exports.hexToBytes = exports.fromBoolean = exports.booleanToBytes = exports.toString = exports.bytesToString = exports.toNumber = exports.bytesToNumber = exports.toBoolean = exports.bytesToBoolean = exports.toBigInt = exports.bytesToBigInt = exports.to = exports.fromBytes = exports.random = exports.randomBytes = exports.trimRight = exports.trimLeft = exports.size = exports.slice = exports.padRight = exports.padLeft = exports.isEqual = exports.isBytes = exports.concat = void 0;
var concat_js_1 = require("./internal/data/concat.js");

@@ -35,4 +35,4 @@ Object.defineProperty(exports, "concat", { enumerable: true, get: function () { return concat_js_1.concat; } });

var toBytes_js_1 = require("./internal/bytes/toBytes.js");
Object.defineProperty(exports, "boolToBytes", { enumerable: true, get: function () { return toBytes_js_1.boolToBytes; } });
Object.defineProperty(exports, "fromBool", { enumerable: true, get: function () { return toBytes_js_1.boolToBytes; } });
Object.defineProperty(exports, "booleanToBytes", { enumerable: true, get: function () { return toBytes_js_1.booleanToBytes; } });
Object.defineProperty(exports, "fromBoolean", { enumerable: true, get: function () { return toBytes_js_1.booleanToBytes; } });
Object.defineProperty(exports, "hexToBytes", { enumerable: true, get: function () { return toBytes_js_1.hexToBytes; } });

@@ -39,0 +39,0 @@ Object.defineProperty(exports, "fromHex", { enumerable: true, get: function () { return toBytes_js_1.hexToBytes; } });

@@ -10,4 +10,4 @@ export { type ConcatErrorType, type ConcatReturnType, concat, } from './internal/data/concat.js';

export { type HexToBytesErrorType, type HexToBytesOptions, hexToBytes, hexToBytes as toBytes, } from './internal/bytes/toBytes.js';
export { type BoolToHexErrorType, type BoolToHexOptions, type BytesToHexErrorType, type BytesToHexOptions, type NumberToHexErrorType, type NumberToHexOptions, type StringToHexErrorType, type StringToHexOptions, type ToHexErrorType, type ToHexParameters, boolToHex, boolToHex as fromBool, bytesToHex, bytesToHex as fromBytes, numberToHex, numberToHex as fromNumber, stringToHex, stringToHex as fromString, toHex, toHex as from, } from './internal/hex/toHex.js';
export { type BooleanToHexErrorType, type BooleanToHexOptions, type BytesToHexErrorType, type BytesToHexOptions, type NumberToHexErrorType, type NumberToHexOptions, type StringToHexErrorType, type StringToHexOptions, type ToHexErrorType, type ToHexParameters, booleanToHex, booleanToHex as fromBoolean, bytesToHex, bytesToHex as fromBytes, numberToHex, numberToHex as fromNumber, stringToHex, stringToHex as fromString, toHex, toHex as from, } from './internal/hex/toHex.js';
export type { Hex } from './internal/types/data.js';
//# sourceMappingURL=Hex.d.ts.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.from = exports.toHex = exports.fromString = exports.stringToHex = exports.fromNumber = exports.numberToHex = exports.fromBytes = exports.bytesToHex = exports.fromBool = exports.boolToHex = exports.toBytes = exports.hexToBytes = exports.toString = exports.hexToString = exports.toNumber = exports.hexToNumber = exports.toBoolean = exports.hexToBoolean = exports.toBigInt = exports.hexToBigInt = exports.to = exports.fromHex = exports.trimRight = exports.trimLeft = exports.size = exports.slice = exports.padRight = exports.padLeft = exports.isEqual = exports.isHex = exports.concat = void 0;
exports.from = exports.toHex = exports.fromString = exports.stringToHex = exports.fromNumber = exports.numberToHex = exports.fromBytes = exports.bytesToHex = exports.fromBoolean = exports.booleanToHex = exports.toBytes = exports.hexToBytes = exports.toString = exports.hexToString = exports.toNumber = exports.hexToNumber = exports.toBoolean = exports.hexToBoolean = exports.toBigInt = exports.hexToBigInt = exports.to = exports.fromHex = exports.trimRight = exports.trimLeft = exports.size = exports.slice = exports.padRight = exports.padLeft = exports.isEqual = exports.isHex = exports.concat = void 0;
var concat_js_1 = require("./internal/data/concat.js");

@@ -35,4 +35,4 @@ Object.defineProperty(exports, "concat", { enumerable: true, get: function () { return concat_js_1.concat; } });

var toHex_js_1 = require("./internal/hex/toHex.js");
Object.defineProperty(exports, "boolToHex", { enumerable: true, get: function () { return toHex_js_1.boolToHex; } });
Object.defineProperty(exports, "fromBool", { enumerable: true, get: function () { return toHex_js_1.boolToHex; } });
Object.defineProperty(exports, "booleanToHex", { enumerable: true, get: function () { return toHex_js_1.booleanToHex; } });
Object.defineProperty(exports, "fromBoolean", { enumerable: true, get: function () { return toHex_js_1.booleanToHex; } });
Object.defineProperty(exports, "bytesToHex", { enumerable: true, get: function () { return toHex_js_1.bytesToHex; } });

@@ -39,0 +39,0 @@ Object.defineProperty(exports, "fromBytes", { enumerable: true, get: function () { return toHex_js_1.bytesToHex; } });

@@ -12,9 +12,9 @@ import { type AssertSizeErrorType } from '../data/assertSize.js';

};
export type ToBytesErrorType = InvalidTypeErrorType | IsBytesErrorType | NumberToBytesErrorType | BoolToBytesErrorType | HexToBytesErrorType | StringToBytesErrorType | IsHexErrorType | ErrorType;
export type ToBytesErrorType = InvalidTypeErrorType | IsBytesErrorType | NumberToBytesErrorType | BooleanToBytesErrorType | HexToBytesErrorType | StringToBytesErrorType | IsHexErrorType | ErrorType;
export declare function toBytes(value: string | bigint | number | boolean | Hex | Bytes, options?: ToBytesOptions): Bytes;
export type BoolToBytesOptions = {
export type BooleanToBytesOptions = {
size?: number | undefined;
};
export type BoolToBytesErrorType = AssertSizeErrorType | PadLeftErrorType | ErrorType;
export declare function boolToBytes(value: boolean, options?: BoolToBytesOptions): Uint8Array;
export type BooleanToBytesErrorType = AssertSizeErrorType | PadLeftErrorType | ErrorType;
export declare function booleanToBytes(value: boolean, options?: BooleanToBytesOptions): Uint8Array;
export type HexToBytesOptions = {

@@ -21,0 +21,0 @@ size?: number | undefined;

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.toBytes = toBytes;
exports.boolToBytes = boolToBytes;
exports.booleanToBytes = booleanToBytes;
exports.hexToBytes = hexToBytes;

@@ -21,3 +21,3 @@ exports.numberToBytes = numberToBytes;

if (typeof value === 'boolean')
return boolToBytes(value, options);
return booleanToBytes(value, options);
if (typeof value === 'string')

@@ -29,3 +29,3 @@ return stringToBytes(value, options);

}
function boolToBytes(value, options = {}) {
function booleanToBytes(value, options = {}) {
const { size } = options;

@@ -32,0 +32,0 @@ const bytes = new Uint8Array(1);

@@ -10,9 +10,9 @@ import { type AssertSizeErrorType } from '../data/assertSize.js';

};
export type ToHexErrorType = BoolToHexErrorType | BytesToHexErrorType | IsHexErrorType | InvalidTypeErrorType | NumberToHexErrorType | StringToHexErrorType | ErrorType;
export type ToHexErrorType = BooleanToHexErrorType | BytesToHexErrorType | IsHexErrorType | InvalidTypeErrorType | NumberToHexErrorType | StringToHexErrorType | ErrorType;
export declare function toHex(value: string | number | bigint | boolean | Bytes, options?: ToHexParameters): Hex;
export type BoolToHexOptions = {
export type BooleanToHexOptions = {
size?: number | undefined;
};
export type BoolToHexErrorType = AssertSizeErrorType | PadLeftErrorType | ErrorType;
export declare function boolToHex(value: boolean, options?: BoolToHexOptions): Hex;
export type BooleanToHexErrorType = AssertSizeErrorType | PadLeftErrorType | ErrorType;
export declare function booleanToHex(value: boolean, options?: BooleanToHexOptions): Hex;
export type BytesToHexOptions = {

@@ -19,0 +19,0 @@ size?: number | undefined;

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.toHex = toHex;
exports.boolToHex = boolToHex;
exports.booleanToHex = booleanToHex;
exports.bytesToHex = bytesToHex;

@@ -24,6 +24,6 @@ exports.numberToHex = numberToHex;

if (typeof value === 'boolean')
return boolToHex(value, options);
return booleanToHex(value, options);
throw new data_js_1.InvalidTypeError(typeof value);
}
function boolToHex(value, options = {}) {
function booleanToHex(value, options = {}) {
const hex = `0x${Number(value)}`;

@@ -30,0 +30,0 @@ if (typeof options.size === 'number') {

@@ -1,2 +0,2 @@

export declare const version = "0.0.0-20240814T041200";
export declare const version = "0.0.0-20240814T043527";
//# sourceMappingURL=version.d.ts.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.version = void 0;
exports.version = '0.0.0-20240814T041200';
exports.version = '0.0.0-20240814T043527';
//# sourceMappingURL=version.js.map

@@ -10,5 +10,5 @@ export { type ConcatErrorType, type ConcatReturnType, concat, } from './internal/data/concat.js';

export { type FromBytesErrorType, type FromBytesOptions, type FromBytesReturnType, type BytesToBigIntErrorType, type BytesToBigIntOptions, type BytesToBooleanErrorType, type BytesToBooleanOptions, type BytesToNumberErrorType, type BytesToNumberOptions, type BytesToStringErrorType, type BytesToStringOptions, fromBytes, fromBytes as to, bytesToBigInt, bytesToBigInt as toBigInt, bytesToBoolean, bytesToBoolean as toBoolean, bytesToNumber, bytesToNumber as toNumber, bytesToString, bytesToString as toString, } from './internal/bytes/fromBytes.js';
export { type BoolToBytesErrorType, type BoolToBytesOptions, type HexToBytesErrorType, type HexToBytesOptions, type NumberToBytesErrorType, type StringToBytesErrorType, type StringToBytesOptions, type ToBytesErrorType, type ToBytesOptions, boolToBytes, boolToBytes as fromBool, hexToBytes, hexToBytes as fromHex, numberToBytes, numberToBytes as fromNumber, stringToBytes, stringToBytes as fromString, toBytes, toBytes as from, } from './internal/bytes/toBytes.js';
export { type BooleanToBytesErrorType, type BooleanToBytesOptions, type HexToBytesErrorType, type HexToBytesOptions, type NumberToBytesErrorType, type StringToBytesErrorType, type StringToBytesOptions, type ToBytesErrorType, type ToBytesOptions, booleanToBytes, booleanToBytes as fromBoolean, hexToBytes, hexToBytes as fromHex, numberToBytes, numberToBytes as fromNumber, stringToBytes, stringToBytes as fromString, toBytes, toBytes as from, } from './internal/bytes/toBytes.js';
export { type BytesToHexErrorType, type BytesToHexOptions, bytesToHex, bytesToHex as toHex, } from './internal/hex/toHex.js';
export type { Bytes } from './internal/types/data.js';
//# sourceMappingURL=Bytes.d.ts.map

@@ -10,4 +10,4 @@ export { concat, } from './internal/data/concat.js';

export { fromBytes, fromBytes as to, bytesToBigInt, bytesToBigInt as toBigInt, bytesToBoolean, bytesToBoolean as toBoolean, bytesToNumber, bytesToNumber as toNumber, bytesToString, bytesToString as toString, } from './internal/bytes/fromBytes.js';
export { boolToBytes, boolToBytes as fromBool, hexToBytes, hexToBytes as fromHex, numberToBytes, numberToBytes as fromNumber, stringToBytes, stringToBytes as fromString, toBytes, toBytes as from, } from './internal/bytes/toBytes.js';
export { booleanToBytes, booleanToBytes as fromBoolean, hexToBytes, hexToBytes as fromHex, numberToBytes, numberToBytes as fromNumber, stringToBytes, stringToBytes as fromString, toBytes, toBytes as from, } from './internal/bytes/toBytes.js';
export { bytesToHex, bytesToHex as toHex, } from './internal/hex/toHex.js';
//# sourceMappingURL=Bytes.js.map

@@ -10,4 +10,4 @@ export { type ConcatErrorType, type ConcatReturnType, concat, } from './internal/data/concat.js';

export { type HexToBytesErrorType, type HexToBytesOptions, hexToBytes, hexToBytes as toBytes, } from './internal/bytes/toBytes.js';
export { type BoolToHexErrorType, type BoolToHexOptions, type BytesToHexErrorType, type BytesToHexOptions, type NumberToHexErrorType, type NumberToHexOptions, type StringToHexErrorType, type StringToHexOptions, type ToHexErrorType, type ToHexParameters, boolToHex, boolToHex as fromBool, bytesToHex, bytesToHex as fromBytes, numberToHex, numberToHex as fromNumber, stringToHex, stringToHex as fromString, toHex, toHex as from, } from './internal/hex/toHex.js';
export { type BooleanToHexErrorType, type BooleanToHexOptions, type BytesToHexErrorType, type BytesToHexOptions, type NumberToHexErrorType, type NumberToHexOptions, type StringToHexErrorType, type StringToHexOptions, type ToHexErrorType, type ToHexParameters, booleanToHex, booleanToHex as fromBoolean, bytesToHex, bytesToHex as fromBytes, numberToHex, numberToHex as fromNumber, stringToHex, stringToHex as fromString, toHex, toHex as from, } from './internal/hex/toHex.js';
export type { Hex } from './internal/types/data.js';
//# sourceMappingURL=Hex.d.ts.map

@@ -10,3 +10,3 @@ export { concat, } from './internal/data/concat.js';

export { hexToBytes, hexToBytes as toBytes, } from './internal/bytes/toBytes.js';
export { boolToHex, boolToHex as fromBool, bytesToHex, bytesToHex as fromBytes, numberToHex, numberToHex as fromNumber, stringToHex, stringToHex as fromString, toHex, toHex as from, } from './internal/hex/toHex.js';
export { booleanToHex, booleanToHex as fromBoolean, bytesToHex, bytesToHex as fromBytes, numberToHex, numberToHex as fromNumber, stringToHex, stringToHex as fromString, toHex, toHex as from, } from './internal/hex/toHex.js';
//# sourceMappingURL=Hex.js.map

@@ -13,3 +13,3 @@ import { type AssertSizeErrorType } from '../data/assertSize.js';

};
export type ToBytesErrorType = InvalidTypeErrorType | IsBytesErrorType | NumberToBytesErrorType | BoolToBytesErrorType | HexToBytesErrorType | StringToBytesErrorType | IsHexErrorType | ErrorType;
export type ToBytesErrorType = InvalidTypeErrorType | IsBytesErrorType | NumberToBytesErrorType | BooleanToBytesErrorType | HexToBytesErrorType | StringToBytesErrorType | IsHexErrorType | ErrorType;
/**

@@ -34,7 +34,7 @@ * Encodes an arbitrary value to {@link Bytes}.

export declare function toBytes(value: string | bigint | number | boolean | Hex | Bytes, options?: ToBytesOptions): Bytes;
export type BoolToBytesOptions = {
export type BooleanToBytesOptions = {
/** Size of the output bytes. */
size?: number | undefined;
};
export type BoolToBytesErrorType = AssertSizeErrorType | PadLeftErrorType | ErrorType;
export type BooleanToBytesErrorType = AssertSizeErrorType | PadLeftErrorType | ErrorType;
/**

@@ -45,3 +45,3 @@ * Encodes a boolean value into {@link Bytes}.

* import { Bytes } from 'ox'
* const data = Bytes.fromBool(true)
* const data = Bytes.fromBoolean(true)
* // Uint8Array([1])

@@ -51,6 +51,6 @@ *

* import { Bytes } from 'ox'
* const data = Bytes.fromBool(true, { size: 32 })
* const data = Bytes.fromBoolean(true, { size: 32 })
* // Uint8Array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1])
*/
export declare function boolToBytes(value: boolean, options?: BoolToBytesOptions): Uint8Array;
export declare function booleanToBytes(value: boolean, options?: BooleanToBytesOptions): Uint8Array;
export type HexToBytesOptions = {

@@ -57,0 +57,0 @@ /** Size of the output bytes. */

@@ -32,3 +32,3 @@ import { assertSize } from '../data/assertSize.js';

if (typeof value === 'boolean')
return boolToBytes(value, options);
return booleanToBytes(value, options);
if (typeof value === 'string')

@@ -45,3 +45,3 @@ return stringToBytes(value, options);

* import { Bytes } from 'ox'
* const data = Bytes.fromBool(true)
* const data = Bytes.fromBoolean(true)
* // Uint8Array([1])

@@ -51,6 +51,6 @@ *

* import { Bytes } from 'ox'
* const data = Bytes.fromBool(true, { size: 32 })
* const data = Bytes.fromBoolean(true, { size: 32 })
* // Uint8Array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1])
*/
export function boolToBytes(value, options = {}) {
export function booleanToBytes(value, options = {}) {
const { size } = options;

@@ -57,0 +57,0 @@ const bytes = new Uint8Array(1);

@@ -11,3 +11,3 @@ import { type AssertSizeErrorType } from '../data/assertSize.js';

};
export type ToHexErrorType = BoolToHexErrorType | BytesToHexErrorType | IsHexErrorType | InvalidTypeErrorType | NumberToHexErrorType | StringToHexErrorType | ErrorType;
export type ToHexErrorType = BooleanToHexErrorType | BytesToHexErrorType | IsHexErrorType | InvalidTypeErrorType | NumberToHexErrorType | StringToHexErrorType | ErrorType;
/**

@@ -32,7 +32,7 @@ * Encodes an arbitrary value into a {@link Hex} value.

export declare function toHex(value: string | number | bigint | boolean | Bytes, options?: ToHexParameters): Hex;
export type BoolToHexOptions = {
export type BooleanToHexOptions = {
/** The size (in bytes) of the output hex value. */
size?: number | undefined;
};
export type BoolToHexErrorType = AssertSizeErrorType | PadLeftErrorType | ErrorType;
export type BooleanToHexErrorType = AssertSizeErrorType | PadLeftErrorType | ErrorType;
/**

@@ -43,3 +43,3 @@ * Encodes a boolean into a {@link Hex} value.

* import { Hex } from 'ox'
* Hex.fromBool(true)
* Hex.fromBoolean(true)
* // '0x1'

@@ -49,3 +49,3 @@ *

* import { Hex } from 'ox'
* Hex.fromBool(false)
* Hex.fromBoolean(false)
* // '0x0'

@@ -55,6 +55,6 @@ *

* import { Hex } from 'ox'
* Hex.fromBool(true, { size: 32 })
* Hex.fromBoolean(true, { size: 32 })
* // '0x0000000000000000000000000000000000000000000000000000000000000001'
*/
export declare function boolToHex(value: boolean, options?: BoolToHexOptions): Hex;
export declare function booleanToHex(value: boolean, options?: BooleanToHexOptions): Hex;
export type BytesToHexOptions = {

@@ -61,0 +61,0 @@ /** The size (in bytes) of the output hex value. */

@@ -35,3 +35,3 @@ import { assertSize } from '../data/assertSize.js';

if (typeof value === 'boolean')
return boolToHex(value, options);
return booleanToHex(value, options);
throw new InvalidTypeError(typeof value);

@@ -44,3 +44,3 @@ }

* import { Hex } from 'ox'
* Hex.fromBool(true)
* Hex.fromBoolean(true)
* // '0x1'

@@ -50,3 +50,3 @@ *

* import { Hex } from 'ox'
* Hex.fromBool(false)
* Hex.fromBoolean(false)
* // '0x0'

@@ -56,6 +56,6 @@ *

* import { Hex } from 'ox'
* Hex.fromBool(true, { size: 32 })
* Hex.fromBoolean(true, { size: 32 })
* // '0x0000000000000000000000000000000000000000000000000000000000000001'
*/
export function boolToHex(value, options = {}) {
export function booleanToHex(value, options = {}) {
const hex = `0x${Number(value)}`;

@@ -62,0 +62,0 @@ if (typeof options.size === 'number') {

/** @internal */
export declare const version = "0.0.0-20240814T041200";
export declare const version = "0.0.0-20240814T043527";
//# sourceMappingURL=version.d.ts.map
/** @internal */
export const version = '0.0.0-20240814T041200';
export const version = '0.0.0-20240814T043527';
//# sourceMappingURL=version.js.map

@@ -76,4 +76,4 @@ export {

export {
type BoolToBytesErrorType,
type BoolToBytesOptions,
type BooleanToBytesErrorType,
type BooleanToBytesOptions,
type HexToBytesErrorType,

@@ -86,4 +86,4 @@ type HexToBytesOptions,

type ToBytesOptions,
boolToBytes,
boolToBytes as fromBool,
booleanToBytes,
booleanToBytes as fromBoolean,
hexToBytes,

@@ -90,0 +90,0 @@ hexToBytes as fromHex,

@@ -77,4 +77,4 @@ export {

export {
type BoolToHexErrorType,
type BoolToHexOptions,
type BooleanToHexErrorType,
type BooleanToHexOptions,
type BytesToHexErrorType,

@@ -88,4 +88,4 @@ type BytesToHexOptions,

type ToHexParameters,
boolToHex,
boolToHex as fromBool,
booleanToHex,
booleanToHex as fromBoolean,
bytesToHex,

@@ -92,0 +92,0 @@ bytesToHex as fromBytes,

@@ -29,3 +29,3 @@ import { type AssertSizeErrorType, assertSize } from '../data/assertSize.js'

| NumberToBytesErrorType
| BoolToBytesErrorType
| BooleanToBytesErrorType
| HexToBytesErrorType

@@ -60,3 +60,3 @@ | StringToBytesErrorType

if (isHex(value)) return hexToBytes(value, options)
if (typeof value === 'boolean') return boolToBytes(value, options)
if (typeof value === 'boolean') return booleanToBytes(value, options)
if (typeof value === 'string') return stringToBytes(value, options)

@@ -68,3 +68,3 @@ if (typeof value === 'number' || typeof value === 'bigint')

export type BoolToBytesOptions = {
export type BooleanToBytesOptions = {
/** Size of the output bytes. */

@@ -74,3 +74,3 @@ size?: number | undefined

export type BoolToBytesErrorType =
export type BooleanToBytesErrorType =
| AssertSizeErrorType

@@ -85,3 +85,3 @@ | PadLeftErrorType

* import { Bytes } from 'ox'
* const data = Bytes.fromBool(true)
* const data = Bytes.fromBoolean(true)
* // Uint8Array([1])

@@ -91,6 +91,9 @@ *

* import { Bytes } from 'ox'
* const data = Bytes.fromBool(true, { size: 32 })
* const data = Bytes.fromBoolean(true, { size: 32 })
* // Uint8Array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1])
*/
export function boolToBytes(value: boolean, options: BoolToBytesOptions = {}) {
export function booleanToBytes(
value: boolean,
options: BooleanToBytesOptions = {},
) {
const { size } = options

@@ -97,0 +100,0 @@ const bytes = new Uint8Array(1)

@@ -29,3 +29,3 @@ import { type AssertSizeErrorType, assertSize } from '../data/assertSize.js'

export type ToHexErrorType =
| BoolToHexErrorType
| BooleanToHexErrorType
| BytesToHexErrorType

@@ -65,7 +65,7 @@ | IsHexErrorType

if (typeof value === 'string') return stringToHex(value, options)
if (typeof value === 'boolean') return boolToHex(value, options)
if (typeof value === 'boolean') return booleanToHex(value, options)
throw new InvalidTypeError(typeof value)
}
export type BoolToHexOptions = {
export type BooleanToHexOptions = {
/** The size (in bytes) of the output hex value. */

@@ -75,3 +75,3 @@ size?: number | undefined

export type BoolToHexErrorType =
export type BooleanToHexErrorType =
| AssertSizeErrorType

@@ -86,3 +86,3 @@ | PadLeftErrorType

* import { Hex } from 'ox'
* Hex.fromBool(true)
* Hex.fromBoolean(true)
* // '0x1'

@@ -92,3 +92,3 @@ *

* import { Hex } from 'ox'
* Hex.fromBool(false)
* Hex.fromBoolean(false)
* // '0x0'

@@ -98,6 +98,9 @@ *

* import { Hex } from 'ox'
* Hex.fromBool(true, { size: 32 })
* Hex.fromBoolean(true, { size: 32 })
* // '0x0000000000000000000000000000000000000000000000000000000000000001'
*/
export function boolToHex(value: boolean, options: BoolToHexOptions = {}): Hex {
export function booleanToHex(
value: boolean,
options: BooleanToHexOptions = {},
): Hex {
const hex: Hex = `0x${Number(value)}`

@@ -104,0 +107,0 @@ if (typeof options.size === 'number') {

{
"name": "ox",
"description": "Ethereum Standard Library",
"version": "0.0.0-20240814T041200",
"version": "0.0.0-20240814T043527",
"main": "./_cjs/index.js",

@@ -6,0 +6,0 @@ "module": "./_esm/index.js",

/** @internal */
export const version = '0.0.0-20240814T041200'
export const version = '0.0.0-20240814T043527'

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

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

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

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

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

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc