repo.or.cz
/
ProtonMail-WebClient.git
/
blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
log
|
graphiclog1
|
graphiclog2
|
commit
|
commitdiff
|
tree
|
refs
|
edit
|
fork
blame
|
history
|
raw
|
HEAD
Cleanup - unused files / unused exports / duplicate exports
[ProtonMail-WebClient.git]
/
packages
/
utils
/
remove.ts
blob
13058d3f502201bcfeadca539be9016dea556528
1
/**
2
* Remove the first occurrence of an item from an array. Return a copy of the updated array
3
*/
4
const remove = <T>(arr: T[], item: T) => {
5
const i = arr.indexOf(item);
6
if (i === -1) {
7
return arr;
8
}
9
const result = arr.slice();
10
result.splice(i, 1);
11
return result;
12
};
13
14
export default remove;