We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 56a7f9d commit f70f9d1Copy full SHA for f70f9d1
packages/runtime-vapor/__tests__/_utils.ts
@@ -135,3 +135,21 @@ export function makeInteropRender(): (comp: Component) => InteropRenderContext {
135
136
return define
137
}
138
+
139
+export function shuffle(array: Array<any>): any[] {
140
+ let currentIndex = array.length
141
+ let temporaryValue
142
+ let randomIndex
143
144
+ // while there remain elements to shuffle...
145
+ while (currentIndex !== 0) {
146
+ // pick a remaining element...
147
+ randomIndex = Math.floor(Math.random() * currentIndex)
148
+ currentIndex -= 1
149
+ // and swap it with the current element.
150
+ temporaryValue = array[currentIndex]
151
+ array[currentIndex] = array[randomIndex]
152
+ array[randomIndex] = temporaryValue
153
+ }
154
+ return array
155
+}
0 commit comments