2.6.2, added case-insensitive filtering and edit message error catching

This commit is contained in:
hydrabolt
2015-08-20 15:56:12 +01:00
parent 265d112afc
commit ebd29e6abd
3 changed files with 49 additions and 11 deletions

View File

@@ -153,13 +153,14 @@ exports.List.prototype.concatSublists = function( whereList, discriminator ) {
return concatList;
}
exports.List.prototype.filter = function( key, value, onlyOne ) {
exports.List.prototype.filter = function( key, value, onlyOne, caseInsen ) {
var results = [];
value = change(value);
for ( index in this.contents ) {
var child = this.contents[ index ];
if ( child[ key ] == value ) {
if ( change(child[ key ]) == value ) {
if ( onlyOne ) {
return child;
} else {
@@ -168,6 +169,13 @@ exports.List.prototype.filter = function( key, value, onlyOne ) {
}
}
function change(val){
if(caseInsen){
val = val.toUpperCase();
}
return val;
}
if ( onlyOne ) {
return false;
}
@@ -178,6 +186,7 @@ exports.List.prototype.filter = function( key, value, onlyOne ) {
exports.List.prototype.deepFilter = function( keys, value, onlyOne ) {
var results = [];
value = change(value);
for ( index in this.contents ) {
var child = this.contents[ index ];
@@ -187,7 +196,7 @@ exports.List.prototype.deepFilter = function( keys, value, onlyOne ) {
buffer = buffer[ key ];
}
if ( buffer == value ) {
if ( change(buffer) == value ) {
if ( onlyOne ) {
return child;
} else {
@@ -196,6 +205,13 @@ exports.List.prototype.deepFilter = function( keys, value, onlyOne ) {
}
}
function change(val){
if(caseInsen){
val = val.toUpperCase();
}
return val;
}
if ( onlyOne ) {
return false;
}