diff --git a/LICENSE b/LICENSE index a64943f..f366d8a 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ The MIT License -Copyright © 2014 Artyom Fedosov +Copyright © 2015 Artyom Fedosov 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 diff --git a/README.md b/README.md index af0c435..e0896ad 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,9 @@ -#Underscore.ExtendedWhere +#Underscore.Excerpt -Smarter select from [Underscore.js][] and [Backbone.js][] collections. +Smarter select query from [Underscore.js][] and [Backbone.js][] collections. ``` -var kitties = felids.extendedWhere({ +var kitties = felids.excerpt({ species: 'cat', aggressive: {'operator': '==', value: false}, // Has not remarks ageInDays: {'operator': '<', value: 50} diff --git a/underscore.extendedwhere.js b/underscore.excerpt.js similarity index 71% rename from underscore.extendedwhere.js rename to underscore.excerpt.js index 9a99019..7c35975 100644 --- a/underscore.extendedwhere.js +++ b/underscore.excerpt.js @@ -1,18 +1,20 @@ /* -* Underscore.ExtendedWhere, v1.0 -* (c) 2014 Artyom "Sleepwalker" Fedosov -* https://github.com/asleepwalker/underscore.extendedwhere +* Underscore.Excerpt, v1.0.1 +* (c) 2015 Artyom "Sleepwalker" Fedosov +* https://github.com/asleepwalker/underscore.excerpt */ -_.extendedWhere = function(list, attrs, after) { +_.excerpt = function(list, attrs, after) { var direct = {}, expressions = {}, matched = []; for (var key in attrs) { - if (_.has(attrs[key], 'operator') && _.has(attrs[key], 'value')) + if (_.has(attrs[key], 'operator') && _.has(attrs[key], 'value')) { expressions[key] = attrs[key]; - else direct[key] = attrs[key]; + } else { + direct[key] = attrs[key]; + } } matched = list.where(direct); @@ -35,7 +37,7 @@ _.extendedWhere = function(list, attrs, after) { }; if (Backbone) { - Backbone.Collection.prototype.extendedWhere = function(attrs, after) { - return _.extendedWhere(this, attrs, after); + Backbone.Collection.prototype.excerpt = function(attrs, after) { + return _.excerpt(this, attrs, after); }; } \ No newline at end of file