
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
gdmn-utils
Advanced tools
A collection of utility functions.
uint8ArrayToBase64function uint8ArrayToBase64(uint8Array: Uint8Array): string
Description:
Converts a Uint8Array into a Base64-encoded string. This function checks for the availability of encoding methods in the environment and uses them accordingly.
Parameters:
uint8Array (Uint8Array): The input array of 8-bit unsigned integers to be encoded.Returns:
string: The Base64-encoded representation of the input array.Usage Example:
const data = new Uint8Array([72, 101, 108, 108, 111]); // Represents 'Hello'
const base64String = uint8ArrayToBase64(data);
console.log(base64String); // Outputs: 'SGVsbG8='
Notes:
btoa for encoding.Buffer.base64ToUint8Arrayfunction base64ToUint8Array(base64String: string): Uint8Array
Description:
Decodes a Base64-encoded string back into a Uint8Array. The function adapts to the environment to use the appropriate decoding method.
Parameters:
base64String (string): The Base64-encoded string to be decoded.Returns:
Uint8Array: The decoded array of 8-bit unsigned integers.Usage Example:
const base64String = 'SGVsbG8=';
const data = base64ToUint8Array(base64String);
console.log(data); // Outputs: Uint8Array(5) [72, 101, 108, 108, 111]
Notes:
Buffer for decoding.atob.uint8ArrayToUtf8Stringfunction uint8ArrayToUtf8String(uint8Array: Uint8Array): string
Description:
Converts a Uint8Array into a UTF-8 encoded string using the TextDecoder API.
Parameters:
uint8Array (Uint8Array): The input array of 8-bit unsigned integers to be converted.Returns:
string: The resulting UTF-8 string.Usage Example:
const data = new Uint8Array([72, 101, 108, 108, 111]);
const utf8String = uint8ArrayToUtf8String(data);
console.log(utf8String); // Outputs: 'Hello'
Notes:
TextDecoder API, which is widely supported in modern environments.numberToUint8Array32function numberToUint8Array32(number: number): Uint8Array
Description:
Encodes a 32-bit floating-point number into a Uint8Array. This is useful for binary data manipulation where numerical values need to be represented as byte arrays.
Parameters:
number (number): The 32-bit floating-point number to be encoded.Returns:
Uint8Array: A 4-byte array representing the encoded number.Usage Example:
const num = 3.14;
const byteArray = numberToUint8Array32(num);
console.log(byteArray); // Outputs: Uint8Array(4) [...]
Notes:
ArrayBuffer and DataView for precise byte-level manipulation.uint8ArrayToNumber32function uint8ArrayToNumber32(uint8Array: Uint8Array): number
Description:
Decodes a Uint8Array back into a 32-bit floating-point number. This function is the inverse of numberToUint8Array32.
Parameters:
uint8Array (Uint8Array): A 4-byte array representing the encoded number.Returns:
number: The decoded 32-bit floating-point number.Usage Example:
const byteArray = new Uint8Array([195, 245, 72, 64]);
const num = uint8ArrayToNumber32(byteArray);
console.log(num); // Outputs: 3.14
Notes:
Uint8Array has a length of at least 4 bytes.uint8ArrayToBase64 and base64ToUint8Array handle both browser and Node.js environments by checking for the presence of btoa, atob, and Buffer.TextDecoder API used in uint8ArrayToUtf8String is supported in modern browsers and Node.js versions.uint8ArrayToBase64 and base64ToUint8Array throw an error if the environment lacks support for the necessary encoding or decoding functions.slimCreates a cleaned copy of an object by removing values and/or fields based on options.
stripFields formats"field" — strip this field name at all nesting levels.".field" — strip this field only at the root level.".a.b.c" — strip c only when parent path is exactly a.b from root.".a.*.c" — * matches one nesting step (each object key or each array item).const source = {
attributes: {
first: { required: true, keep: 'A' },
second: { required: false, keep: 'B' }
}
};
const result = slim(source, {
deep: true,
stripFields: ['.attributes.*.required']
});
// result:
// {
// attributes: {
// first: { keep: 'A' },
// second: { keep: 'B' }
// }
// }
When multiple deep paths are provided (for example ['.attributes.*.required', '.attributes.*.index']), they are processed together during traversal.
FAQs
A collection of utility functions.
The npm package gdmn-utils receives a total of 226 weekly downloads. As such, gdmn-utils popularity was classified as not popular.
We found that gdmn-utils demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.