Permalink
Browse files

add path, and LICENCE

  • Loading branch information...
1 parent 6431c08 commit 22b767b444c8f1f3b8d1b18c47806a7c942036cf @dominictarr committed Oct 29, 2011
Showing with 91 additions and 0 deletions.
  1. +22 −0 LICENCE
  2. +60 −0 functions.js
  3. +9 −0 objects.js
View
22 LICENCE
@@ -0,0 +1,22 @@
+Copyright (c) 2011 Dominic Tarr
+
+Permission is hereby granted, free of charge,
+to any person obtaining a copy of this software and
+associated documentation files (the "Software"), to
+deal in the Software without restriction, including
+without limitation the rights to use, copy, modify,
+merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom
+the Software is furnished to do so,
+subject to the following conditions:
+
+The above copyright notice and this permission notice
+shall be included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
+ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
View
@@ -150,3 +150,63 @@ var defer =
return deferrer
}
+
+
+/*
+ curryHead(func, tail...)
+ -> function (head) { return func(head, tail...) }
+ given a function and tail args,
+ return a function that takes a head arg,
+ and applys head.concat(tail) to the given function
+
+*/
+
+var curryTail =
+ exports.curryTail = function (func) {
+ var args = [].slice.call(arguments, 1)
+ if(!args.length) return func
+ return function (a) {
+ return func.apply(this, [a].concat(args))
+ }
+ }
+
+/*
+ curryHead(func, head)
+ -> function (tail...) { return func(head, tail...) }
+
+ given a function and head arg,
+ return a function that takes tail args,
+ and calls the given function with head.concat(tail)
+*/
+
+var curryHead =
+ exports.curryHead = function (func, a) {
+ return function () {
+ var args = [].slice.call(arguments)
+ return func.apply(this, [a].concat(args))
+ }
+ }
+
+/*
+ curryTailHead
+
+ take a given function and return a function that takes tail args,
+ and returns a function that takes a head arg,
+ and that calls the given function with head.concat(tail)
+
+ you are certainly deep down the rabit hole when you are using functional composition on curry functions
+
+ this is actually gonna be useful for making spec assertions -- with higer order assertions.
+
+ so that you can say
+ equal(x, X)
+
+ with:
+
+ _equal(X)(x)
+
+*/
+
+var curryTailHead = exports.curryTailHead = function (funx) {
+ return curryHead (curryTail, funx)
+}
View
@@ -200,5 +200,14 @@ deepMerge = exports.deepMerge = function (old, nw) {
})
return s
+}
+
+var path = exports.path = function (object, path) {
+ for (var i in path) {
+ if(object == null) return undefined
+ var key = path[i]
+ object = object[key]
+ }
+ return object
}

0 comments on commit 22b767b

Please sign in to comment.