Skip to content

Instantly share code, notes, and snippets.

View frycz's full-sized avatar
🏠
Working from home

Adam Sawicki frycz

🏠
Working from home
View GitHub Profile
@frycz
frycz / machine.js
Last active August 31, 2020 08:08
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@frycz
frycz / flattenArray.js
Last active December 8, 2019 14:16
Function flattens an array of arbitrarily nested arrays of integers into a flat array of integers
/**
* Flattens an array of arbitrarily nested arrays of integers into a flat array of integers.
* Run `jest ./flattenArray.test.js` for tests.
*
* @param {*} arr - nested array of integers
* @returns flattened array
*/
function flattenArray(arr) {
const result = [];
arr.forEach(elem => {