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 most = require('most'); | |
const stream = most.just(Array(170000)); | |
const dest = []; | |
stream.forEach(bigArray => | |
dest.push.apply(dest, bigArray) | |
); |
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
var most = require('most'); | |
const init = most.fromEvent('click', window) | |
.scan(function(last) { return !last }, false); | |
init | |
.filter(Boolean) | |
.flatMap(function() { | |
return most.create(function(add, end, error) { | |
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
var most = require('most'); | |
const init = most.fromEvent('click', window) | |
.scan(function(last) { return !last }, false); | |
init | |
.filter(Boolean) | |
.flatMap(function() { | |
return most.create(function(add, end, error) { | |
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
var most = require('most'); | |
const root = most.just(true).multicast(); // remove multicast and stream 1 doesn’t throw | |
// STREAM 1 (listens to root) | |
root | |
.forEach(function(value) { | |
document.body.innerHTML += 'first: ' + value + '<br>'; | |
}) |
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
var most = require('most'); | |
var visibility = most.fromEvent('visibilitychange', document) | |
.map(function() { return !document.hidden; }) | |
.startWith(!document.hidden) | |
.multicast(); // removing this will fix sampleWith | |
visibility | |
.forEach(function(value) { | |
document.body.innerHTML += 'first stream: ' + value + '<br>'; |
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
var most = require('most'); | |
var stream = most.just(1); | |
var promise = Promise.resolve(2); | |
var sampledStream = most.just(3); | |
// works when promise(s) come first | |
stream | |
.sample(function() { return [].slice.call(arguments); }, most.fromPromise(promise), sampledStream) | |
.forEach(function(value) { |
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
var most = require('most'); | |
var clicks = most.fromEvent('click', document) | |
.map(function() { return 'click' }) | |
.debounce(200) | |
.startWith('init') | |
.sampleWith(most.periodic(1000)); | |
clicks.forEach(function(value) { document.body.innerHTML += value + '<br>'}); |
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
.scrollable { | |
overflow: auto; | |
} | |
.scrollableWrapper { | |
position: relative; | |
} | |
.scrollableWrapper:before { | |
content: ''; | |
position: absolute; | |
top: 0; |
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 fullText() { | |
var elements = [].slice.call(document.querySelectorAll('[data-full-text]')); | |
elements.forEach(function(element) { | |
var REGEX_NUMBER = /\d+/; | |
var REGEX_NO_NUMBER = /[^\d]+/; | |
element.style.display = "inline"; | |
element.style.fontSize = ''; | |
var width = element.getBoundingClientRect().width; | |
var containerWidth = element.parentNode.getBoundingClientRect().width; | |
var fontSize = getComputedStyle(element).fontSize; |
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
# local PHP Server | |
server() { | |
url="localhost:${2:-8000}" | |
if [ -z "$1" ]; then | |
php -S $url & # run server in background | |
else | |
php -S $url -t $1 & | |
fi | |
sleep 0.3s # wait for server to start |