@extra-array/insert-update

2.1.75 • Public • Published

Inserts a value to an ordered array.

This is part of package extra-array.

array.insert$(x, v, [fn]);
// x:  an array (updated)
// v:  value to insert
// fn: compare function (a, b)
// --> x
const array = require('extra-array');

var a = [1, 7, 8, 10];
array.insert$(a, 5);
// [1, 5, 7, 8, 10]

a;
// [1, 5, 7, 8, 10]

var b = ['a', 'K', 'M', 'n'];
array.insert$(b, 'l', (a, b) => a.toLowerCase().localeCompare(b.toLowerCase()));
// ['a', 'K', 'l', 'M', 'n'];

b;
// ['a', 'K', 'l', 'M', 'n'];

references

Package Sidebar

Install

npm i @extra-array/insert-update

Weekly Downloads

2

Version

2.1.75

License

MIT

Unpacked Size

2.35 kB

Total Files

4

Last publish

Collaborators

  • wolfram77