1.0.11 • Published 6 months ago

@arun_murali/rustyutils v1.0.11

Weekly downloads
-
License
MIT/Apache-2.0
Repository
-
Last release
6 months ago

📘 Function Documentation

Introduction

Welcome to the function documentation for our project! This document provides detailed descriptions, parameters, return values, and example usages for all available functions. It is designed to help you understand how each function works and how to use them in your projects. Below you'll find a table of contents that links to each function’s detailed documentation.

Table of Contents

deep_clone()

Description: Creates a deep copy of the given input.

Example usage:

const cloned = deep_clone({ key: 'value' });
console.log(cloned); // Output: { key: 'value' }

Parameters

NameTypeDescription
inputanyThe value to clone.

Returns

TypeDescription
anyThe deeply cloned value.

flatten()

Description: Flattens a nested object or array into a single-level object with dot-separated keys.

Example usage:

const flattened = flatten({ 'a.b.c': 1 });
console.log(flattened); // Output: { 'a.b.c': 1 }

Parameters

NameTypeDescription
inputanyThe object or array to flatten.

Returns

TypeDescription
anyThe flattened object with dot-separated keys representing the hierarchy of the original structure.

hash_value()

Description: Generates a hash of the input string using the specified algorithm.

Example usage:

const hash = hash_value('hello world', 'sha256');
console.log(hash); // Output: e.g. '64ec88ca00b268e5ba1a35678a1b5316d212f4f366b2477246bfe2f30e6e5aef'

Parameters

NameTypeDescription
inputstringThe input string to hash.
algostringThe hash algorithm to use. Supported: 'sha256', 'sha512', 'md5', 'sha3_256', 'sha3_512', 'blake2b', 'blake2s'.

Returns

TypeDescription
stringThe hexadecimal string of the hash output.

compare_hash()

Description: Compares an input string against a given hash using the specified algorithm.

Example usage:

const isValid = compare_hash('hello world', 'sha256', '64ec88ca00b268e5ba1a35678a1b5316d212f4f366b2477246bfe2f30e6e5aef');
console.log(isValid); // Output: true

Parameters

NameTypeDescription
inputstringThe input string to hash and compare.
algostringThe hashing algorithm to use. Same options as in hash_value.
expected_hashstringThe expected hash string to compare with.

Returns

TypeDescription
booleanReturns true if the generated hash matches the expected hash; otherwise, false.

chunk()

Description: Splits an input array into smaller chunks of a specified size.

Example usage:

const result = chunk([1, 2, 3, 4, 5], 2);
console.log(result); // Output: [[1, 2], [3, 4], [5]]

Parameters

NameTypeDescription
inputArray<any>The input array to be divided into chunks.
sizenumberThe maximum size of each chunk.

Returns

TypeDescription
Array<Array<any>>Returns an array of chunked arrays.

1.0.11

6 months ago

1.0.10

6 months ago

1.0.9

6 months ago

1.0.8

6 months ago

1.0.7

6 months ago

1.0.6

7 months ago

1.0.5

7 months ago

1.0.4

7 months ago

1.0.3

7 months ago

1.0.2

7 months ago

1.0.1

7 months ago

0.1.0

7 months ago

1.0.0

7 months ago