UNPKG

@datalayer/core

Version:
17 lines (16 loc) 428 B
/* * 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]]; } };