UNPKG

typescript-array-utils

Version:
14 lines (13 loc) 471 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); function move(a, from, to) { var element = a[from]; var forward = from < to; var head = a.slice(0, forward ? from : to); var mid = a.slice(forward ? from + 1 : to, forward ? to + 1 : from); var tail = a.slice(forward ? to + 1 : from + 1); return forward ? [].concat(head, mid, element, tail) : [].concat(head, element, mid, tail); } exports.move = move;