Last active
December 17, 2015 11:19
-
-
Save neonstalwart/5601465 to your computer and use it in GitHub Desktop.
use SimpleQueryEngine to find the first match in an array
This file contains hidden or 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
define([ | |
'dojo/_base/array', | |
'dojo/store/util/SimpleQueryEngine' | |
], function (array, SimpleQueryEngine) { | |
return function findFirst(arr, query) { | |
var matches = SimpleQueryEngine(query).matches, | |
found; | |
array.some(arr, function (it) { | |
if (matches(it)) { | |
found = it; | |
return true; | |
} | |
}); | |
return found; | |
}; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment