🚀 Socket Launch Week Day 5:Introducing Repository Access Permissions and Custom Roles.Learn more
Sign In

basic-array

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install
Package was removed
Sorry, it seems this package was removed from the registry

basic-array

Modify Your Arrays With Some Basic Functions

unpublished
npmnpm
Version
2.1.0
Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source
  • 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.arrayPush(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]
  • My Website: Click Here!
  • My Discord Server: Join Here!

Keywords

array

FAQs

Package last updated on 19 Apr 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts