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
{ | |
"useTabs": false, | |
"tabWidth": 2, | |
"semi": false, | |
"trailingComma": "none", | |
"endOfLine": "lf", | |
"printWidth": 100, | |
"singleQuote": false | |
} |
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 axios, { Method, AxiosInstance, AxiosRequestConfig } from 'axios' | |
// eslint-disable-next-line @typescript-eslint/ban-ts-comment | |
// @ts-ignore | |
import qs from 'qs' | |
export const FORM_METHOD: Method[] = ['POST', 'post', 'PUT', 'put'] | |
export const QUERY_METHOD: Method[] = ['GET', 'get', 'DELETE', 'delete'] | |
let http: AxiosInstance = axios.create({ | |
baseURL: '/' |
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
/** | |
* 判斷變數值是否是 Primitive | |
*/ | |
const isPrimitive = (val: any) => { | |
if (val == null) return true | |
if (typeof val === 'object' || typeof val === 'function') return false | |
return true | |
} |
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 str = 'bbabcddd' | |
const regex = /(abc)/gd; | |
const matched = regex.exec(str); | |
console.log(matched); | |
// [ | |
// "abc", | |
// "abc", | |
// groups: undefined, |
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
// usage.mjs | |
import { output } from "./awaiting.mjs"; | |
export function outputPlusValue(value) { return output + value } | |
console.log(outputPlusValue(100)); | |
setTimeout(() => console.log(outputPlusValue(100), 1000)); |
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 Person { | |
name = 'Kurt' | |
#age = 25 | |
test() { | |
console.log('Hi, ') | |
this.#ttt() | |
} | |
#ttt() { | |
console.log(this.name) | |
} |
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
// awaiting.mjs | |
import { process } from "./some-module.mjs"; | |
const dynamic = import(computedModuleSpecifier); | |
const data = fetch(url); | |
export const output = process((await dynamic).default, await data); |
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
// usage.mjs | |
import promise, { output } from "./awaiting.mjs"; | |
export function outputPlusValue(value) { return output + value } | |
promise.then(() => { | |
console.log(outputPlusValue(100)); | |
setTimeout(() => console.log(outputPlusValue(100), 1000); | |
}); |
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
// awaiting.mjs | |
import { process } from "./some-module.mjs"; | |
let output; | |
export default (async () => { | |
const dynamic = await import(computedModuleSpecifier); | |
const data = await fetch(url); | |
output = process(dynamic.default, data); | |
})(); | |
export { output }; |
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
// awaiting.mjs | |
import { process } from "./some-module.mjs"; | |
let output; | |
async function main() { | |
const dynamic = await import(computedModuleSpecifier); | |
const data = await fetch(url); | |
output = process(dynamic.default, data); | |
} | |
main(); | |
export { output }; |
NewerOlder