UNPKG

@woosh/meep-engine

Version:

Pure JavaScript game engine. Fully featured and production ready.

22 lines (18 loc) 523 B
import { assert } from "../../assert.js"; /** * Swaps two elements in the array * @template T * @param {T[]} array * @param {number} index0 * @param {number} index1 * @returns {void} * @see array_swap */ export function array_swap_one(array, index0, index1) { assert.isArrayLike(array, 'array'); assert.isNonNegativeInteger(index0, 'index0'); assert.isNonNegativeInteger(index1, 'index1'); const t = array[index0]; array[index0] = array[index1]; array[index1] = t; }