New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

@lbzg/arrays

Package Overview
Dependencies
Maintainers
1
Versions
33
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@lbzg/arrays

Javascript arrays extension.

latest
Source
npmnpm
Version
3.0.15
Version published
Maintainers
1
Created
Source

Array helper.

Installation & Usage

npm i @lbzg/arrays

Attach to prototype or import Arrays or arr.
fns: add, addUnique, remove, get, getAll, has, count, indices, list

import '@lbzg/arrays'

const x = []

x.arr().add({id: 1})
x.arr().add([{id: 2}, 3, 3])
x.arr().addUnique(1) # does not get added
x.arr().remove(1)

x.arr().getAll() # [{id: 2}, 3, 3]

selector can be a value, an array of values or a function

# get(selector?, key? = 'id')
x.arr().get() # {id: 2}
x.arr().get(1) # undefined
x.arr().get(2) # {id: 2}
x.arr().get(3) # 3
x.arr().get([1, 2, 3]) # {id:2}
x.arr().get(x => x === 3) # 3

x.arr().getAll() # [{id: 2}, 3, 3]
x.arr().getAll(1) # []
x.arr().getAll(2) # [{id: 2}]
x.arr().getAll(3) # [3, 3]
x.arr().getAll([1, 2, 3]) # [{id: 2}, 3, 3]
x.arr().getAll(x => x === 3) # [3, 3]
x.arr().has(2) # true # has(selector?, key?)
x.arr().count() # 4 # count(selector?, key?)
x.arr().indices(1) # [0, 1] # indices(selector, key?)
x.arr().list() # [2] # list(key?)

Prototype

arr(input?)

Takes optional input and returns Arrays instance.
Array.prototype.arr() takes no input.

Arrays

constructor(input?)

add(input): array ~ mutates array
addUnique(input, key?): array ~ mutates array
remove(selector, amount?, key?): array ~ mutates array

get(selector?, key?): value | undefined
getAll(selector?, key?): array
has(selector?, key?): boolean ~ every for value(s); some for function
count(selector?, key?): number
indices(selector, key?): array ~ of matched indexes
list(key?): array ~ object key values

input ~ value or value[]
selector ~ value or value[] or function
key ~ string | number | symbol (object identifier)

Keywords

array

FAQs

Package last updated on 06 Jan 2020

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