Created
May 4, 2012 17:20
-
-
Save gmoeck/2596336 to your computer and use it in GitHub Desktop.
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
var matchersForFilter = function(properties) { | |
var attributes = util.keys(properties); | |
var attributesFilters = util.values(properties); | |
var arraysWithAttributeAndAttributesFilters = util.zip(attributes, | |
attributesFilters); | |
var arrayOfMatchersForAttribute = | |
util.map(arraysWithAttributeAndAttributesFilters, matchersForAttribute); | |
var matchers = util.flatten(arrayOfMatchersForAttribute, true); | |
return matchers; | |
}; | |
var matchersForAttribute = function(arrayWithAttributeAndFilters) { | |
var attribute = arrayWithAttributeAndFilters[0]; | |
var filtersForAttribute = arrayWithAttributeAndFilters[1]; | |
var types = util.keys(filtersForAttribute); | |
var values = util.values(filtersForAttribute); | |
var arraysWithTypeAndValue = util.zip(types, values); | |
var matchers = util.map(util.bind(matcherForTypeAndValue, this, attribute)); | |
return matchers; | |
}; | |
var matcherForTypeAndValue = function(attribute, arrayWithTypeAndValue) { | |
return { | |
type: arrayWithTypeAndValue[0], | |
attribute: attribute, | |
value: arrayWithTypeAndValue[1] | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment