This content moved here: https://exploringjs.com/impatient-js/ch_arrays.html#quickref-arrays
const waitFor = (ms) => new Promise(r => setTimeout(r, ms)) | |
const asyncForEach = async (array, callback) => { | |
for (let index = 0; index < array.length; index++) { | |
await callback(array[index], index, array) | |
} | |
} | |
const start = async () => { | |
await asyncForEach([1, 2, 3], async (num) => { | |
await waitFor(50) |
These files show one way to make the next.js "with-global-stylesheet" example work with the amazingly awesome Storybook ecosystem.
Specifically, the three files below replace the next.config.js
file, in the "with-global-stylesheet" example.
More generically, they demonstrate how to share webpack configuration extensions between next.js and Storybook.
A massive THANK YOU to tmeasday for all his help to get these working!
const randomInterval = (() => { | |
const random = (min, max) => Math.random() * (max - min) + min; | |
return (callback, min, max) => { | |
const time = { | |
start: performance.now(), | |
total: random(min, max) | |
}; | |
const tick = now => { | |
if (time.total <= now - time.start) { | |
time.start = now; |
Code spliting in webpack to help decrease loaded dependencies on load.
- UI that gets displayed as a callback from an event can benefit.
- We can async. load a ES6
import()
and code after it is returned using a promise.
// At top of file, assign an `import()` that is returned from a function.
const getBloodhound = () => import('bloodhound-js');
// Add an event that will trigger loading the module.
While attempting to explain JavaScript's reduce
method on arrays, conceptually, I came up with the following - hopefully it's helpful; happy to tweak it if anyone has suggestions.
JavaScript Arrays have lots of built in methods on their prototype. Some of them mutate - ie, they change the underlying array in-place. Luckily, most of them do not - they instead return an entirely distinct array. Since arrays are conceptually a contiguous list of items, it helps code clarity and maintainability a lot to be able to operate on them in a "functional" way. (I'll also insist on referring to an array as a "list" - although in some languages, List
is a native data type, in JS and this post, I'm referring to the concept. Everywhere I use the word "list" you can assume I'm talking about a JS Array) This means, to perform a single operation on the list as a whole ("atomically"), and to return a new list - thus making it much simpler to think about both the old list and the new one, what they contain, and
Penetrating Testing/Assessment Workflow & other fun infosec stuff
https://github.com/jivoi/pentest
My feeble attempt to organize (in a somewhat logical fashion) the vast amount of information, tools, resources, tip and tricks surrounding penetration testing, vulnerability assessment, and information security as a whole*
- Reconnaissance
- Passive/Semi-Passive
- Tools
- Passive/Semi-Passive
- Discover - https://github.com/leebaird/discover
https://gist.github.com/ljharb/58faf1cfcb4e6808f74aae4ef7944cff
While attempting to explain JavaScript's reduce
method on arrays, conceptually, I came up with the following - hopefully it's helpful; happy to tweak it if anyone has suggestions.
JavaScript Arrays have lots of built in methods on their prototype. Some of them mutate - ie, they change the underlying array in-place. Luckily, most of them do not - they instead return an entirely distinct array. Since arrays are conceptually a contiguous list of items, it helps code clarity and maintainability a lot to be able to operate on them in a "functional" way. (I'll also insist on referring to an array as a "list" - although in some languages, List
is a native data type, in JS and this post, I'm referring to the concept. Everywhere I use the word "list" you can assume I'm talking about a JS Array) This means, to perform a single operation on the list as a whole ("atomically"), and to return a new list - thus making it mu
export function tween( time, update ) { | |
const start = Date.now(); | |
var isCanceled = false; | |
var isComplete = false; | |
var chain = []; | |
function loop() { | |
if ( isCanceled ) return; |