Skip to content

Instantly share code, notes, and snippets.

@PaulGiletich
PaulGiletich / intersectRangeArrays.ts
Created Jun 5, 2018
get intersection of 2 arrays of ranges
View intersectRangeArrays.ts
export type Range = [number, number];
export const intersectRangeArrays = (arrA: Range[], arrB: Range[]): Range[] => {
let result = [];
let aLength = arrA.length;
let bLength = arrB.length;
let ai = 0;
@PaulGiletich
PaulGiletich / curry.js
Last active Dec 30, 2015
curry is a function that returns function with first arguments pre-assigned to it. Arguments stored in closure
View curry.js
Function.prototype.curry = function () {
if (arguments.length<1) {
return this;
}
var _this = this;
var _args = Array.prototype.slice.call(arguments);
return function() {
return _this.apply(this, _args.concat(Array.prototype.slice.call(arguments)));
}
}