@woosh/meep-engine
Version:
Pure JavaScript game engine. Fully featured and production ready.
26 lines (21 loc) • 617 B
JavaScript
/**
* @template T
* @param {T[]|ArrayLike<T>|TypedArray|Uint8ClampedArray|Uint8Array|Uint32Array|Float32Array} a
* @param {number} a_offset
* @param {T[]|ArrayLike<T>|TypedArray|Uint8ClampedArray|Uint8Array|Uint32Array|Float32Array} b
* @param {number} b_offset
* @param {number} length How many elements should be moved
*/
export function array_swap(
a, a_offset,
b, b_offset,
length
) {
for (let k = 0; k < length; k++) {
const i = a_offset + k;
const j = b_offset + k;
const swap = b[j];
b[j] = a[i];
a[i] = swap;
}
}