Skip to content

Instantly share code, notes, and snippets.

View edouardmisset's full-sized avatar

Edouard edouardmisset

View GitHub Profile
@edouardmisset
edouardmisset / Shallow Object Comparison.md
Created January 2, 2024 15:11
The code snippet defines a function called `shallowComparison` that performs a shallow comparison between two objects of the same type. It checks if both objects have the same keys and if the values for these keys are the same in both objects

Shallow Object Comparison

Preview:
import { ObjectType } from './type-helpers'

/**
 * @description Performs a shallow comparison between two objects of the same type.
 * It checks if both objects have the same keys and if the values for these keys are the same in both objects.
 *
 * @template T The type of the objects to compare.
@edouardmisset
edouardmisset / Find Unique Elements from Array (symmetricDifference).md
Created December 22, 2023 16:10
This code snippet defines a function called `uniqueElements` that takes an array of arrays as input

Find Unique Elements from Array (symmetricDifference)

Preview:
/**
 * Returns the unique elements from n arrays.
 *
 * This function uses the `setDifference` function to find the elements that are in one array but not in the others.
 * It uses the `reduce` method to apply this process to each array in turn, starting with the first two arrays and then using their symmetric difference as the starting point for the next call.
 *
 * @template T The type of the elements in the arrays. It can be any type.
@edouardmisset
edouardmisset / Remove leading sign from string number.md
Last active December 22, 2023 16:05
test(Helper): ✅ add unit tests for some helper's pure functions

Remove leading sign from string number

Preview:
/**
 * @description Removes leading plus or minus sign from a string number.
 * @param {string} stringNumber - The string number to remove the leading sign from.
 * @returns {string} The string number without the leading sign.
 */
export const removeLeadingSign = (stringNumber: string): string =>
  stringNumber.replace(/^[+-]+/, '')