Skip to content

Instantly share code, notes, and snippets.

View youyoumu's full-sized avatar

youyoumu youyoumu

View GitHub Profile
import { spawnSync } from "child_process";
import { defineConfig } from "tsup";
export default defineConfig((options) => ({
entry: ["src/**/*.{ts,tsx}"],
format: "esm",
outDir: "dist",
splitting: false,
outExtension() {
return {
@youyoumu
youyoumu / tsconfig.json
Created March 1, 2025 12:03
typescript config with explanation
{
// reference: https://www.totaltypescript.com/tsconfig-cheat-sheet
"compilerOptions": {
// --- base options --
"esModuleInterop": true,
"skipLibCheck": true,
"target": "ES2022",
"allowJs": true,
"checkJs": true,
@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
Last active March 1, 2025 12:59
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,