Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Make gtl.curry specs green

  • Loading branch information...
commit 892e22c0304d4a34d4d725f12f7feadb457228f4 1 parent 6660d58
@kossnocorp authored
Showing with 30 additions and 3 deletions.
  1. +30 −3 src/gtl.coffee
View
33 src/gtl.coffee
@@ -23,6 +23,21 @@ gtl = {}
clone = (array) -> array.slice()
###
+ Internal: merge objects
+###
+merge = (a = {}, b = {}) ->
+ result = {}
+
+ copyPropsToResult = (obj) ->
+ for own key, value of obj
+ result[key] = value
+
+ copyPropsToResult(a)
+ copyPropsToResult(b)
+
+ result
+
+###
Internal: get element by path
###
getByPath = (obj, path) ->
@@ -166,9 +181,21 @@ gtl.rules.fuzzy = (str, searchStr) ->
###
Public: curry function
###
-gtl.curry = (curriedRules) ->
- (array, rules) ->
- gtl.filter(array, curriedRules)
+gtl.curry = (curriedRules, curriedIterator) ->
+ (array, userRules, userIterator = curriedIterator) ->
+ if userRules and userRules.constructor == Function
+ rules = curriedRules
+ iterator = userRules
+ else
+ rules = merge(curriedRules, userRules)
+ iterator = userIterator
+
+ gtl.filter(array, rules, iterator)
+
+###
+ Public: clone gtl object
+###
+gtl.clone = ->
# Export gtl to global scope
if window?
Please sign in to comment.
Something went wrong with that request. Please try again.