@blake.regalia/belt
Advanced tools
Comparing version 0.42.0 to 0.43.0
@@ -201,2 +201,8 @@ import type { NaiveBase58, NaiveBase64, NaiveBase93, NaiveHexLower } from './strings'; | ||
/** | ||
* Split a byte array into 'words' using the given delimiter | ||
* @param xb_value the delimiter value to split by | ||
* @returns list of words which will all be zeroed out when the parent instance is wiped | ||
*/ | ||
export declare const bytes_split: (atu8_bytes: Uint8Array, xb_delimiter: number) => Uint8Array[]; | ||
/** | ||
* Concatenate a sequence of Uint8Arrays. | ||
@@ -203,0 +209,0 @@ * @param a_buffers the data to concatenate in order |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.bytes_to_base93 = exports.bytes_to_string8 = exports.string8_to_bytes = exports.base64_to_bytes = exports.bytes_to_base64 = exports.base64_to_bytes_slim = exports.bytes_to_base64_slim = exports.hex_to_bytes = exports.bytes_to_hex = exports.concat2 = exports.concat = exports.bytes_to_bigint_be = exports.bytes_to_biguint_be = exports.bigint_to_bytes_be = exports.biguint_to_bytes_be = exports.bytes_to_uint32_be = exports.uint32_to_bytes_be = exports.bytes_to_json = exports.json_to_bytes = exports.text_to_base64 = exports.base64_to_text = exports.bytes_to_text = exports.text_to_bytes = exports.decode_length_prefix_u16 = exports.encode_length_prefix_u16 = exports.zero_out = exports.hkdf = exports.hmac = exports.import_key = exports.sha512 = exports.sha384 = exports.sha256d = exports.sha256 = exports.dataview = exports.bytes = exports.canonicalize_json = exports.safe_json = exports.parse_json_safe = exports.parse_json = exports.stringify_json = exports.safely_sync = exports.uuid_v4 = exports.bigint_min = exports.bigint_max = exports.bigint_abs = exports.bigint_greater = exports.bigint_lesser = exports.SI_HASH_ALGORITHM_SHA512 = exports.SI_HASH_ALGORITHM_SHA384 = exports.SI_HASH_ALGORITHM_SHA256 = void 0; | ||
exports.crypto_random_int = exports.crypto_random = exports.crypto_random_unit_double = exports.crypto_random_bytes = exports.base58_to_bytes = exports.bytes_to_base58 = exports.base93_to_bytes = void 0; | ||
exports.bytes_to_string8 = exports.string8_to_bytes = exports.base64_to_bytes = exports.bytes_to_base64 = exports.base64_to_bytes_slim = exports.bytes_to_base64_slim = exports.hex_to_bytes = exports.bytes_to_hex = exports.concat2 = exports.concat = exports.bytes_split = exports.bytes_to_bigint_be = exports.bytes_to_biguint_be = exports.bigint_to_bytes_be = exports.biguint_to_bytes_be = exports.bytes_to_uint32_be = exports.uint32_to_bytes_be = exports.bytes_to_json = exports.json_to_bytes = exports.text_to_base64 = exports.base64_to_text = exports.bytes_to_text = exports.text_to_bytes = exports.decode_length_prefix_u16 = exports.encode_length_prefix_u16 = exports.zero_out = exports.hkdf = exports.hmac = exports.import_key = exports.sha512 = exports.sha384 = exports.sha256d = exports.sha256 = exports.dataview = exports.bytes = exports.canonicalize_json = exports.safe_json = exports.parse_json_safe = exports.parse_json = exports.stringify_json = exports.safely_sync = exports.uuid_v4 = exports.bigint_min = exports.bigint_max = exports.bigint_abs = exports.bigint_greater = exports.bigint_lesser = exports.SI_HASH_ALGORITHM_SHA512 = exports.SI_HASH_ALGORITHM_SHA384 = exports.SI_HASH_ALGORITHM_SHA256 = void 0; | ||
exports.crypto_random_int = exports.crypto_random = exports.crypto_random_unit_double = exports.crypto_random_bytes = exports.base58_to_bytes = exports.bytes_to_base58 = exports.base93_to_bytes = exports.bytes_to_base93 = void 0; | ||
const belt_js_1 = require("./belt.js"); | ||
@@ -337,2 +337,30 @@ exports.SI_HASH_ALGORITHM_SHA256 = 'SHA-256'; | ||
/** | ||
* Split a byte array into 'words' using the given delimiter | ||
* @param xb_value the delimiter value to split by | ||
* @returns list of words which will all be zeroed out when the parent instance is wiped | ||
*/ | ||
const bytes_split = (atu8_bytes, xb_delimiter) => { | ||
// array of pointers to words as buffers | ||
let a_words = []; | ||
// byte index start of word | ||
let ib_start = 0; | ||
// while there are words remaining | ||
for (;;) { | ||
// find next matching byte | ||
const ib_delim = atu8_bytes.indexOf(xb_delimiter, ib_start); | ||
// no more matches | ||
if (-1 === ib_delim) | ||
break; | ||
// without copying data, save a reference to the word | ||
a_words.push(atu8_bytes.subarray(ib_start, ib_delim)); | ||
// advanced the index for the start of the next word | ||
ib_start = ib_delim + 1; | ||
} | ||
// push final word | ||
a_words.push(atu8_bytes.subarray(ib_start)); | ||
// return list of words | ||
return a_words; | ||
}; | ||
exports.bytes_split = bytes_split; | ||
/** | ||
* Concatenate a sequence of Uint8Arrays. | ||
@@ -339,0 +367,0 @@ * @param a_buffers the data to concatenate in order |
@@ -201,2 +201,8 @@ import type { NaiveBase58, NaiveBase64, NaiveBase93, NaiveHexLower } from './strings'; | ||
/** | ||
* Split a byte array into 'words' using the given delimiter | ||
* @param xb_value the delimiter value to split by | ||
* @returns list of words which will all be zeroed out when the parent instance is wiped | ||
*/ | ||
export declare const bytes_split: (atu8_bytes: Uint8Array, xb_delimiter: number) => Uint8Array[]; | ||
/** | ||
* Concatenate a sequence of Uint8Arrays. | ||
@@ -203,0 +209,0 @@ * @param a_buffers the data to concatenate in order |
@@ -303,2 +303,29 @@ import { XG_8, is_array, is_dict_es, is_string, entries, from_entries, die, try_sync } from './belt.js'; | ||
/** | ||
* Split a byte array into 'words' using the given delimiter | ||
* @param xb_value the delimiter value to split by | ||
* @returns list of words which will all be zeroed out when the parent instance is wiped | ||
*/ | ||
export const bytes_split = (atu8_bytes, xb_delimiter) => { | ||
// array of pointers to words as buffers | ||
let a_words = []; | ||
// byte index start of word | ||
let ib_start = 0; | ||
// while there are words remaining | ||
for (;;) { | ||
// find next matching byte | ||
const ib_delim = atu8_bytes.indexOf(xb_delimiter, ib_start); | ||
// no more matches | ||
if (-1 === ib_delim) | ||
break; | ||
// without copying data, save a reference to the word | ||
a_words.push(atu8_bytes.subarray(ib_start, ib_delim)); | ||
// advanced the index for the start of the next word | ||
ib_start = ib_delim + 1; | ||
} | ||
// push final word | ||
a_words.push(atu8_bytes.subarray(ib_start)); | ||
// return list of words | ||
return a_words; | ||
}; | ||
/** | ||
* Concatenate a sequence of Uint8Arrays. | ||
@@ -305,0 +332,0 @@ * @param a_buffers the data to concatenate in order |
{ | ||
"name": "@blake.regalia/belt", | ||
"version": "0.42.0", | ||
"version": "0.43.0", | ||
"repository": "github:blake-regalia/belt", | ||
@@ -5,0 +5,0 @@ "license": "ISC", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
357547
6683