Skip to content

Instantly share code, notes, and snippets.

var group = function(arr, cb, ctx) {
var buckets = [];
for (var i=0, len=arr.length; i<len; i++) {
if (cb.call(ctx, arr[i], i) || !buckets.length) {
buckets.push([arr[i]]);
} else {
buckets[buckets.length-1].push(arr[i]);
}
}
return buckets;
@xat
xat / gist:9452fcb14e5d8440563a
Created November 7, 2014 19:42
contains.js
var contains = function(arr, cb) {
for (var i=0, len=arr.length; i<len; i++) {
if (cb(arr[i], i)) return true;
}
return false;
};
var last = function(fn, l) {
return function() {
var args = Array.prototype.slice.call(arguments);
args.push(l);
return l = fn.apply(null, args);
};
};

Keybase proof

I hereby claim:

  • I am xat on github.
  • I am xat (https://keybase.io/xat) on keybase.
  • I have a public key whose fingerprint is FAF5 5550 9A02 5279 1FB0 76F3 5B49 2B19 0149 FC24

To claim this, I am signing this object:

const pipeline = (...fns) => (val) => fns.reduce((prom, fn) => prom.then(fn), Promise.resolve(val));
const myPipe = pipeline(
(val) => val + 1,
(val) => val + 1
);
Promise.resolve(1)
.then(myPipe)
.then((result) => {
I am attesting that this GitHub handle xat is linked to the Tezos account tz1P9djZkQKQdvt68eixoyBf8ezNYjgrEdue for tzprofiles
sig:edsigtue5MxmvLyCQsaXQGDNJ5hb3ovPMQjZkK6twewkscXr98ZCGUTN8zHqR9X4wqoZrJg6vy4EffLmipjmcYc9NtEypfSPWGg