1
0
mirror of https://github.com/matrix-org/matrix-js-sdk.git synced 2025-08-18 05:42:00 +03:00

Handle redactions (both live and historic).

This commit is contained in:
Kegan Dougal
2015-07-21 17:14:11 +01:00
parent 6653d294d9
commit 90e778cb84
2 changed files with 24 additions and 2 deletions

View File

@@ -148,6 +148,7 @@ module.exports.findElement = function(array, fn, reverse) {
* function signature <code>fn(element, index, array)</code>. Return true to
* remove this element and break.
* @param {boolean} reverse True to search in reverse order.
* @return True if an element was removed.
*/
module.exports.removeElement = function(array, fn, reverse) {
var i;
@@ -155,17 +156,19 @@ module.exports.removeElement = function(array, fn, reverse) {
for (i = array.length - 1; i >= 0; i--) {
if (fn(array[i], i, array)) {
array.splice(i, 1);
return; }
return true;
}
}
}
else {
for (i = 0; i < array.length; i++) {
if (fn(array[i], i, array)) {
array.splice(i, 1);
return;
return true;
}
}
}
return false;
};
/**