Awaits for a pending response with a single line.
const { status, data, error } = await parseResponse(fetch('/resource')))Awaits for a pending response with a single line.
const { status, data, error } = await parseResponse(fetch('/resource')))| const splitWords = phrase => phrase.split(' ') | |
| const firstLetter = word => word.charAt(0) | |
| const lastLetter = word => word.charAt(word.length - 1) | |
| const initialLetter = words => words | |
| .map(word => word.charAt(0)) | |
| .join('') | |
| const firstAndLastLetter = word => [ | |
| firstLetter(word), |
| const grayscale = pixel => { | |
| const [r, g, b] = pixel.data | |
| const average = (r + g + b) / 3 | |
| pixel.data[0] = average | |
| pixel.data[1] = average | |
| pixel.data[2] = average | |
| return pixel | |
| } |
| const intersection = (a, b) => | |
| a.map(ai => b.filter(bi => bi === ai)).flat() | |
| intersection(['banana', 'apple'], ['banana', 'mellon']) // ['banana'] | |
| intersection(['banana', 'apple'], ['banana', 'mellon', 'apple']) // ['banana', 'apple'] |
| const createElement = name => | |
| document.createElement(String(name).toUpperCase()) | |
| const defineAttributes = (VNode, attributes) => | |
| Object.keys(attributes).forEach(attr => | |
| VNode.setAttribute(attr, attributes[attr])) | |
| const defineChildren = (VNode, children) => | |
| Array.isArray(children) && children.forEach(e => VNode.appendChild(e)) |
| import { Button } from './Button' | |
| export const Dialog = props => h('article', { | |
| id: 'my-dialog', | |
| content: Button({ | |
| textContent: 'Hey', | |
| onclick: props.onSuccessClick | |
| }) | |
| }) |
| + app.use('/', cors...) | |
| - app.use(cors...) |
| // Setting dynamic CORS for non-options Request | |
| app.use(cors((req, cb) => { | |
| const companyDNS = '.mycompany.xyz' | |
| const isTrusted = req.header('Origin').indexOf(companyDNS) >= 1 | |
| // Some more business logics... | |
| return cb(null, { | |
| credentials: true, | |
| origin: isTrusted |
| const Fetch = (fun, fetcher) => fun({ | |
| get(endpoint, headers) { | |
| return fetch(endpoint, headers) | |
| }, | |
| post(endpoint, body, headers) { | |
| return fetch(endpoint, { body, headers, method: 'POST' }) | |
| } | |
| }) | |
| /* | |
| Fat Cursor. | |
| This overwrites the "underline thin" style since that is one that can be styled with CSS | |
| So set your settings to: | |
| "editor.cursorStyle": "underline-thin", | |
| */ | |
| .monaco-editor .cursors-layer.cursor-underline-thin-style > .cursor { | |
| border-bottom-width: 0; | |
| border-left-width: 3px; | |
| border-left-style: solid; |