09 2024 档案
摘要:function observe(obj) { for (const key in obj) { let internalValue = obj[key]; const funs = new Set() Object.defineProperty(obj, key, { configurable:
阅读全文
摘要:Let's say we have a Vue application that renders many heavy components on the first load. The problem we're facing is a long white screen period while
阅读全文
摘要:In a production environment, we want to prompt the user with a message when new scripts are available, asking New scripts are available. Do you want t
阅读全文
摘要:export const isPromiseLike = <T>(value: PromiseLike<T>) => value !== null && (typeof value 'object' || typeof value 'function') && typeof value.then '
阅读全文
摘要:export const isAsyncFunction = (fn: Function) => fn[Symbol.toStringTag] 'AsyncFunction'; // isAsyncFunction(() => {}) // false // isAsyncFunction(() =
阅读全文
摘要:type BanType<T, E> = T extends E ? never : T; type BanDate<T> = BanType<T, Date>; function log<T>(x: BanDate<T>) { console.log() } log(new Date()) //
阅读全文
摘要:.callmethod exits on any function, which will refer to Function.prototype.call for example: console.log.call Function.prototype.call // call Also it m
阅读全文
摘要:const requestFullscreenProps = [ "requestFullScreen", "webkitRequestFullScreen", "mozRequestFullScreen", "msRequestFullScreen", ] as const; const exit
阅读全文
摘要:The difference between document.body and document.documentElement: document.body returns the <body> elementdocument.documentElement returns the <html>
阅读全文
摘要:Consider this Result type: type Result<TResult, TError> = | { success: true; data: TResult; } | { success: false; error: TError; }; The Result type ha
阅读全文
摘要:Node.js on Containers So now what if we wanted to run a container that has Node.js in it? The default Ubuntu container doesn't have Node.js installed.
阅读全文
摘要:So it's much easier to do what we did with Docker. Run this command: docker run --interactive --tty alpine:3.19.1 # or, to be shorter: docker run -it
阅读全文
摘要:Consider this package.json file: { "name": "exercise", "version": "1.0.0", "main": "index.js", "scripts": { "dev": "run-p dev:*", "dev:client": "tsc -
阅读全文
摘要:A long-awaited feature is smart incremental builds for TypeScript projects. In 3.0 you can use the --build flag with tsc. This is effectively a new en
阅读全文
摘要:function timeout(time) { return new Promise((resolve) => { setTimeout(resolve, time); }); } class ParalleTask { constructor(paralleCount = 2) { this.t
阅读全文
摘要:@use 'sass:math'; .menu-item { opacity: 0; transition: 0.5s; } $r: 120px; $n: 6; $step: 360deg / $n; for $i from 1 through $n { .board:hover .menu-ite
阅读全文
摘要:export const randomColor = () => { return "#" + Math.random().toString(16).substring(2, 8).padEnd(6, '0') } export const randomString = (len: number)
阅读全文
摘要:The solution is to modify the tsconfig.json file to enable declarationMap under the compilerOptions. // inside tsconfig.json { "compilerOptions": { "d
阅读全文