2.1.1 • Published 3 years ago

basic-array v2.1.1

Weekly downloads
-
License
ISC
Repository
-
Last release
3 years ago
  • Modify Your Arrays With Some Basic Functions

Installation:

npm install basic-array@latest

Random Values

const BasicArray = require("basic-array");
const basicArray = new BasicArray();

let array = [1, 2, 3, 4, 5];

/* Return a Random Value From The Array */
console.log(basicArray.randomValue(array)); // ====> 2

/* Return a Random Values From The Array According To The Number of Values */
console.log(basicArray.randomValues(array, 3)); // ====> [4, 2, 5]

First Values

const BasicArray = require("basic-array");
const basicArray = new BasicArray();

let array = [1, 2, 3, 4, 5];

/* Return The First Value From The Array */
console.log(basicArray.firstValue(array)); // ====> 1

/* Return The First Values From The Array According To The Number of Values */
console.log(basicArray.firstValues(array, 3)); // ====> [1, 2, 3]

First Values

const BasicArray = require("basic-array");
const basicArray = new BasicArray();

let array = [1, 2, 3, 4, 5];

/* Return The Last Value From The Array */
console.log(basicArray.lastValue(array)); // ====> 5

/* Return The Last Values From The Array According To The Number of Values */
console.log(basicArray.lastValues(array, 3)); // ====> [5, 4, 3]

Modified Arrays

const BasicArray = require("basic-array");
const basicArray = new BasicArray();

let array = [1, 2, 3, 4, 5];

/* Return a New Array With All Values But With Random Index */
console.log(basicArray.arrayRandom(array)); // ====> [2, 4, 5, 1, 3]

/* Return The Length of The Array */
console.log(basicArray.arrayLength(array)); // ====> 5

/* Return a New Array With All Values Plus The Pushed Values */
console.log(basicArray.arrayPush(array, 6)); // ====> [1, 2, 3, 4, 5, 6]

/* Return a New Array With All Values Except The Pulled Values */
console.log(basicArray.arrayPull(array, [5, 4])); // ====> [1, 2, 3]

/* Return True if The Array Contains The Value Else Return False */
console.log(basicArray.arrayHas(array, 3)); // ====> true

/* Return True if The Array Equal The Second Array Else Return False */
console.log(basicArray.arrayEqual(array, [1, 2, 3, 4, 5])); // ====> true

/* Return The Values Of The Array That Not in The Second Array */
console.log(basicArray.arrayDiff(array, [1, 2, 3])); // ====> [4, 5]
2.1.1

3 years ago

2.1.0

3 years ago

2.0.0

3 years ago

1.1.0

3 years ago

1.0.0

3 years ago