-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Artyom 'Sleepwalker' Fedosov
committed
Feb 17, 2015
1 parent
c7d30b6
commit 6d056c4
Showing
3 changed files
with
14 additions
and
12 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
The MIT License | ||
|
||
Copyright © 2014 Artyom Fedosov <[email protected]> | ||
Copyright © 2015 Artyom Fedosov <[email protected]> | ||
|
||
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 | ||
|
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,20 @@ | ||
/* | ||
* Underscore.ExtendedWhere, v1.0 | ||
* (c) 2014 Artyom "Sleepwalker" Fedosov <[email protected]> | ||
* https://github.com/asleepwalker/underscore.extendedwhere | ||
* Underscore.Excerpt, v1.0.1 | ||
* (c) 2015 Artyom "Sleepwalker" Fedosov <[email protected]> | ||
* 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); | ||
}; | ||
} |