This file contains hidden or 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 Ix = require('ix'), | |
Rx = require('rx'), | |
Enumerable = Ix.Enumerable, | |
Enumerator = Ix.Enumerator, | |
Observable = Rx.Observable; | |
Observable.permute = function(root, hasPermutation, resultSelector) { | |
return Observable | |
.returnValue({ value: root, depth: -1 }) | |
.expandRecursive(function(wrapper) { |
This file contains hidden or 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
macro flatMapVars { rule { } => { } } | |
macro concatVars { rule { } => { } } | |
macro flatMapCond { rule { } => { true } } | |
macro concatsCond { rule { } => { true } } | |
macro concatBlocks { rule { } => { } } | |
// wrapArgs(x, i, a) .foo(function (y, j, b) { return y + 1; }) ... ; | |
macro wrapArgs { | |
function(stxs, context) { | |
var name_stx = stxs[0]; |
This file contains hidden or 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
/* output: | |
legend: | |
current: Scheduled concurrently by the CurrentThread scheduler. | |
recursive: Scheduled recursively by the Immediate scheduler. | |
setTimeout: Scheduled asynchronously by the Timeout scheduler. | |
blocking-current: Scheduled to block concurrently by the CurrentThread scheduler. | |
blocking-recursive: Scheduled to block recursively by the Immediate scheduler. | |
setTimeout a 0 | |
setTimeout b 0 |
This file contains hidden or 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
/*output*//* | |
var foo = 'd', bar = 'e'; | |
console.log('a', 'b', 'c', foo, bar); | |
console.log('a', 'b', 'c', foo, 2, 3, 4, 5); | |
console.log('a', 'c', 'b'); | |
console.log('a', 'd', 'b', 'f', 'e', 'g', foo); | |
function veryLongFunction() { | |
console.log.apply(console, arguments); | |
} | |
veryLongFunction('a', 'b', 'c', 'd', 'e', 'f'); |
This file contains hidden or 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
/* output *//* | |
var result; | |
var acc = 1, x = 10; | |
while (true) { | |
if (x <= 1) { | |
// non-recursive return invocations aren't rewritten | |
acc = log(acc); | |
break; | |
} else { | |
acc = acc * x; |
This file contains hidden or 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 noop = require("rx/support/noop"); | |
var try_catch = require("rx/support/try-catch"); | |
var flatten_args = require("rx/support/arguments-flatten"); | |
var errorObj = require("rx/support/error-object"); | |
function Generator(destinationOrNext, _throw, _return) { | |
if(destinationOrNext && typeof destinationOrNext === "object") { | |
this.result = destinationOrNext.result || { done: false }; | |
this.destination = destinationOrNext; | |
} else { |
This file contains hidden or 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
old fromArray with immediate scheduler x 129,353 ops/sec ±1.57% (91 runs sampled) | |
new fromArray with immediate scheduler x 475,989 ops/sec ±1.18% (82 runs sampled) | |
267.98% faster than Rx | |
old from (array) with immediate scheduler x 116,648 ops/sec ±2.21% (81 runs sampled) | |
new from (array) with immediate scheduler x 689,305 ops/sec ±4.35% (88 runs sampled) | |
490.93% faster than Rx | |
old from (array) with immediate scheduler x 68,486 ops/sec ±1.60% (88 runs sampled) | |
new from (array) with immediate scheduler x 983,076 ops/sec ±3.37% (85 runs sampled) |
This file contains hidden or 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 isArray = Array.isArray; | |
var iterateKeySet = require("falcor-path-utils").iterateKeySet; | |
// module.exports = getJSON; | |
// debugger; | |
var paths = [ | |
['list', 'selected', 'name'], | |
['list', [0, 1, 3, 5], 'name'], | |
['list', 5, 'name'], |
This file contains hidden or 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 Rx = require('rxjs/Rx.KitchenSink'); | |
var toSubscriber = require('rxjs/util/toSubscriber').toSubscriber; | |
Rx.Observable.prototype.subscribe = newSubscribe; | |
var source = Rx.Observable.create(function (subscriber) { | |
subscriber.next('foo'); | |
subscriber.complete(); | |
return function() { | |
console.log('source unsubscribed'); |
This file contains hidden or 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 Rx = require('rxjs'); | |
var shared = new Rx.Subject(); | |
var source = Rx.Observable | |
.never() | |
.finally(console.log.bind(console, "unsubscribe")) | |
.multicast(shared) | |
.refCount(); | |
source.subscribe(null, null, console.log.bind(console, "1. done")); |