diff options
author | Tor Andersson <tor@ccxvii.net> | 2023-06-05 11:43:45 +0200 |
---|---|---|
committer | Tor Andersson <tor@ccxvii.net> | 2023-06-05 11:45:21 +0200 |
commit | 700ce314701fde559e807f09ac6d40a1ef60b5c2 (patch) | |
tree | aad46f79f5e55d3fbc5b8a55dfe1def2a6227869 /public | |
parent | ab74f660dd0301995d2b71be27e89764e1ee4b5e (diff) | |
download | server-700ce314701fde559e807f09ac6d40a1ef60b5c2.tar.gz |
Add another function to common code library.
Diffstat (limited to 'public')
-rw-r--r-- | public/common/util.js | 7 |
1 files changed, 7 insertions, 0 deletions
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] |