made with esnextbin
made with esnextbin
import most from 'most' | |
const add1 = x => x + 1 | |
const even = x => x % 2 === 0 | |
const sum = (x, y) => x + y | |
const newArray = n => { | |
const a = new Array(n) | |
for (let i = 0; i < n; ++i) { | |
a[i] = i |
|====\____/====/============\=/===========|================|
| | ____ |/ ____//| |
| | | | | //_____|_____| |_____|
| |\==/| | | | |______ \\ | |
| | \/ | | \==/ | \\/ // | |
|____| |____|____________|___________// |____|
made with esnextbin
import { Stream, observe, periodic } from '../most' | |
import defaultScheduler from '../lib/scheduler/defaultScheduler' | |
const proxy = () => { | |
const source = new Source() | |
return { | |
imitate: stream => imitateStream(stream, source), | |
stream: new Stream(source) | |
} | |
} |
made with esnextbin
This is an explanation of the extremely subtle problem in this most.js issue. This solution described isn't necessarily the best, or most rigorous solution. We're investigating other potential solutions, but wanted to record this information in case it's interesting to someone.
One of the fastest ways to schedule a task in ES6 is to use a promise. They tend to use the fastest micro-tick scheduling option the platform provides. So, when a task is scheduled with scheduler.asap it doesn’t use setTimeout 0, it uses a promise to schedule itself, because that’s basically as close to zero-time as you can get in a platform independent way
given this:
made with esnextbin
Needs a description, and a meaningful example ...
import { merge } from 'most'
// race :: Stream a -> Stream a -> Stream a
// return a stream that imitates the input stream with
// the earliest first event
const race = (s1, s2) =>
merge(mapToSelf(s1), mapToSelf(s2)).take(1).join()