mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-12 01:23:31 +01:00
filter list change
This commit is contained in:
26
lib/list.js
26
lib/list.js
@@ -156,11 +156,11 @@ exports.List.prototype.concatSublists = function( whereList, discriminator ) {
|
||||
exports.List.prototype.filter = function( key, value, onlyOne, caseInsen ) {
|
||||
|
||||
var results = [];
|
||||
value = change(value);
|
||||
value = change( value );
|
||||
|
||||
for ( index in this.contents ) {
|
||||
var child = this.contents[ index ];
|
||||
if ( change(child[ key ]) == value ) {
|
||||
if ( change( child[ key ] ) == value ) {
|
||||
if ( onlyOne ) {
|
||||
return child;
|
||||
} else {
|
||||
@@ -169,8 +169,8 @@ exports.List.prototype.filter = function( key, value, onlyOne, caseInsen ) {
|
||||
}
|
||||
}
|
||||
|
||||
function change(val){
|
||||
if(caseInsen){
|
||||
function change( val ) {
|
||||
if ( caseInsen ) {
|
||||
val = val.toUpperCase();
|
||||
}
|
||||
return val;
|
||||
@@ -180,13 +180,16 @@ exports.List.prototype.filter = function( key, value, onlyOne, caseInsen ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return results;
|
||||
var retList = new List( this.discriminator );
|
||||
retList.contents = results;
|
||||
|
||||
return retList;
|
||||
}
|
||||
|
||||
exports.List.prototype.deepFilter = function( keys, value, onlyOne ) {
|
||||
|
||||
var results = [];
|
||||
value = change(value);
|
||||
value = change( value );
|
||||
|
||||
for ( index in this.contents ) {
|
||||
var child = this.contents[ index ];
|
||||
@@ -196,7 +199,7 @@ exports.List.prototype.deepFilter = function( keys, value, onlyOne ) {
|
||||
buffer = buffer[ key ];
|
||||
}
|
||||
|
||||
if ( change(buffer) == value ) {
|
||||
if ( change( buffer ) == value ) {
|
||||
if ( onlyOne ) {
|
||||
return child;
|
||||
} else {
|
||||
@@ -205,8 +208,8 @@ exports.List.prototype.deepFilter = function( keys, value, onlyOne ) {
|
||||
}
|
||||
}
|
||||
|
||||
function change(val){
|
||||
if(caseInsen){
|
||||
function change( val ) {
|
||||
if ( caseInsen ) {
|
||||
val = val.toUpperCase();
|
||||
}
|
||||
return val;
|
||||
@@ -215,6 +218,9 @@ exports.List.prototype.deepFilter = function( keys, value, onlyOne ) {
|
||||
if ( onlyOne ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
var retList = new List( this.discriminator );
|
||||
retList.contents = results;
|
||||
|
||||
return results;
|
||||
return retList;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user