See: https://github.com/cujojs/most/tree/v0.10-perf/perf
Representative results run on node 0.11.14, on a 2012 MacBook Pro core i7 2.3ghz w/8g RAM.
See: https://github.com/cujojs/most/tree/v0.10-perf/perf
Representative results run on node 0.11.14, on a 2012 MacBook Pro core i7 2.3ghz w/8g RAM.
| var jiff = require('jiff'); | |
| var p = [{"op":"test","path":"/messages/0","value":{"id":"QJ951IQ-","time":"2014-12-05T02:24:31.880Z","userId":"7yjrlN0x","text":"q","thread":"default","isThread":false,"user":{"name":"chen","avatar":"http://tp1.sinaimg.cn/1651843872/180/40048616024/1","nickname":"chen","thread":"default","id":"7yjrlN0x","online":true}}},{"op":"remove","path":"/messages/0"},{"op":"add","path":"/messages/2","value":{"id":"71D0JL7b","time":"2014-12-05T02:25:33.729Z","userId":"7JHrWpG-","text":"r","thread":"default","isThread":false,"user":{"name":"yong","avatar":"http://tp3.sinaimg.cn/1346257214/50/1269085478/0","nickname":"yong","id":"7JHrWpG-","thread":"default","online":true}}}]; | |
| var d1 = {"messages":[{"id":"QJ951IQ-","time":"2014-12-05T02:24:31.880Z","userId":"7yjrlN0x","text":"q","thread":"default","isThread":false,"user":{"name":"chen","avatar":"http://tp1.sinaimg.cn/1651843872/180/40048616024/1","nickname":"chen","thread":"default","id":"7yjrlN0x","online":true}},{"id":"mJR6kUmW","time":"201 |
| function AbortablePromise(resolver) { | |
| if (typeof resolver !== 'function') | |
| throw new Error('AbortablePromise needs a resolver function'); | |
| var abort; | |
| var promise = new Promise(function (resolve, reject) { | |
| var aborter; | |
| abort = function () { | |
| if (aborter == null) |
| var switchLatest = require('./lib/combinator/switch').switch; | |
| exports.switch = exports.switchLatest = switchLatest; | |
| Stream.prototype.switch = Stream.prototype.switchLatest = function() { | |
| return switchLatest(this); | |
| }; |
| module.exports = clone; | |
| function clone(x) { | |
| if(x == null || typeof x !== 'object') { | |
| return x; | |
| } | |
| if(Array.isArray(x)) { | |
| return cloneArray(x); | |
| } |
| var most = require('../../most'); | |
| //var n = 0; | |
| //var n = 1; | |
| var n = 2; | |
| var s = most.of(1).flatMap(function() { | |
| return most.periodic(1000); | |
| }).take(n); |
| var most = require('../../most'); | |
| var n = 0; | |
| //var n = 1; | |
| //var n = 2; | |
| var s = most.periodic(1000).take(n); | |
| s.observe(function(x) { | |
| console.log(x); |
| // Dropping sparse array support makes this code much simpler | |
| function reduce(promises, f) { | |
| var hasArg = arguments.length > 2; | |
| if((promises.length>>>0) === 0) { | |
| return hasArg ? when.promise(arguments[2]) : when.reject(new TypeError('Cannot reduce empty array with no initial value')); | |
| } | |
| return hasArg ? runReduce(0, promises, f, arguments[2]) | |
| : runReduce(1, promises, f, promises[0]); | |
| } |
| var when = require('../../../when'); | |
| var a = []; | |
| for(var i=0; i<1000000; ++i) { | |
| a[i] = when.resolve(i); | |
| } | |
| var start = Date.now(); | |
| when.reduce(a, add, 0).done(function(r) { | |
| //when.reduceRight(a, add, 0).done(function(r) { |
| var when = require('../../../when'); | |
| var a = []; | |
| for(var i=0; i<1000000; ++i) { | |
| a[i] = when.resolve(i); | |
| } | |
| var start = Date.now(); | |
| when.map(a, function(x) { | |
| return add(x, 1); |