Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

array-tools

Package Overview
Dependencies
Maintainers
1
Versions
53
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

array-tools - npm Package Compare versions

Comparing version 1.1.1 to 1.1.2

2

lib/array-tools.js

@@ -157,3 +157,3 @@ "use strict";

function where(arrayOfObjects, query){
return arrayOfObjects.filter(function(item){
return arrayify(arrayOfObjects).filter(function(item){
return o.exists(item, query);

@@ -160,0 +160,0 @@ });

{
"name": "array-tools",
"author": "Lloyd Brookes <75pound@gmail.com>",
"version": "1.1.1",
"version": "1.1.2",
"description": "Useful functions for working with arrays",

@@ -6,0 +6,0 @@ "repository": "https://github.com/75lb/array-tools.git",

@@ -8,10 +8,12 @@ [![view on npm](http://img.shields.io/npm/v/array-tools.svg)](https://www.npmjs.org/package/array-tools)

#array-tools
Useful functions for working with arrays
####Example
**Example**
```js
var a = require("array-tools");
```
**Contents**
**Contents**
* [pluck(arrayOfObjects, ...property)](#module_array-tools.pluck)

@@ -30,5 +32,6 @@ * [arrayify(input)](#module_array-tools.arrayify)

<a name="module_array-tools.pluck"></a>
###a.pluck(arrayOfObjects, ...property)
###a.pluck(arrayOfObjects, ...property) ![static](http://img.shields.io/badge/function-static-green.svg?style=flat)
Plucks the value of the specified property from each object in the input array
**Params**

@@ -39,3 +42,3 @@ - arrayOfObjects `Array.<Object>` - the input array of objects

**Returns**: `Array`
####Example
**Example**
```js

@@ -56,3 +59,3 @@ > var data = [

<a name="module_array-tools.arrayify"></a>
###a.arrayify(input)
###a.arrayify(input) ![static](http://img.shields.io/badge/function-static-green.svg?style=flat)
Takes input and guarantees an array back. Result can be one of three things:

@@ -64,2 +67,3 @@

**Params**

@@ -69,3 +73,3 @@ - input `*` - the input value to convert to an array

**Returns**: `Array`
####Example
**Example**
```js

@@ -84,5 +88,6 @@ > a.arrayify(null)

<a name="module_array-tools.exists"></a>
###a.exists(array, value)
###a.exists(array, value) ![static](http://img.shields.io/badge/function-static-green.svg?style=flat)
returns true if a value, or nested object value exists in an array
**Params**

@@ -93,3 +98,3 @@ - array `Array` - the array to search

**Returns**: `boolean`
####Example
**Example**
```js

@@ -106,6 +111,7 @@ > a.exists([ 1, 2, 3 ], 2)

<a name="module_array-tools.where"></a>
###a.where(arrayOfObjects, query)
###a.where(arrayOfObjects, query) ![static](http://img.shields.io/badge/function-static-green.svg?style=flat)
returns an array containing items from `arrayOfObjects` where key/value pairs
from `query` are matched identically
**Params**

@@ -116,3 +122,3 @@ - arrayOfObjects `Array` - the array to search

**Returns**: `Array`
####Example
**Example**
```js

@@ -128,6 +134,7 @@ > dudes = [{ name: "Jim", age: 8}, { name: "Clive", age: 8}, { name: "Hater", age: 9}]

<a name="module_array-tools.findWhere"></a>
###a.findWhere(arrayOfObjects, query)
###a.findWhere(arrayOfObjects, query) ![static](http://img.shields.io/badge/function-static-green.svg?style=flat)
returns the first item from `arrayOfObjects` where key/value pairs
from `query` are matched identically
**Params**

@@ -138,3 +145,3 @@ - arrayOfObjects `Array` - the array to search

**Returns**: `Object`
####Example
**Example**
```js

@@ -149,5 +156,6 @@ > dudes = [{ name: "Jim", age: 8}, { name: "Clive", age: 8}, { name: "Hater", age: 9}]

<a name="module_array-tools.without"></a>
###a.without(input, toRemove)
###a.without(input, toRemove) ![static](http://img.shields.io/badge/function-static-green.svg?style=flat)
Returns the input minus the specified values.
**Params**

@@ -158,3 +166,3 @@ - input `Array` - the input array

**Returns**: `Array`
####Example
**Example**
```js

@@ -167,5 +175,6 @@ > a.without([ 1, 2, 3 ], 2)

<a name="module_array-tools.union"></a>
###a.union(array1, array2, idKey)
###a.union(array1, array2, idKey) ![static](http://img.shields.io/badge/function-static-green.svg?style=flat)
merge two arrays into a single array of unique values
**Params**

@@ -177,3 +186,3 @@ - array1 `Array` - First array

**Returns**: `Array`
####Example
**Example**
```js

@@ -199,5 +208,6 @@ > var array1 = [ 1, 2 ], array2 = [ 2, 3 ];

<a name="module_array-tools.commonSequence"></a>
###a.commonSequence(a, b)
###a.commonSequence(a, b) ![static](http://img.shields.io/badge/function-static-green.svg?style=flat)
Returns the initial elements which both input arrays have in common
**Params**

@@ -208,3 +218,3 @@ - a `Array` - first array to compare

**Returns**: `Array`
####Example
**Example**
```js

@@ -215,5 +225,6 @@ > a.commonSequence([1,2,3], [1,2,4])

<a name="module_array-tools.unique"></a>
###a.unique(array)
###a.unique(array) ![static](http://img.shields.io/badge/function-static-green.svg?style=flat)
reduces an array to unique values
**Params**

@@ -223,3 +234,3 @@ - array `Array` - input array

**Returns**: `Array`
####Example
**Example**
```js

@@ -232,5 +243,6 @@ > n = [1,6,6,7,1]

<a name="module_array-tools.spliceWhile"></a>
###a.spliceWhile(array, index, test, ...elementN)
###a.spliceWhile(array, index, test, ...elementN) ![static](http://img.shields.io/badge/function-static-green.svg?style=flat)
splice from `index` until `test` fails
**Params**

@@ -243,3 +255,3 @@ - array `Array` - the input array

**Returns**: `Array`
####Example
**Example**
```js

@@ -254,5 +266,6 @@ > letters = ["a", "a", "b"]

<a name="module_array-tools.extract"></a>
###a.extract(array, callback)
###a.extract(array, callback) ![static](http://img.shields.io/badge/function-static-green.svg?style=flat)
Removes items from `array` which pass the `callback` test. Modifies the input array, returns the extracted.
**Params**

@@ -259,0 +272,0 @@ - array `Array` - the input array, modified directly

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc