4.0.0 • Published 3 years ago

array-move v4.0.0

Weekly downloads
184,259
License
MIT
Repository
github
Last release
3 years ago

array-move

Move an array item to a different position

Install

$ npm install array-move

Usage

import {arrayMoveImmutable} from 'array-move';

const input = ['a', 'b', 'c'];

const array1 = arrayMoveImmutable(input, 1, 2);
console.log(array1);
//=> ['a', 'c', 'b']

const array2 = arrayMoveImmutable(input, -1, 0);
console.log(array2);
//=> ['c', 'a', 'b']

const array3 = arrayMoveImmutable(input, -2, -3);
console.log(array3);
//=> ['b', 'a', 'c']

API

arrayMoveImmutable(array, fromIndex, toIndex)

Clones the given array, moves the item to a new position in the new array, and then returns the new array. The given array is not mutated.

arrayMoveMutable(array, fromIndex, toIndex)

Moves the item to the new position in the array array. Useful for huge arrays where absolute performance is needed.

array

Type: Array

fromIndex

Type: number

The index of item to move.

If negative, it will begin that many elements from the end.

toIndex

Type: number

The index of where to move the item.

If negative, it will begin that many elements from the end.

@fairfx/fuji@helpscout/hsds-reacttarnet-jumbo-react@epranka/test-form-schemadesktop-transfer-clientminsilo-react-clientstorybook-addons-playwrighttmaito-icondexi-react-component-library@trevianxyz/messagecenter-uisbw-components-testcdc-maphotee-adminwapl-worksmulti-select-react-component-with-tagslistreact-gallery-uploadersparrow-bird-serversimple-antd-management-fast-frameworkzstack-componentsyis-ceshi@huimei/huimei-designreact-approveme-uicodewing-ui5-htpinst_site_1inst_site_npmdemotestpublish@knapsack/app-uisimple-edit-gridladys-npm-base@everything-registry/sub-chunk-1165react-dashbaordlinkedout-frontlink-hub-liblipc-bpmn-js-properties-panelmusic-raya-botmy-simple-grid-testnmtsmartformsdkmoddler-properties-panelmodo-plugin-commonmario-teacher-student-clientmario-districtminta-studioml-testing-toolkit-uimui-rule-buildermultiselect-component-with-tagsmui-query-builder-bugfixmui-querybuildermicro-page-plugin-presetmicro-page-reactmongeznftrace-form-buildernetlify-cms-widget-filemetacode-readonly-array-settermeix-react-uimeix-uimandarina-antdls-itc-cmsmg-formsmf-tablemaxingkeji-common-reactmayihr-business-componentsmayihr-componentsmayihr-components-mobilemayihr-ldcpmayihr-login-components@toy-box/toybox-lib@therms/atalaya@ubnt/unifi-access-ui@undermuz/react-json-form@undermuz/react-page-builder@usereactify/app@umaker/form@tsri-wepublish/editor@txdfe/at-sortable-select@teft/editor-tools@types/array-move@teamix/pro-dashboard@xonar/form-js-editoraldehydeaipage-editor@zalelion/slides@wm-hosp/sum_react@yingzhi8/lowcode-public-packageamarpanchal-report-publish@zhaofeng-shu33/iceworks-server@whppt/next@zstack-cmp/components@vienne/block_editor@zanyarsun/nx-components@zgfe/modules-dmadmin-templatesah-form-builder-sampleah-formbuilder@x2s/componentsandoncloud-dashboard-toolkitandoncloud-workplaces-status-widget@zalastax/nolb-array-@alwaystudios/as-ui-components@app-garage/image-uploader
4.0.0

3 years ago

3.0.1

4 years ago

3.0.0

4 years ago

2.2.2

4 years ago

2.2.1

4 years ago

2.2.0

4 years ago

2.1.0

5 years ago

2.0.0

5 years ago

1.0.0

9 years ago

0.1.0

9 years ago