Skip to content

Instantly share code, notes, and snippets.

View jmlivingston's full-sized avatar

John Livingston jmlivingston

View GitHub Profile
@jmlivingston
jmlivingston / machineCheatSheet.js
Last active December 21, 2021 04:38
xstate.js
const machineCheatSheet = {
// ***** COMMON *****
id: 'custom-id',
type: 'atomic', // atomic | compound | history | final | parallel
initial: 'start', // initial state
context: {}, // any object - extended state
states: { start: {}, final: {} },
// ***** ACTIONS - ENTRY / EXIT *****
entry: [], // * actions
@jmlivingston
jmlivingston / machine.js
Last active August 2, 2021 23:27
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@jmlivingston
jmlivingston / cra-to-snowpack.js
Last active February 22, 2021 04:37
cra-to-snowpack
#!/usr/bin/env node
// Instructions - Run the following within an existing project generated by create-react-app.
// npx https://gist.github.com/jmlivingston/3516dbe71f2bcba17e41dd3fb44d1cfa
// For detailed steps, check out https://github.com/jmlivingston/cra-to-snowpack
const { exec } = require('child_process')
const fs = require('fs')
const path = require('path')
@jmlivingston
jmlivingston / debounce.md
Last active March 9, 2020 17:29 — forked from nmsdvid/new_gist_file.js
Simple JavaScript Debounce Function

Definition

Prevents function from being called until delay has passed without being called. This prevents excessive computer operations like API calls or heavy calculations.

Pattern

Curried function with two parameters: function and delay. As long as the debounced function continues to be called within the delay, the original function will not be called.

Use Cases