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
// => The Suman config file; should always remain at the root of your project | |
// => If transpile is true, Suman will put your babel deps in ~/.suman/node_modules | |
// => When you first install Suman, Suman will write a directory called "suman" to your project root, | |
// it is best practice to simply move the "suman" directory inside your "test" directory, | |
// when you move the "suman" directory, you must update the "sumanHelpersDir" property below to reflect the path | |
// from the project root to the "sumanHelpersDir" | |
// suman.conf.js uses some core utilities, you can change this logic at will |
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 Rx = require('rx-lite'); | |
const values = [1, 2, 3]; | |
const obs = Rx.Observable.from(values); | |
obs.subscribe( | |
function onNext(result) { | |
console.log('item =>', result); |
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
// enqueues 1 or more items, accepting a string or an array of strings | |
enq(lines: string | Array<string>, opts: IEnqueueOpts): Observable<any> { | |
opts = opts || {}; | |
if (opts.controlled) { | |
return this._enqControlled(lines, opts); | |
} |
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
//import RxJS5 | |
const Rx = require('rxjs'); | |
// create an observable | |
// An observable is: "just a function that takes a subscriber and returns a function" | |
const obs = Rx.Observable.create(sub => { | |
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
// asynchronous constructor example, | |
// like always do not explictly return anything from the constructor | |
function Queue(){ | |
this.ready = false; | |
let callable = true; | |
let ee = new EE(); // new event emitter |
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
// import opq | |
const Queue = require('opq'); | |
// below we create a new client to the queue, | |
// and create the queue on the filesystem if it does | |
// not exist. the port is used by Live-Mutex; | |
// fp is our queue filepath | |
const q = new Queue({ |
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 Rx = require('rxjs'); | |
console.log(1); | |
new Promise(function(resolve,reject){ | |
console.log(2); | |
resolve(); | |
}); |
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
console.log(1); | |
new Promise(function(resolve,reject){ | |
console.log(2); | |
resolve(); | |
}).then(function(val){ | |
console.log(3); | |
}); |
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 {Observable} = require('rxjs'); | |
function makeObs(){ | |
const obs = Observable.create(sub => { | |
setTimeout(() => { | |
sub.next(3); | |
},500); | |
}); |
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 stream = require('stream'); | |
function getReadableStream(fn) { | |
return new stream.Readable({ | |
objectMode: true, |