Comparing version
"use strict"; | ||
// <https://lacke.mn/reduce-your-bundle-js-file-size/> | ||
// // <https://github.com/lodash/babel-plugin-lodash/issues/221> | ||
var isError = require('lodash/isError'); | ||
var isArray = require('lodash/isArray'); | ||
var isEmpty = require('lodash/isEmpty'); | ||
var pick = require('lodash/pick'); | ||
var isFunction = require('lodash/isFunction'); // we want to support parsing other fields than the standard: | ||
var isError = require('iserror'); // we want to support parsing other fields than the standard: | ||
// <https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors> | ||
@@ -21,11 +11,13 @@ // <https://github.com/stripe/stripe-node/blob/3c07d851cf897490d8b93dd4457dda0c4c8e667f/lib/Error.js#L33> | ||
if (!isError(err)) throw new Error('`err` must be an Error'); | ||
if (!isArray(fields)) throw new Error('`fields` must be an Array'); | ||
if (!Array.isArray(fields)) throw new Error('`fields` must be an Array'); | ||
var keys = {}; | ||
Object.getOwnPropertyNames(Object.getPrototypeOf(err)).concat(Object.getOwnPropertyNames(err)).forEach(function (key) { | ||
if (!isFunction(err[key])) keys[key] = err[key]; | ||
if (typeof err[key] !== 'function') keys[key] = err[key]; | ||
}); | ||
if (!keys.name && err.constructor.name) keys.name = err.constructor.name; | ||
return isArray(fields) && !isEmpty(fields) ? pick(keys, fields) : keys; | ||
return Array.isArray(fields) && fields.length !== 0 ? keys.filter(function (key) { | ||
return fields.indexOf(key) !== -1; | ||
}) : keys; | ||
}; | ||
module.exports = parseErr; |
{ | ||
"name": "parse-err", | ||
"description": "Parse errors in the Browser and Node. Made for Cabin.", | ||
"version": "0.0.8", | ||
"version": "0.0.9", | ||
"author": "Nick Baugh <niftylettuce@gmail.com> (http://niftylettuce.com/)", | ||
"ava": { | ||
"failFast": true, | ||
"verbose": true | ||
"verbose": true, | ||
"helpers": [ | ||
"test/helpers/**/*" | ||
] | ||
}, | ||
@@ -23,14 +26,14 @@ "bugs": { | ||
"dependencies": { | ||
"lodash": "^4.17.11" | ||
"iserror": "^0.0.2" | ||
}, | ||
"devDependencies": { | ||
"@babel/cli": "^7.4.4", | ||
"@babel/core": "^7.4.4", | ||
"@babel/preset-env": "^7.4.4", | ||
"@commitlint/cli": "^7.5.2", | ||
"@commitlint/config-conventional": "^7.5.0", | ||
"ava": "^1.4.1", | ||
"@babel/core": "^7.4.5", | ||
"@babel/preset-env": "^7.4.5", | ||
"@commitlint/cli": "^8.0.0", | ||
"@commitlint/config-conventional": "^8.0.0", | ||
"ava": "^2.1.0", | ||
"babelify": "^10.0.0", | ||
"browserify": "^16.2.3", | ||
"codecov": "^3.3.0", | ||
"codecov": "^3.5.0", | ||
"cross-env": "^5.2.0", | ||
@@ -40,11 +43,11 @@ "eslint": "^5.16.0", | ||
"eslint-plugin-compat": "^3.1.1", | ||
"eslint-plugin-node": "^8.0.1", | ||
"eslint-plugin-node": "^9.1.0", | ||
"fixpack": "^2.3.1", | ||
"husky": "^2.1.0", | ||
"lint-staged": "^8.1.5", | ||
"nyc": "^14.0.0", | ||
"husky": "^2.4.0", | ||
"lint-staged": "^8.2.0", | ||
"nyc": "^14.1.1", | ||
"remark-cli": "^6.0.1", | ||
"remark-preset-github": "^0.0.13", | ||
"rimraf": "^2.6.3", | ||
"tinyify": "^2.5.0", | ||
"tinyify": "^2.5.1", | ||
"xo": "^0.24.0" | ||
@@ -125,3 +128,3 @@ }, | ||
"ava": "cross-env NODE_ENV=test ava", | ||
"browserify": "browserify src/index.js -o dist/parse-err.js -s parseErr -d -t [ babelify --configFile ./.dist.babelrc ]", | ||
"browserify": "browserify src/index.js -o dist/parse-err.js -s parseErr -g [ babelify --configFile ./.dist.babelrc ]", | ||
"build": "npm run build:clean && npm run build:lib && npm run build:dist", | ||
@@ -133,3 +136,3 @@ "build:clean": "rimraf lib dist", | ||
"lint": "xo && remark . -qfo && eslint -c .lib.eslintrc lib && eslint -c .dist.eslintrc dist", | ||
"minify": "cross-env NODE_ENV=production browserify src/index.js -o dist/parse-err.min.js -s parseErr -d -t [ babelify --configFile ./.dist.babelrc ] -p tinyify", | ||
"minify": "cross-env NODE_ENV=production browserify src/index.js -o dist/parse-err.min.js -s parseErr -g [ babelify --configFile ./.dist.babelrc ] -p tinyify", | ||
"nyc": "cross-env NODE_ENV=test nyc ava", | ||
@@ -136,0 +139,0 @@ "test": "npm run build && npm run lint && npm run ava", |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
12468
-96.61%65
-97.69%+ Added
+ Added
- Removed
- Removed