Last active
December 14, 2015 06:38
-
-
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.
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
(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