@extra-array/swap-update.min

Exchanges two values.

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
@extra-array/swap-update.min
1402.10.197 months ago3 years agoMinified + gzip package size for @extra-array/swap-update.min in KB

Readme

Exchanges two values. :package: :smileycat: :running: :vhs: :moon: :scroll: :newspaper: :bluebook:
Alternatives: swap, swap$.

This is part of package extra-array.

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



array.swap$(x, i, j);
// x: an array (updated)
// i: an index
// j: another index
// → x

const array = require("extra-array");

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

x;
// [ 2, 1, 3, 4 ]

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



References