Skip to content

Instantly share code, notes, and snippets.

@neonstalwart
Last active December 17, 2015 11:19
Show Gist options
  • Save neonstalwart/5601465 to your computer and use it in GitHub Desktop.
Save neonstalwart/5601465 to your computer and use it in GitHub Desktop.
use SimpleQueryEngine to find the first match in an array
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