🎩 You're Invited:Meet the Socket team at Black Hat in Las Vegas, August 3-6.RSVP
Sign In

map-plus

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

map-plus - npm Package Compare versions

Comparing version
1.0.0
to
1.0.1
+124
-5
index.js

@@ -1,7 +0,124 @@

const { cb, isArrayLike, getKeys } = require('./lib/index');
const shallowProperty = key => obj => obj == null ? void 0 : obj[key];
module.exports = (obj, iteratee, context) => {
iteratee = cb(iteratee, context);
const keys = !isArrayLike(obj) && getKeys(obj);
const {length} = keys || obj;
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 => {
const type = typeof obj;
return type === 'function' || type === 'object' && !!obj;
};
const isArguments = obj => toString.call(obj) === '[object Arguments]';
const identity = value => value;
const getKeys = (obj) => {
if (!isObject(obj)) return [];
return Object.keys(obj);
};
const isMatch = (object, attrs) => {
const keys = getKeys(attrs);
const {length} = keys;
if (object == null) return !length;
const obj = Object(object);
for (let i = 0; i < length; i++) {
const key = keys[i];
if (attrs[key] !== obj[key] || !(key in obj)) return false;
}
return true;
};
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) => {
if (context === void 0) return func;
switch (argCount == null ? 3 : argCount) {
case 1: return value => func.call(context, value);
// The 2-argument case is omitted because we’re not using it.
case 3: return (value, index, collection) => func.call(context, value, index, collection);
case 4: return (accumulator, value, index, collection) => func.call(context, accumulator, value, index, collection);
}
return (...args) => func.apply(context, args);
};
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, cb: cb$1 } = lib;
var map = (obj, iteratee, context) => {
iteratee = cb$1(iteratee, context);
const keys = !isArrayLike$1(obj) && getKeys$1(obj);
const { length } = keys || obj;
const results = Array(length);

@@ -17,1 +134,3 @@

};
module.exports = map;
+7
-3
{
"name": "map-plus",
"version": "1.0.0",
"version": "1.0.1",
"description": "Creates a new array of values by mapping each value in list through an iteratee.",

@@ -11,7 +11,6 @@ "main": "index.js",

"lint:fix": "eslint . --fix --max-warnings 0",
"test": "mocha"
"test": "npm run build && karma start --single-run --browsers ChromeHeadless karma.conf.js"
},
"files": [
"index.js",
"lib",
"umd"

@@ -41,3 +40,8 @@ ],

"babel-eslint": "^10.1.0",
"chai": "^4.2.0",
"eslint": "^6.8.0",
"karma": "^4.4.1",
"karma-chai": "^0.1.0",
"karma-chrome-launcher": "^3.1.0",
"karma-mocha": "^1.3.0",
"mocha": "^7.1.1",

@@ -44,0 +48,0 @@ "rollup": "^2.1.0"

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

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

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

@@ -10,3 +10,5 @@ (function (global, factory) {

const MAX_ARRAY_INDEX = 2 ** 53 - 1;
const getLength = shallowProperty('length');
const isArrayLike = (collection) => {

@@ -18,2 +20,4 @@ const length = getLength(collection);

const isFunction = obj => toString.call(obj) === '[object Function]';
const isObject = obj => {

@@ -25,2 +29,6 @@ const type = typeof obj;

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

@@ -32,4 +40,2 @@ if (!isObject(obj)) return [];

const isFunction = obj => toString.call(obj) === '[object Function]';
const isMatch = (object, attrs) => {

@@ -51,6 +57,10 @@ const keys = getKeys(attrs);

const identity = value => value;
const matcher = attrs => {
attrs = Object.assign({}, attrs);
return obj => isMatch(obj, attrs);
};
const deepGet = (obj, path) => {
const {length} = path;
const { length } = path;

@@ -85,8 +95,2 @@ for (let i = 0; i < length; i++) {

const matcher = attrs => {
attrs = Object.assign({}, attrs);
return obj => isMatch(obj, attrs);
};
const baseIteratee = (value, context, argCount) => {

@@ -111,13 +115,23 @@ if (value == null) return identity;

var lib = {
shallowProperty,
getLength,
isArrayLike,
isFunction,
isObject,
isArguments,
identity,
getKeys,
property,
matcher,
isMatch,
optimizeCb,
cb
};
const { cb: cb$1, isArrayLike: isArrayLike$1, getKeys: getKeys$1 } = lib;
const { getKeys: getKeys$1, isArrayLike: isArrayLike$1, cb: cb$1 } = lib;
var mapPlus = (obj, iteratee, context) => {
var map = (obj, iteratee, context) => {
iteratee = cb$1(iteratee, context);
const keys = !isArrayLike$1(obj) && getKeys$1(obj);
const {length} = keys || obj;
const { length } = keys || obj;
const results = Array(length);

@@ -134,4 +148,6 @@

var mapPlus = map;
return mapPlus;
})));
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 isObject = obj => {
const type = typeof obj;
return type === 'function' || type === 'object' && !!obj;
};
const getKeys = (obj) => {
if (!isObject(obj)) return [];
return Object.keys(obj);
};
const isFunction = obj => toString.call(obj) === '[object Function]';
const isMatch = (object, attrs) => {
const keys = getKeys(attrs);
const {length} = keys;
if (object == null) return !length;
const obj = Object(object);
for (let i = 0; i < length; i++) {
const key = keys[i];
if (attrs[key] !== obj[key] || !(key in obj)) return false;
}
return true;
};
const identity = value => value;
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) => {
if (context === void 0) return func;
switch (argCount == null ? 3 : argCount) {
case 1: return value => func.call(context, value);
// The 2-argument case is omitted because we’re not using it.
case 3: return (value, index, collection) => func.call(context, value, index, collection);
case 4: return (accumulator, value, index, collection) => func.call(context, accumulator, value, index, collection);
}
return (...args) => func.apply(context, args);
};
const matcher = attrs => {
attrs = Object.assign({}, attrs);
return obj => isMatch(obj, attrs);
};
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);
};
module.exports = {
isArrayLike,
getKeys,
cb
};