Skip to content

Instantly share code, notes, and snippets.

@ozbe
Last active December 14, 2015 06:38
Show Gist options
  • Save ozbe/5043757 to your computer and use it in GitHub Desktop.
Save ozbe/5043757 to your computer and use it in GitHub Desktop.
Alias linq.js (http://linqjs.codeplex.com) prototype functions to lower camel case.
(function (Enumerable) {
"use strict";
var mediator = function (methodName) {
return function () {
return Enumerable.prototype[methodName].apply(this, arguments);
};
};
for (var propertyName in Enumerable.prototype) {
if (!Enumerable.prototype[propertyName].apply) {
continue;
}
var alias = propertyName.charAt(0).toLowerCase() + propertyName.slice(1);
Enumerable.prototype[alias] = mediator(propertyName);
}
})(Enumerable);
// Example
//console.log(Enumerable.From([1, 2]).sum());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment