1.0.2 • Published 4 years ago

@bemoje/arr-swap v1.0.2

Weekly downloads
1
License
MIT
Repository
github
Last release
4 years ago

@bemoje/arr-swap

Swap array elements in place. Runtime: O(1)

Version

Travis CI

Dependencies

Stats

Donate

Installation

npm install @bemoje/arr-swap
npm install --save @bemoje/arr-swap
npm install --save-dev @bemoje/arr-swap

Usage

import arrSwap from '@bemoje/arr-swap'

const arr = [10, 20]

arrSwap(arr, 0, 1)

console.log(arr)
//=> [20, 10]

Tests

Uses Jest to test module functionality. Run tests to get coverage details.

npm run test

API

arrSwap

Swap array elements in place. Runtime: O(1)

Parameters
  • arr array to be modified

  • from number index of the first element

  • to number index of the 2nd element

Returns

void