JSPM

@extra-array/swap.min

2.8.43
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 370
  • Score
    100M100P100Q46590F
  • License MIT

Exchanges two values.

Package Exports

  • @extra-array/swap.min

Readme

Exchanges two values. 🏃 📼 📦 🌔 📒

Alternatives: swap, swap$.
This is part of package extra-array.

This is browserified, minified version of @extra-array/swap.
It is exported as global variable array_swap.
CDN: unpkg, jsDelivr.

array.swap(x, i, j);
// x: an array
// i: an index
// j: another index
const array = require('extra-array');

var x = [1, 2, 3, 4];
array.swap(x, 0, 1);
// [ 2, 1, 3, 4 ]

array.swap(x, 0, 3);
// [ 4, 2, 3, 1 ]

references