BetterDiscordApp-v2/client/src/structs/list.js

32 lines
779 B
JavaScript

/*
* BetterDiscord List
* Copyright (c) 2015-present Jiiks/JsSucks - https://github.com/Jiiks / https://github.com/JsSucks
* All rights reserved.
* https://betterdiscord.net
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
/**
* Class representing a list.
* @extends Array
*/
export default class List extends Array {
get(...filters) {
return this.find(item => {
for (const filter of filters) {
for (const key in filter) {
if (filter.hasOwnProperty(key)) {
if (item[key] !== filter[key]) return false;
}
}
}
return true;
});
}
}