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 gameMachine = Machine( | |
{ | |
id: "pyramid", | |
initial: "play", | |
context: { | |
bet: 25, | |
levels: 3, | |
currentLevel: 1, | |
pyramid: { | |
// 0 => losing element |
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
function partition ( list, prop, begin, end, pivot ) { | |
var piv = list[pivot]; | |
swap (list, pivot, end-1 ); | |
var store = begin; | |
var ix; | |
for ( ix = begin; ix < end - 1; ++ix ) { | |
if ( list[ix][prop] <= piv[prop] ) { | |
swap (list, store, ix ); | |
++store; | |
} |
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 queueMachine = Machine({ | |
id: 'queue', | |
initial: '', | |
context: { | |
queue: [] | |
} | |
}) | |
const calendarMachine = Machine({ | |
id: 'calendar', |
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 results = [ | |
{ | |
"category":"Entertainment: Video Games", | |
"type":"multiple", | |
"difficulty":"easy", | |
"question":"Which game did "Sonic The Hedgehog" make his first appearance in?", | |
"correct_answer":"Rad Mobile", | |
"incorrect_answers":[ | |
"Sonic The Hedgehog", | |
"Super Mario 64", |
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 results = [ | |
{ | |
"category":"Entertainment: Video Games", | |
"type":"multiple", | |
"difficulty":"easy", | |
"question":"Which game did "Sonic The Hedgehog" make his first appearance in?", | |
"correct_answer":"Rad Mobile", | |
"incorrect_answers":[ | |
"Sonic The Hedgehog", | |
"Super Mario 64", |
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 CART_EVENT = { | |
ADD: "ADD", | |
REMOVE: "REMOVE", | |
UPDATE_QTY: "UPDATE_QTY", | |
SAVE_FOR_LATER: "SAVE_FOR_LATER" | |
}; | |
const SAVE_FOR_LATER_EVENT = { | |
ADD_TO_LIST: "ADD_TO_LIST", | |
UNSAVE: "UNSAVE", | |
MOVE_TO_CART: "MOVE_TO_CART" |
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 cartActions = { | |
addProduct: assign((ctx, evt)=> ({ | |
cart:{ | |
...ctx.cart, | |
count: ctx.cart.count + 1, | |
products: [...ctx.cart.products, evt.payload] | |
} | |
})), | |
addSaveForLater: assign((ctx, evt)=>({ |
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
// Available variables: | |
// - Machine | |
// - interpret | |
// - assign | |
// - send | |
// - sendParent | |
// - spawn | |
// - raise | |
// - actions |
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 context = { | |
password: "" | |
}; | |
const passwordMachine = Machine( | |
{ | |
initial: "idle", | |
context, | |
states: { | |
idle: { |
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 buttonMachine = Machine( | |
{ | |
id: "submitButtonWithTransitions", | |
initial: "disabled", | |
states: { | |
active: { | |
on: { | |
HOVER: "hovered", | |
PRESS: "pressed", | |
CLICK: "clicked", |
NewerOlder