mirror of
https://github.com/react/react-native-devtools-frontend.git
synced 2026-10-05 11:31:31 +08:00
DISABLE_THIRD_PARTY_CHECK=new npm module causes package-lock change We can get rid of a custom script and use ESLint for these rules. Additionally this means editors will highlight the issue in the editor. Change-Id: I552b52e7f07b4e7430b3f685dbc3b5fad36ffff2 Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/2052167 Reviewed-by: Paul Lewis <aerotwist@chromium.org> Commit-Queue: Jack Franklin <jacktfranklin@chromium.org>
30 lines
1.2 KiB
JavaScript
30 lines
1.2 KiB
JavaScript
import _curry3 from './internal/_curry3.js';
|
|
|
|
/**
|
|
* Move an item, at index `from`, to index `to`, in a list of elements.
|
|
* A new list will be created containing the new elements order.
|
|
*
|
|
* @func
|
|
* @memberOf R
|
|
* @category List
|
|
* @sig Number -> Number -> [a] -> [a]
|
|
* @param {Number} from The source index
|
|
* @param {Number} to The destination index
|
|
* @param {Array} list The list which will serve to realise the move
|
|
* @return {Array} The new list reordered
|
|
* @example
|
|
*
|
|
* R.move(0, 2, ['a', 'b', 'c', 'd', 'e', 'f']); //=> ['b', 'c', 'a', 'd', 'e', 'f']
|
|
* R.move(-1, 0, ['a', 'b', 'c', 'd', 'e', 'f']); //=> ['f', 'a', 'b', 'c', 'd', 'e'] list rotation
|
|
*/
|
|
var move = /*#__PURE__*/_curry3(function (from, to, list) {
|
|
var length = list.length;
|
|
var result = list.slice();
|
|
var positiveFrom = from < 0 ? length + from : from;
|
|
var positiveTo = to < 0 ? length + to : to;
|
|
var item = result.splice(positiveFrom, 1);
|
|
|
|
return positiveFrom < 0 || positiveFrom >= list.length || positiveTo < 0 || positiveTo >= list.length ? list : [].concat(result.slice(0, positiveTo)).concat(item).concat(result.slice(positiveTo, list.length));
|
|
});
|
|
|
|
export default move; |