This file contains 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
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="utf-8" /> | |
<title>Nested Tables</title> | |
<style> | |
html { | |
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, | |
Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif; | |
font-size: 14px; |
This file contains 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 clone(...rest) { | |
return Object.assign({}, ...rest); | |
} | |
/** | |
* Builder for confirmation states. | |
* | |
* @param {String} onConfirm State to transition to on confirmation | |
* @param {String} onCancel State to transition to on cancel | |
*/ |
This file contains 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 config = { | |
id: 'annotation', | |
initial: 'unselected', | |
context: { | |
id: null, | |
annotation: null, | |
errorMessage: null | |
}, | |
states: { | |
unselected: { |
This file contains 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 fetchAnnotation(id) { | |
//return Promise.reject('oops!'); | |
return Promise.resolve({ | |
id, | |
comment: 'Dummy resolved', | |
user: 'jmakeig' | |
}); | |
} | |
function confirmCancel(message = 'You sure?') { |
This file contains 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
// Actions are on transitions | |
// Entry/exit are on states | |
// Mocks for testing services: https://medium.com/@tahini/how-to-effortlessly-model-async-react-with-xstates-invoke-4c36dc8547b3 | |
const dirty = { | |
initial: 'clean', | |
states: { | |
clean: { |
This file contains 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
{ | |
"exclude": [ | |
".git/**", | |
"node_modules/**", | |
"bower_components/**" | |
], | |
"always-semicolon": true, | |
"block-indent": "\t", | |
"color-case": "lower", | |
"color-shorthand": true, |
This file contains 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
# Set this up in .profile or remember to call it after nvm install | |
ln -s $(dirname $(nvm which $(nvm current))) "$NVM_DIR"/current |
This file contains 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 letters = xdmp.toJSON(['a', 'b', 'c']).root; // ArrayNode | |
Array.from(letters); // [Text, Text, Text] | |
ArrayNode.prototype[Symbol.iterator] = function*() { | |
for (let i = 0; i < this.length; i++) { | |
yield this[String(i)]; | |
} | |
}; |
This file contains 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 multiEntry from 'rollup-plugin-multi-entry'; | |
import nodeResolve from 'rollup-plugin-node-resolve'; | |
import typescript from 'rollup-plugin-typescript2'; | |
export default { | |
input: 'src/**/*.test.ts', | |
output: [ | |
/* Command-line in Node | |
```shell | |
rollup -c test.config.js && \ |
This file contains 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
// https://github.com/github/fetch/issues/175#issuecomment-216791333 | |
function timeoutPromise(ms, promise) { | |
return new Promise((resolve, reject) => { | |
const timeoutId = setTimeout(() => { | |
reject(new Error('promise timeout')); | |
}, ms); | |
promise.then( | |
res => { | |
clearTimeout(timeoutId); | |
resolve(res); |