New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

for-each-plus

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

for-each-plus - npm Package Compare versions

Comparing version 1.0.2 to 1.0.3

107

index.js

@@ -1,16 +0,2 @@

const shallowProperty = key => obj => obj == null ? void 0 : obj[key];
const MAX_ARRAY_INDEX = 2 ** 53 - 1;
const getLength = shallowProperty('length');
const isArrayLike = (collection) => {
const length = getLength(collection);
return typeof length == 'number' && length >= 0 && length <= MAX_ARRAY_INDEX;
};
const isFunction = obj => toString.call(obj) === '[object Function]';
const isObject = obj => {
var isObject = obj => {
const type = typeof obj;

@@ -21,7 +7,3 @@

const isArguments = obj => toString.call(obj) === '[object Arguments]';
const identity = value => value;
const getKeys = (obj) => {
var getKeys = (obj) => {
if (!isObject(obj)) return [];

@@ -32,44 +14,15 @@

const isMatch = (object, attrs) => {
const keys = getKeys(attrs);
const {length} = keys;
var shallowProperty = key => obj => obj == null ? void 0 : obj[key];
if (object == null) return !length;
const obj = Object(object);
var getLength = shallowProperty('length');
for (let i = 0; i < length; i++) {
const key = keys[i];
const MAX_ARRAY_INDEX = 2 ** 53 - 1;
if (attrs[key] !== obj[key] || !(key in obj)) return false;
}
var isArrayLike = (collection) => {
const length = getLength(collection);
return true;
return typeof length == 'number' && length >= 0 && length <= MAX_ARRAY_INDEX;
};
const matcher = attrs => {
attrs = Object.assign({}, attrs);
return obj => isMatch(obj, attrs);
};
const deepGet = (obj, path) => {
const { length } = path;
for (let i = 0; i < length; i++) {
if (obj == null) return void 0;
obj = obj[path[i]];
}
return length ? obj : void 0;
};
const property = path => {
if (!Array.isArray(path)) {
return shallowProperty(path);
}
return obj => deepGet(obj, path);
};
const optimizeCb = (func, context, argCount) => {
var optimizeCb = (func, context, argCount) => {
if (context === void 0) return func;

@@ -86,41 +39,5 @@ switch (argCount == null ? 3 : argCount) {

const baseIteratee = (value, context, argCount) => {
if (value == null) return identity;
if (isFunction(value)) return optimizeCb(value, context, argCount);
if (isObject(value) && !Array.isArray(value)) return matcher(value);
return property(value);
};
let iteratee;
const exportIteratee = iteratee = (value, context) => baseIteratee(value, context, Infinity);
const cb = (value, context, argCount) => {
if (iteratee !== exportIteratee) return iteratee(value, context);
return baseIteratee(value, context, argCount);
};
var lib = {
shallowProperty,
getLength,
isArrayLike,
isFunction,
isObject,
isArguments,
identity,
getKeys,
property,
matcher,
isMatch,
optimizeCb,
cb
};
const { getKeys: getKeys$1, isArrayLike: isArrayLike$1, optimizeCb: optimizeCb$1 } = lib;
var forEach = (obj, iteratee, context) => {
iteratee = optimizeCb$1(iteratee, context);
if (isArrayLike$1(obj)) {
iteratee = optimizeCb(iteratee, context);
if (isArrayLike(obj)) {
let i = 0;

@@ -132,3 +49,3 @@

} else {
const keys = getKeys$1(obj);
const keys = getKeys(obj);

@@ -135,0 +52,0 @@ for (const key of keys) {

4

package.json
{
"name": "for-each-plus",
"version": "1.0.2",
"version": "1.0.3",
"description": "A better forEach.",

@@ -47,4 +47,4 @@ "main": "index.js",

"mocha": "^7.1.1",
"rollup": "^2.1.0"
"rollup": "^2.3.0"
}
}

@@ -21,3 +21,3 @@ # for-each-plus [![Build Status](https://travis-ci.com/jonkemp/for-each-plus.svg?branch=master)](https://travis-ci.com/jonkemp/for-each-plus)

```
<script src="https://unpkg.com/for-each-plus@1.0.1/umd/index.js" />
<script src="https://unpkg.com/for-each-plus@1.0.3/umd/index.js" />
```

@@ -24,0 +24,0 @@

@@ -7,17 +7,3 @@ (function (global, factory) {

const shallowProperty = key => obj => obj == null ? void 0 : obj[key];
const MAX_ARRAY_INDEX = 2 ** 53 - 1;
const getLength = shallowProperty('length');
const isArrayLike = (collection) => {
const length = getLength(collection);
return typeof length == 'number' && length >= 0 && length <= MAX_ARRAY_INDEX;
};
const isFunction = obj => toString.call(obj) === '[object Function]';
const isObject = obj => {
var isObject = obj => {
const type = typeof obj;

@@ -28,7 +14,3 @@

const isArguments = obj => toString.call(obj) === '[object Arguments]';
const identity = value => value;
const getKeys = (obj) => {
var getKeys = (obj) => {
if (!isObject(obj)) return [];

@@ -39,44 +21,15 @@

const isMatch = (object, attrs) => {
const keys = getKeys(attrs);
const {length} = keys;
var shallowProperty = key => obj => obj == null ? void 0 : obj[key];
if (object == null) return !length;
const obj = Object(object);
var getLength = shallowProperty('length');
for (let i = 0; i < length; i++) {
const key = keys[i];
const MAX_ARRAY_INDEX = 2 ** 53 - 1;
if (attrs[key] !== obj[key] || !(key in obj)) return false;
}
var isArrayLike = (collection) => {
const length = getLength(collection);
return true;
return typeof length == 'number' && length >= 0 && length <= MAX_ARRAY_INDEX;
};
const matcher = attrs => {
attrs = Object.assign({}, attrs);
return obj => isMatch(obj, attrs);
};
const deepGet = (obj, path) => {
const { length } = path;
for (let i = 0; i < length; i++) {
if (obj == null) return void 0;
obj = obj[path[i]];
}
return length ? obj : void 0;
};
const property = path => {
if (!Array.isArray(path)) {
return shallowProperty(path);
}
return obj => deepGet(obj, path);
};
const optimizeCb = (func, context, argCount) => {
var optimizeCb = (func, context, argCount) => {
if (context === void 0) return func;

@@ -93,41 +46,5 @@ switch (argCount == null ? 3 : argCount) {

const baseIteratee = (value, context, argCount) => {
if (value == null) return identity;
if (isFunction(value)) return optimizeCb(value, context, argCount);
if (isObject(value) && !Array.isArray(value)) return matcher(value);
return property(value);
};
let iteratee;
const exportIteratee = iteratee = (value, context) => baseIteratee(value, context, Infinity);
const cb = (value, context, argCount) => {
if (iteratee !== exportIteratee) return iteratee(value, context);
return baseIteratee(value, context, argCount);
};
var lib = {
shallowProperty,
getLength,
isArrayLike,
isFunction,
isObject,
isArguments,
identity,
getKeys,
property,
matcher,
isMatch,
optimizeCb,
cb
};
const { getKeys: getKeys$1, isArrayLike: isArrayLike$1, optimizeCb: optimizeCb$1 } = lib;
var forEach = (obj, iteratee, context) => {
iteratee = optimizeCb$1(iteratee, context);
if (isArrayLike$1(obj)) {
iteratee = optimizeCb(iteratee, context);
if (isArrayLike(obj)) {
let i = 0;

@@ -139,3 +56,3 @@

} else {
const keys = getKeys$1(obj);
const keys = getKeys(obj);

@@ -142,0 +59,0 @@ for (const key of keys) {

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