This file contains hidden or 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 getTrace = error => error.stack.match(/(?<=\().*(?=\))/g) |
This file contains hidden or 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 tableProps = { | |
| postId: ['varchar', 'NOT NULL', 'PRIMARY KEY'], | |
| id: ['numeric', 'NOT NULL', 'PRIMARY KEY'], | |
| data: ['json', 'NOT NULL'] | |
| } | |
| const result = | |
| Object | |
| .keys(tableProps) | |
| .reduce((acc, key) => { |
This file contains hidden or 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 prepareModuleForInjection = code => { | |
| const moduleBody = /(?<=\{return\s).*(?=})|(?<=({(?![return]))).*(?=})|(?<=\=>\s)(?=[a-z]).*|(?<=\=>)\n.*/gsi | |
| const [extractedBody] = String(code).match(moduleBody) || '' | |
| return extractedBody | |
| ? `${extractedBody.trim()}\n\n` | |
| : '' | |
| } | |
| webview.executeJavaScript( |
This file contains hidden or 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 toCamelCase = (str, separator) => | |
| separator | |
| ? str.toLowerCase().replace( | |
| new RegExp(`(${separator})*(${separator}.{1})`, 'g'), | |
| char => char.toUpperCase().substr(1) | |
| ) | |
| : str | |
| console.log( | |
| toCamelCase('my-cool-function', '-') // myCoolFunction |
This file contains hidden or 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 multilineString = ` | |
| This is... | |
| a multiline string. | |
| ` | |
| const minify = it => it.replace(/\s+/g, '') | |
| minify(multilineString) | |
| // Thisis...amultilinestring. |
This file contains hidden or 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 obj = { | |
| values: [1, 2, 3, 4, 5], | |
| [Symbol.iterator]() { | |
| let i = 0 | |
| return { | |
| next: () => { | |
| i++ | |
| return { |
This file contains hidden or 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 pixel = ((init = 0) => { | |
| let pixelValue = init | |
| function increment(value) { | |
| pixelValue += value | |
| } | |
| return { | |
| getByIncrement: value => { | |
| increment(value) |
This file contains hidden or 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 delay(time) { | |
| return new Promise(resolve => | |
| setTimeout(resolve, time) | |
| ) | |
| } | |
| (async () => { | |
| await delay(1000) | |
| console.log('It takes 1 second to be executed.') |
This file contains hidden or 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 numbers = [4, 2, 5, 1, 3] | |
| const orderBy = ([...arr], type = 'ASC') => { | |
| const order = { | |
| ASC: (a, b) => a - b, | |
| DESC: (a, b) => b - a | |
| } | |
| return arr.sort(order[type]) | |
| } |
This file contains hidden or 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
| fetch('https://www.githubstatus.com/') | |
| .then(res => res.text()) | |
| .then(text => { | |
| const parser = new DOMParser() | |
| const dom = parser.parseFromString(text, 'text/html') | |
| const status = Array.from( | |
| dom.querySelectorAll("div.component-inner-container.showcased span.component-status"), | |
| el => { | |
| const alias = { | |
| 'status-green': 'normal', |