This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const fs = require("fs"); | |
const path = require("path"); | |
const IgnoreFiles = ["node_modules", ".idea", ".vscode", "package-lock.json", "yarn.lock"]; | |
class RemoveComments { | |
sourcePath = ""; | |
targetPath = ""; | |
constructor(sourcePath, targetPath) { | |
this.sourcePath = sourcePath; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { fileURLToPath } from "node:url" | |
export const __dirname = () => fileURLToPath(import.meta.url) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
const genContainer = | |
(name: string): React.FC => | |
({ children }) => | |
( | |
<div> | |
<h1>I'm {name}</h1> | |
<div style={{ paddingLeft: '10px' }}>{children}</div> | |
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Node<T> { | |
value: T | |
next?: Node<T> | |
constructor(value: T) { | |
this.value = value | |
} | |
} | |
class Queue<T> { | |
private _size = 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function shallowClone(obj) { | |
if (typeof obj !== 'object') return obj; | |
const newObj = obj instanceof Array ? [] : {}; | |
for (let key of Object.keys(obj)) { | |
newObj[key] = obj[key]; | |
} | |
return newObj; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function deepCopySimple(obj) { | |
return JSON.parse(JSON.stringify(obj)); | |
} | |
function deepClone(obj) { | |
if (typeof obj !== 'object') return obj; | |
const newObj = obj instanceof Array ? [] : {}; | |
for (let key of Object.keys(obj)) { | |
if (typeof obj[key] !== 'object') { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class EventBus { | |
constructor() { | |
this.eventMap = {} | |
this.onceEventMap = {} | |
} | |
on(eventName, listener) { | |
if (!this.eventMap[eventName]) { | |
this.eventMap[eventName] = [listener] | |
} else { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
abstract class CustomStorage { | |
abstract storage: any; | |
abstract getItem<T>(key: string): T | null; | |
abstract setItem(key: string, value: any): void; | |
abstract removeItem(key: string): void; | |
abstract clear(): void; | |
getItemAndDelete<T>(key: string): T | null { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function curry(fn) { | |
return function curried(...args) { | |
if (fn.length === args.length) { | |
return fn.apply(this, args); | |
} | |
return (...extraArgs) => { | |
return curried.apply(this, args.concat(extraArgs)); | |
}; | |
}; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function debounce(fn, delay) { | |
let timerId = null; | |
return (...args) => { | |
clearTimeout(timerId); | |
timerId = setTimeout(() => { | |
fn(args) | |
}, delay) | |
} | |
} |
NewerOlder