Published
Edited
May 6, 2018
4 stars
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
stdlib_flat_help = require( "https://unpkg.com/@stdlib/stdlib@0.0.38/dist/stdlib-flat-help.min.js" )
Insert cell
Insert cell
Insert cell
HELP = stdlib_flat_help.help()
Insert cell
Insert cell
function help( alias ) {
var txt;
if ( HELP.hasOwnProperty( alias ) ) {
txt = HELP[ alias ];
} else {
txt = 'Error: unrecognized alias. Ensure that the provided alias is spelled correctly, including capitalization.';
}
return md`\`\`\`${txt}\`\`\``;
}
Insert cell
Insert cell
help( 'base.sin' )
Insert cell
Insert cell
Insert cell
aliases = Object.keys( HELP )
Insert cell
Insert cell
function randomHelpText() {
var idx = Math.floor( Math.random() * aliases.length ); // Not perfectly uniform, but close enough...
return help( aliases[ idx ] );
}
Insert cell
Insert cell
PAUSE = true
Insert cell
Insert cell
function *simulation( delay ) {
delay *= 1000; // convert seconds to milliseconds
while ( true ) {
yield new Promise( onResolve );
};
function onResolve( resolve ) {
setTimeout( onTimeout, delay );
function onTimeout() {
// In the "paused" state, we never resolve the promise...
if ( !PAUSE ) {
resolve( randomHelpText() );
}
}
}
}
Insert cell
simulation( 10 )
Insert cell
Insert cell
viewof helpIndex = html`<input type="range" min=0 max=${aliases.length-1} value=0>`
Insert cell
Insert cell
help( aliases[ helpIndex ] )
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more