From 700ce314701fde559e807f09ac6d40a1ef60b5c2 Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Mon, 5 Jun 2023 11:43:45 +0200 Subject: Add another function to common code library. --- public/common/util.js | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'public') diff --git a/public/common/util.js b/public/common/util.js index 0edaf2a..0f6fc44 100644 --- a/public/common/util.js +++ b/public/common/util.js @@ -99,6 +99,13 @@ function array_remove(array, index) { array.length = n - 1 } +function array_remove_item(array, item) { + let n = array.length + for (let i = 0; i < n; ++i) + if (array[i] === item) + return array_remove(array, i) +} + function array_insert(array, index, item) { for (let i = array.length; i > index; --i) array[i] = array[i - 1] -- cgit v1.2.3