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 getCircularArrayIndex = (i, { length }) => | |
| (i % length + length) % length; | |
| const testArray = new Array(5); | |
| for (let i = -30; i < 31; i++) { | |
| console.log(i, getCircularArrayIndex(i, testArray)) | |
| } |
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
| open -a Preview ~/Library/Messages/Attachments |
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
| new URLSearchParams([...new FormData(ev.target)]) |
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 getProxy = (target = {}, key) => | |
| target[key] || (target[key] = new Proxy({}, { get: getProxy })); | |
| const fillPick = (proxy, fn, fromObject = fn(proxy)) => | |
| Object.assign( | |
| {}, | |
| ...Object.entries(proxy).map(([key, value]) => ({ | |
| [key]: Object.keys(value).length | |
| ? fillPick(value, fn, fromObject[key]) | |
| : fromObject[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
| // Thanks to https://vincent.billey.me/pure-javascript-immutable-array | |
| import React, { Component } from 'react'; | |
| const setStateArraySplice = ( | |
| stateKey, | |
| arrayStart, | |
| arrayDeleteCount, | |
| ...items | |
| ) => ({ |
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
| var test = () => { | |
| console.log('fired on DOMContentLoaded or after'); | |
| } | |
| window.onwheneva = test; | |
| document.readyState !== 'loading' ? onwheneva() : | |
| document.addEventListener('DOMContentLoaded', onwheneva); |
NewerOlder