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

@josecarlosrz/array-helper

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@josecarlosrz/array-helper - npm Package Compare versions

Comparing version 1.0.3 to 1.0.4

110

index.js

@@ -12,3 +12,9 @@ module.exports = {

for (let i = 0; i < array.length; i++) {
if (!(i in array)) {
continue;
}
await closure.call(thisArg, array[i], i, array);
}

@@ -18,3 +24,3 @@

find: async function(array, closure) {
map: async function(array, closure) {

@@ -27,13 +33,19 @@ let thisArg;

const responses = [];
for (let i = 0; i < array.length; i++) {
if (await closure.call(thisArg, array[i], i, array)) {
return array[i];
if (!(i in array)) {
continue;
}
responses.push(await closure.call(thisArg, array[i], i, array));
}
return responses;
},
findIndex: async function(array, closure) {
filter: async function(array, closure) {

@@ -46,6 +58,12 @@ let thisArg;

const newArray = [];
for (let i = 0; i < array.length; i++) {
if (!(i in array)) {
continue;
}
if (await closure.call(thisArg, array[i], i, array)) {
return i;
newArray.push(array[i]);
}

@@ -55,7 +73,7 @@

return -1;
return newArray;
},
map: async function(array, closure) {
some: async function(array, closure) {

@@ -68,13 +86,19 @@ let thisArg;

const responses = [];
for (let i = 0; i < array.length; i++) {
responses.push(await closure.call(thisArg, array[i], i, array));
if (!(i in array)) {
continue;
}
if (await closure.call(thisArg, array[i], i, array)) {
return true;
}
}
return responses;
return false;
},
filter: async function(array, closure) {
every: async function(array, closure) {

@@ -87,17 +111,19 @@ let thisArg;

const newArray = [];
for (let i = 0; i < array.length; i++) {
if (await closure.call(thisArg, array[i], i, array)) {
newArray.push(array[i]);
if (!(i in array)) {
continue;
}
if (!await closure.call(thisArg, array[i], i, array)) {
return false;
}
}
return newArray;
return true;
},
some: async function(array, closure) {
find: async function(array, closure) {

@@ -113,3 +139,3 @@ let thisArg;

if (await closure.call(thisArg, array[i], i, array)) {
return true;
return array[i];
}

@@ -119,7 +145,5 @@

return false;
},
every: async function(array, closure) {
findIndex: async function(array, closure) {

@@ -134,4 +158,4 @@ let thisArg;

if (!await closure.call(thisArg, array[i], i, array)) {
return false;
if (await closure.call(thisArg, array[i], i, array)) {
return i;
}

@@ -141,8 +165,24 @@

return true;
return -1;
},
reduce: async function(array, closure, value = null) {
reduce: async function(array, closure) {
let value;
if (arguments.length > 2) {
value = arguments[2];
} else if (array.length > 0) {
value = array[0];
} else {
throw new TypeError('Reduce of empty array with no initial value');
}
for (let i = 0; i < array.length; i++) {

@@ -156,4 +196,20 @@ value = await closure(value, array[i], i, array);

reduceRight: async function(array, closure, value = null) {
reduceRight: async function(array, closure) {
let value;
if (arguments.length > 2) {
value = arguments[2];
} else if (array.length > 0) {
value = array[0];
} else {
throw new TypeError('Reduce of empty array with no initial value');
}
for (let i = array.length - 1; i >= 0; i--) {

@@ -160,0 +216,0 @@ value = await closure(value, array[i], i, array);

{
"name": "@josecarlosrz/array-helper",
"version": "1.0.3",
"version": "1.0.4",
"description": "Array helper to have async behavior and some util methods",

@@ -5,0 +5,0 @@ "main": "index.js",

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