Skip to content

Instantly share code, notes, and snippets.

💭
(╯°□°)╯︵ ┻━┻

Ingvar Stepanyan RReverser

💭
(╯°□°)╯︵ ┻━┻
Block or report user

Report or block RReverser

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@RReverser
RReverser / promise-tree.js
Created Apr 17, 2014
Promise Tree traversal
View promise-tree.js
function when(value, func) {
var promise = Promise.cast(value);
if (func) {
promise = promise.then(function (value) {
return Promise.cast(func(value)).then(function (newValue) {
return newValue === undefined ? value : newValue;
});
});
}
View data-emitters.md
feature Promises streams generators
asynchronous
(can push from inner callbacks)
true true false
multiple push false true true
error catch true false false
error forwarding true false true
external dependency is a must false true false
View ObservableStream.js
var stream = require('stream');
var Rx = require('rx');
var util = require('util');
function ObservableStream(transform) {
stream.Duplex.call(this, {objectMode: true});
this.subject = new Rx.Subject();
this.observable = transform(this.subject);
this.subscription = null;
@RReverser
RReverser / index.js
Created Jul 29, 2014
requirebin sketch
View index.js
// just for RequireBin
console.log = function () {
var pre = document.createElement('pre');
pre.textContent = Array.prototype.map.call(arguments, function (arg) {
return typeof arg === 'object' ? JSON.stringify(arg, null, 2) : arg;
}).join(' ');
document.body.appendChild(pre);
};
var esprima = require('esprima-fb'), ast;
View gist:3463103840d0706aa80d
function Template(str, data) {
return str.replace(/\${([^}]+)}/g, (_, name) => data[name]);
}
var answer = 42;
(function () {
var answer = 60;
console.log(Template('Answer is ${answer}', {answer}));
})();
View gist:24da7556d656e34a2ab4
### Keybase proof
I hereby claim:
* I am RReverser on github.
* I am rreverser (https://keybase.io/rreverser) on keybase.
* I have a public key whose fingerprint is 3456 B5A0 0E7F 67D8 A049 5B85 7634 8879 1722 011A
To claim this, I am signing this object:
@RReverser
RReverser / es6-intrinsic.js
Created Jun 14, 2015
ES6 spec: 6.1.7.4 Well-Known Intrinsic Objects
View es6-intrinsic.js
/*
The MIT License (MIT)
Copyright (c) 2015 Ingvar Stepanyan
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
@RReverser
RReverser / index.js
Last active Sep 6, 2015
jsunderhood tutorial
View index.js
#!/usr/bin/env node
var fs = require('fs');
var acorn = require('./parser');
var transform = require('./transform');
var escodegen = require('escodegen');
var filename = process.argv[2];
if (!filename) {
console.log('Usage: transpile filename.js');
View asyncContext.js
var createChain = function (ops) {
var chain = function () {};
chain.__asyncOps = ops;
return new Proxy(chain, AsyncContextHandler);
};
function AsyncAccessError() {
TypeError.call(this, 'Can\'t perform synchronous operation on remote object.');
}
View awaitable.js
function awaitableVersionOf(nodeFunction) {
return (...args) => new Promise((resolve, reject) => {
nodeFunction(
...args,
(error, ...cbArgs) => error ? reject(error) : resolve(...cbArgs)
);
});
}
You can’t perform that action at this time.