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

pro-array

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pro-array - npm Package Compare versions

Comparing version 1.0.1 to 1.0.2

jsdoc2md/partials/separator.hbs

3

Gruntfile.js

@@ -60,3 +60,4 @@ module.exports = function(grunt) {

'jsdoc2md/partials/params-table.hbs',
'jsdoc2md/partials/param-table-name.hbs'
'jsdoc2md/partials/param-table-name.hbs',
'jsdoc2md/partials/separator.hbs'
],

@@ -63,0 +64,0 @@ separators: true,

@@ -0,0 +0,0 @@ The MIT License (MIT)

{
"name": "pro-array",
"version": "1.0.1",
"version": "1.0.2",
"description": "Extends the functionality of Arrays with several useful methods",

@@ -5,0 +5,0 @@ "main": "pro-array.js",

@@ -0,0 +0,0 @@ /**

@@ -55,7 +55,8 @@ # ProArray

-
---
<a name="Array#chunk"></a>
### array.chunk([size]) ⇒ <code>[Array](#Array)</code>
Creates an array of elements split into groups the length of `size`. If the array can't be split evenly, the final chunk will be the remaining elements.
Creates an array of elements split into groups the length of `size`. If the array
can't be split evenly, the final chunk will be the remaining elements.

@@ -71,6 +72,10 @@

```js
[1, 2, 3, 4].chunk(2); // -> [[1, 2], [3, 4]] [1, 2, 3, 4].chunk(3); // -> [[1, 2, 3], [4]]
[1, 2, 3, 4].chunk(2);
// -> [[1, 2], [3, 4]]
[1, 2, 3, 4].chunk(3);
// -> [[1, 2, 3], [4]]
```
-
---

@@ -84,6 +89,9 @@ <a name="Array#clear"></a>

```js
var array = [1, 2, 3]; array.clear(); console.log(array); // -> []
var array = [1, 2, 3];
array.clear();
console.log(array);
// -> []
```
-
---

@@ -98,10 +106,14 @@ <a name="Array#clone"></a>

```js
var a = [1, 2, 3]; var b = a.clone(); console.log(b, b === a); // -> [1, 2, 3] false
var a = [1, 2, 3];
var b = a.clone();
console.log(b, b === a);
// -> [1, 2, 3] false
```
-
---
<a name="Array#compact"></a>
### array.compact() ⇒ <code>[Array](#Array)</code>
Returns a new array with all falsey values removed. Falsey values are `false`, `0`, `""`, `null`, `undefined`, and `NaN`.
Returns a new array with all falsey values removed. Falsey values
are `false`, `0`, `""`, `null`, `undefined`, and `NaN`.

@@ -112,6 +124,7 @@ **Returns**: <code>[Array](#Array)</code> - A new array containing only the truthy values of the original array.

```js
[0, 1, false, 2, '', 3].compact(); // -> [1, 2, 3]
[0, 1, false, 2, '', 3].compact();
// -> [1, 2, 3]
```
-
---

@@ -124,7 +137,8 @@ <a name="Array#diff"></a>

-
---
<a name="Array#difference"></a>
### array.difference(...*arrays) ⇒ <code>[Array](#Array)</code>
Returns a new array with all of the values of this array that are not in any of the input arrays (performs a set difference).
Returns a new array with all of the values of this array that are not in
any of the input arrays (performs a set difference).

@@ -139,12 +153,20 @@

```js
[1, 2, 3, 4, 5].difference([5, 2, 10]); // -> [1, 3, 4]
[1, 2, 3, 4, 5].difference([5, 2, 10]);
// -> [1, 3, 4]
```
-
---
<a name="Array#each"></a>
### array.each(callback(value,index,array), [safeIteration]) ⇒ <code>[Array](#Array)</code>
Invokes a callback function on each element in the array. A generic iterator method similar to `Array#forEach()` but with the following differences: 1. `this` always refers to the current element in the iteration (the `value` argument to the callback). 2. Returning `false` in the callback will cancel the iteration (similar to a `break` statement). 3. The array is returned to allow for function chaining. 4. The callback __is__ invoked for indexes that have been deleted or elided unless `safeIteration` is `true`.
Invokes a callback function on each element in the array.
A generic iterator method similar to `Array#forEach()` but with the following differences:
1. `this` always refers to the current element in the iteration (the `value` argument to the callback).
2. Returning `false` in the callback will cancel the iteration (similar to a `break` statement).
3. The array is returned to allow for function chaining.
4. The callback __is__ invoked for indexes that have been deleted or elided unless `safeIteration` is `true`.
| Param | Type | Default | Description |

@@ -159,12 +181,37 @@ | --- | --- | --- | --- |

```js
['a', 'b', 'c'].each(console.log.bind(console)); // -> 'a' 0 ['a', 'b', 'c'] // -> 'b' 1 ['a', 'b', 'c'] // -> 'c' 2 ['a', 'b', 'c'] // -> ['a', 'b', 'c'] ['a', 'b', 'c'].each(function(value, index) { console.log(value); if (index === 1) return false; }); // -> 'a' // -> 'b' // -> ['a', 'b', 'c'] [[1, 2], [3, 4, 5]].each(Array.prototype.pop); // -> [[1], [3, 4]] new Array(1).each(console.log.bind(console)); // -> undefined 0 ['a', 'b', 'c'] // -> [undefined] new Array(1).each(console.log.bind(console), true); // -> [undefined]
['a', 'b', 'c'].each(console.log.bind(console));
// -> 'a' 0 ['a', 'b', 'c']
// -> 'b' 1 ['a', 'b', 'c']
// -> 'c' 2 ['a', 'b', 'c']
// -> ['a', 'b', 'c']
['a', 'b', 'c'].each(function(value, index) {
console.log(value);
if (index === 1) return false;
});
// -> 'a'
// -> 'b'
// -> ['a', 'b', 'c']
[[1, 2], [3, 4, 5]].each(Array.prototype.pop);
// -> [[1], [3, 4]]
new Array(1).each(console.log.bind(console));
// -> undefined 0 ['a', 'b', 'c']
// -> [undefined]
new Array(1).each(console.log.bind(console), true);
// -> [undefined]
```
-
---
<a name="Array#equals"></a>
### array.equals(array) ⇒ <code>boolean</code>
Determines if the arrays are equal by doing a shallow comparison of their elements using strict equality. __Note:__ The order of elements in the arrays DOES matter. The elements must be found in the same order for the arrays to be considered equal.
Determines if the arrays are equal by doing a shallow comparison of their elements using strict equality.
__Note:__ The order of elements in the arrays DOES matter. The elements must be found in the same order
for the arrays to be considered equal.
| Param | Type | Description |

@@ -182,6 +229,15 @@ | --- | --- | --- |

```js
var array = [1, 2, 3]; array.equals(array); // -> true array.equals([1, 2, 3]); // -> true array.equals([3, 2, 1]); // -> false
var array = [1, 2, 3];
array.equals(array);
// -> true
array.equals([1, 2, 3]);
// -> true
array.equals([3, 2, 1]);
// -> false
```
-
---

@@ -201,6 +257,21 @@ <a name="Array#get"></a>

```js
var array = [1, 2, 3]; array.get(0); // -> 1 array.get(1); // -> 2 array.get(-1); // -> 3 array.get(-2); // -> 2 array.get(5); // -> undefined
var array = [1, 2, 3];
array.get(0);
// -> 1
array.get(1);
// -> 2
array.get(-1);
// -> 3
array.get(-2);
// -> 2
array.get(5);
// -> undefined
```
-
---

@@ -220,6 +291,10 @@ <a name="Array#intersect"></a>

```js
[1, 2, 3].intersect([2, 3, 4]); // -> [2, 3] [1, 2, 3].intersect([101, 2, 50, 1], [2, 1]); // -> [1, 2]
[1, 2, 3].intersect([2, 3, 4]);
// -> [2, 3]
[1, 2, 3].intersect([101, 2, 50, 1], [2, 1]);
// -> [1, 2]
```
-
---

@@ -239,10 +314,14 @@ <a name="Array#natsort"></a>

```js
var files = ['a.txt', 'a10.txt', 'a2.txt', 'a1.txt']; files.natsort(); console.log(files); // -> ['a.txt', 'a1.txt', 'a2.txt', 'a10.txt']
var files = ['a.txt', 'a10.txt', 'a2.txt', 'a1.txt'];
files.natsort();
console.log(files);
// -> ['a.txt', 'a1.txt', 'a2.txt', 'a10.txt']
```
-
---
<a name="Array#numsort"></a>
### array.numsort() ⇒ <code>[Array](#Array)</code>
Sorts an array in place using a numerical comparison algorithm (sorts numbers from lowest to highest) and returns the array.
Sorts an array in place using a numerical comparison algorithm
(sorts numbers from lowest to highest) and returns the array.

@@ -253,6 +332,9 @@ **Returns**: <code>[Array](#Array)</code> - The array.

```js
var files = [10, 0, 2, 1]; files.numsort(); console.log(files); // -> [0, 1, 2, 3]
var files = [10, 0, 2, 1];
files.numsort();
console.log(files);
// -> [0, 1, 2, 3]
```
-
---

@@ -272,10 +354,20 @@ <a name="Array#remove"></a>

```js
var array = [1, 2, 3, 3, 4, 3, 5]; array.remove(1); // -> [2, 3, 3, 4, 3, 5] array.remove(3); // -> [2, 4, 5] array.remove(2, 5); // -> [4]
var array = [1, 2, 3, 3, 4, 3, 5];
array.remove(1);
// -> [2, 3, 3, 4, 3, 5]
array.remove(3);
// -> [2, 4, 5]
array.remove(2, 5);
// -> [4]
```
-
---
<a name="Array#rnumsort"></a>
### array.rnumsort() ⇒ <code>[Array](#Array)</code>
Sorts an array in place using a reverse numerical comparison algorithm (sorts numbers from highest to lowest) and returns the array.
Sorts an array in place using a reverse numerical comparison algorithm
(sorts numbers from highest to lowest) and returns the array.

@@ -286,6 +378,9 @@ **Returns**: <code>[Array](#Array)</code> - The array.

```js
var files = [10, 0, 2, 1]; files.rnumsort(); console.log(files); // -> [3, 2, 1, 0]
var files = [10, 0, 2, 1];
files.rnumsort();
console.log(files);
// -> [3, 2, 1, 0]
```
-
---

@@ -305,6 +400,7 @@ <a name="Array#union"></a>

```js
[1, 2, 3].union([2, 3, 4, 5]); // -> [1, 2, 3, 4, 5]
[1, 2, 3].union([2, 3, 4, 5]);
// -> [1, 2, 3, 4, 5]
```
-
---

@@ -317,3 +413,3 @@ <a name="Array#uniq"></a>

-
---

@@ -332,6 +428,15 @@ <a name="Array#unique"></a>

```js
// Unsorted [4, 2, 3, 2, 1, 4].unique(); // -> [4, 2, 3, 1] // Sorted [1, 2, 2, 3, 4, 4].unique(); // -> [1, 2, 3, 4] [1, 2, 2, 3, 4, 4].unique(true); // -> [1, 2, 3, 4] (but faster than the previous example)
// Unsorted
[4, 2, 3, 2, 1, 4].unique();
// -> [4, 2, 3, 1]
// Sorted
[1, 2, 2, 3, 4, 4].unique();
// -> [1, 2, 3, 4]
[1, 2, 2, 3, 4, 4].unique(true);
// -> [1, 2, 3, 4] (but faster than the previous example)
```
-
---

@@ -350,6 +455,7 @@ <a name="Array#without"></a>

```js
[1, 2, 3, 4].without(2, 4); // -> [1, 3]
[1, 2, 3, 4].without(2, 4);
// -> [1, 3]
```
-
---

@@ -0,0 +0,0 @@ 'use strict';

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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