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
| /* | |
| Make the function more readable and maintainable | |
| */ | |
| function doStuff(text) { | |
| const lowerCased = text.toLocaleLowerCase(); | |
| const words = lowerCased.split(' '); | |
| words.reverse(); | |
| const trimmedWords = []; |
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
| // inspired by https://rescript-lang.org/docs/manual/v8.0.0/api/belt/map#getexn | |
| function makeErroringMap (array, byIdFunc, defaultValue) { | |
| const wm = new WeakMap() | |
| array.forEach(item => { | |
| wm.set(byIdFunc(item), item) | |
| }) | |
| return { | |
| get(id) { |
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
| import { createSelector } from 'reselect' | |
| export const getWorkflows = context => context.workflows | |
| export const getId = context => context.activeId | |
| /** OPTION 1 */ | |
| /** | |
| * Will probably throw an error |
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
| // 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 machine = Machine({ | |
| "id": "wizard", | |
| "initial": "idle", | |
| "context": { | |
| "steps": [ | |
| { | |
| "title": "Step 1", | |
| "next": true | |
| }, | |
| { |
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 machine = Machine({ | |
| "id": "playlist:1", | |
| "initial": "loading", | |
| "context": { | |
| "playlistId": 1, | |
| "playlist": { | |
| "name": "" | |
| }, | |
| "contribution": { | |
| "cursor": { |
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 submitWizard(context) { | |
| return new Promise((resolve, reject) => { | |
| setTimeOut(() => { | |
| const isSuccess = Math.random() > 0 | |
| return isSuccess ? resolve({ data: { your: "result" } }) : reject(Error('did not work')) | |
| }, 3000) | |
| }) | |
| } | |
| const wizard = Machine({ |
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
| Verifying my Blockstack ID is secured with the address 18uZo7LBYySEjYXiHPiXL1qwchSZWD2PCk https://explorer.blockstack.org/address/18uZo7LBYySEjYXiHPiXL1qwchSZWD2PCk |
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
| // classic | |
| function sum (a, b) { | |
| return a + b | |
| } | |
| // old-school | |
| var sum = function (a, b) { | |
| return a + b | |
| } | |
NewerOlder