Comparing version 2.7.1 to 2.8.0
{ | ||
"name": "rjs", | ||
"version": "2.7.1", | ||
"version": "2.8.0", | ||
"description": "A library of Javascript utility functions with an emphasis on Functional Programming.", | ||
@@ -5,0 +5,0 @@ "main": "rjs.js", |
@@ -10,10 +10,28 @@ A library of Javascript utility functions with an emphasis on Functional Programming. | ||
<!-- Prototypes the functions onto the appropriate native objects (OPTIONAL) --> | ||
<script type="text/javascript" src="rjs-proto.js"></script> | ||
## Node Land | ||
RJS = require("./rjs"); | ||
require("./rjs-proto"); // optional | ||
# Prototyping Onto Native Objects | ||
While controversial, prototyping functions onto native objects can result in far more elegant code than doing otherwise. | ||
The majority of the functions in RJS center around native types like String, Number, Array, and Function, making them | ||
perfect candidates for prototyping. Nothing is prototyped onto Object. | ||
Adding RJS functions to native objects is off by default. To opt-in, call RJS.installPrototypes: | ||
RJS.installPrototypes(); | ||
Now instead of writing awkward code like this: | ||
RJS.map(people, function(person) { | ||
return RJS.supplant("Hello {0}!", [person.name]); | ||
}); | ||
We can write elegant, intuitive code like this: | ||
people.map(function() { | ||
return "Hello {0}!".supplant([person.name]); | ||
}); | ||
# Unit Tests | ||
@@ -20,0 +38,0 @@ test/index.html |
27
rjs.js
/** | ||
* Raine's Javascript Extensions | ||
* v2.7.1 | ||
* v2.8.0 | ||
* A library of Javascript utility functions with an emphasis on Functional Programming. | ||
@@ -105,3 +105,2 @@ */ | ||
/*********************************** | ||
@@ -793,3 +792,20 @@ * String | ||
// export public interface | ||
/*********************************** | ||
* Prototype Installation | ||
***********************************/ | ||
var installPrototypes = function(rjs) { | ||
var rjs = rjs || RJS; | ||
install(String, rjs, ["supplant", "trim", "startsWith", "before", "after", "between", { repeatString: "repeat" }, "toTitleCase", { strContains: "contains" } ]); | ||
install(Number, rjs, ["ordinal", { mapNumber: "map" }]); | ||
install(Array, rjs, ["map", "each", "pluck", "group", "orderedGroup", "tally", "contains", "strictContains", "unique", "reversed", "index", "rotate", "toObject", "find", "findByProperty", "filterBy", "any", "all" ]); | ||
install(Function, rjs, ["curry", "currify", "toInstance", "new"]); | ||
}; | ||
/*********************************** | ||
* Export Public Interface | ||
***********************************/ | ||
return { | ||
@@ -867,3 +883,6 @@ | ||
"new" : createNew, | ||
callAfterDone : callAfterDone | ||
callAfterDone : callAfterDone, | ||
// prototype installation | ||
installPrototypes : installPrototypes | ||
}; | ||
@@ -870,0 +889,0 @@ |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
450306
29
10625
232