base64ToRaw(value: string)

Requires:
@ray-js/panel-sdk≥1.0.0

Description

Convert a Base64-encoded string to a hexadecimal raw string

Parameters

ParameterTypeRequiredDescription
valuestringYesA Base64-encoded string

Return Value

Type: string
The corresponding hexadecimal raw string, two characters per byte

Examples

Basic usage

import { utils } from '@ray-js/panel-sdk';

const { base64ToRaw } = utils;

base64ToRaw('SGVsbG8='); // '48656c6c6f'
base64ToRaw('/wA=');     // 'ff00'

rawToBase64(value: string)

Requires:
@ray-js/panel-sdk≥1.0.0

Description

Convert a hexadecimal raw string to a Base64-encoded string

Parameters

ParameterTypeRequiredDescription
valuestringYesA hexadecimal raw string whose length must be even

Return Value

Type: any
The Base64-encoded string; returns an empty string if the input length is odd

Examples

Basic usage

import { utils } from '@ray-js/panel-sdk';

const { rawToBase64 } = utils;

rawToBase64('48656c6c6f'); // 'SGVsbG8='
rawToBase64('ff00');       // '/wA='
rawToBase64('f');          // '' (odd length returns empty string)

hexToBinary(value: string)

Requires:
@ray-js/panel-sdk≥1.0.0

Description

Convert a hexadecimal string to a binary string

Parameters

ParameterTypeRequiredDescription
valuestringYesHexadecimal string

Return Value

Type: string
The corresponding binary string

Examples

Basic usage

import { utils } from '@ray-js/panel-sdk';

const { hexToBinary } = utils;

hexToBinary('ff'); // '11111111'
hexToBinary('0a'); // '1010'
hexToBinary('1');  // '1'

generateDpStrStep(dpStr: string)

Requires:
@ray-js/panel-sdk≥1.0.0

Description

Create a step-wise parser for raw or string DPs

Parameters

ParameterTypeRequiredDescription
dpStrstringYesThe DP hexadecimal string to parse

Return Value

Type: (num: number, type: "string" | "number") => __object
A step parser function; each call returns the next parsed segment as { value, done }

Valid Values

return.type
ValueDescriptionSince
string--
number--

Examples

Basic usage

import { utils } from '@ray-js/panel-sdk';

const { generateDpStrStep } = utils;

const step = generateDpStrStep('3264');
const val1 = step().value;  // 50  (0x32)
const val2 = step(2).value; // 100 (0x64)