@datalayer/core
Version:
**Datalayer Core**
17 lines (16 loc) • 428 B
JavaScript
/*
* Copyright (c) 2023-2025 Datalayer, Inc.
* Distributed under the terms of the Modified BSD License.
*/
export const asArray = (obj) => {
if (Array.isArray(obj)) {
return obj;
}
return [obj];
};
export const shuffleArray = (array) => {
for (let i = array.length - 1; i > 0; i--) {
const j = Math.floor(Math.random() * (i + 1));
[array[i], array[j]] = [array[j], array[i]];
}
};