Skip to content

Instantly share code, notes, and snippets.

View youyoumu's full-sized avatar

youyoumu youyoumu

View GitHub Profile
@youyoumu
youyoumu / segmentArray.ts
Last active December 14, 2024 12:42
Utility function to segment array into array of array with defined length
/** Segment array into array of array with defined length
* @example const data = [
* {name: "A"},
* {name: "B"},
* {name: "C"}
* ];
*
* const segmented = segmentArray(data, 2);
* console.log(segmented); // [[{name: "A"}, {name: "B"}], [{name: "C"}]]
*/
@youyoumu
youyoumu / mergeArrays.ts
Created December 14, 2024 12:40
Utility function to Merges two arrays of objects, combining properties from both arrays.
/**
* Merges two arrays of objects, combining properties from both arrays.
* Allows for duplicates and preserves all properties.
*
* @template T The first type of objects in the arrays
* @template U The second type of objects in the arrays
* @param array1 First array of objects
* @param array2 Second array of objects
* @returns Merged array of objects with combined properties
*/
@youyoumu
youyoumu / .prettierrc
Created November 16, 2024 09:18
My prettier config
{
"printWidth": 80,
"tabWidth": 2,
"useTabs": false,
"semi": false,
"singleQuote": true,
"quoteProps": "as-needed",
"jsxSingleQuote": false,
"trailingComma": "es5",
"bracketSpacing": true,