MCPcopy Create free account
hub / github.com/LearnPrompt/LearnPrompt / toggleListItem

Function toggleListItem

src/utils/jsUtils.ts:13–22  ·  view source on GitHub ↗
(list: T[], item: T)

Source from the content-addressed store, hash-verified

11}
12
13export function toggleListItem<T>(list: T[], item: T): T[] {
14 const itemIndex = list.indexOf(item)
15 if (itemIndex === -1) {
16 return list.concat(item)
17 } else {
18 const newList = [...list]
19 newList.splice(itemIndex, 1)
20 return newList
21 }
22}
23
24export function shuffle(arr) {
25 let i = arr.length

Callers 1

index.tsxFile · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected