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

eraro

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

eraro - npm Package Compare versions

Comparing version 1.1.0 to 2.0.0

68

eraro.js

@@ -9,6 +9,6 @@ /* Copyright (c) 2014-2018 Richard Rodger, MIT License */

// #### System modules
var util = require('util')
const Util = require('util')
// #### External modules
var _ = require('lodash')
var Template = require('lodash.template')

@@ -26,3 +26,3 @@ // #### Exports

// * _msgmap_ : (optional) Object; map codes to message templates
// * _inspect_ : (optional) Boolean; If true, _util.inspect_ is called on values; default: true.
// * _inspect_ : (optional) Boolean; If true, _Util.inspect_ is called on values; default: true.
//

@@ -53,5 +53,5 @@ // Returns: Function

? ''
: _.isString(options.prefix)
: 'string' === typeof options.prefix
? options.prefix
: _.isString(options.package)
: 'string' === typeof options.package
? options.package + ': '

@@ -73,3 +73,3 @@ : ''

if (util.isError(ex)) {
if (Util.isError(ex)) {
if (ex.eraro && !options.override) return ex

@@ -84,19 +84,21 @@ } else {

code = _.isString(code)
? code
: ex
? ex.code
code =
'string' === typeof code
? code
: ex
? ex.code
: ex.message
? ex.message
? ex.code
: ex.message
? ex.message
: 'unknown'
: 'unknown'
: 'unknown'
details = _.isObject(details)
? details
: _.isObject(msg) && !_.isString(msg)
? msg
: {}
details =
'object' === typeof details
? details
: 'object' === typeof msg && 'string' !== typeof msg
? msg
: {}
msg = _.isString(msg) ? msg : null
msg = 'string' === typeof msg ? msg : null
msg = buildmessage(

@@ -158,3 +160,3 @@ options,

function callpoint(error, markers) {
markers = _.isArray(markers) ? markers : []
markers = Array.isArray(markers) ? markers : []

@@ -174,3 +176,3 @@ var stack = error ? error.stack : null

for (var j = 0; j < markers.length; j++) {
if (_.isString(markers[j])) {
if ('string' === typeof markers[j]) {
found = -1 != line.indexOf(markers[j])

@@ -184,3 +186,3 @@ if (found) break

out = _.isString(lines[i]) ? lines[i].substring(4) : out
out = 'string' === typeof lines[i] ? lines[i].substring(4) : out
}

@@ -219,5 +221,5 @@

msgprefix +
(_.isString(msg)
('string' === typeof msg
? msg
: _.isString(msgmap[code])
: 'string' === typeof msgmap[code]
? msgmap[code]

@@ -229,4 +231,5 @@ : ex

// These are the inserts.
var valmap = _.extend({}, details, { code: code })
var valmap = Object.assign({}, details, { code: code })
// TODO: is this needed anymore with _ removed?
// Workaround to prevent underscore blowing up if properties are not

@@ -236,5 +239,7 @@ // found. Reserved words and undefined need to be suffixed with $

var valstrmap = { util: util, _: _ }
_.each(valmap, function(val, key) {
/* jshint evil:true */
var valstrmap = { util: Util }
Object.entries(valmap).forEach(function(entry) {
var key = entry[0]
var val = entry[1]
try {

@@ -248,3 +253,4 @@ eval('var ' + key + ';')

}
valstrmap[key] = inspect && !_.isString(val) ? util.inspect(val) : val
valstrmap[key] =
inspect && 'string' !== typeof val ? Util.inspect(val) : val
})

@@ -255,3 +261,3 @@

try {
var tm = _.template(message)
var tm = Template(message)
message = tm(valstrmap)

@@ -274,3 +280,3 @@ done = true

' VALUES:' +
util.inspect(valmap, { depth: 2 }) +
Util.inspect(valmap, { depth: 2 }) +
' TEMPLATE ERROR: ' +

@@ -277,0 +283,0 @@ e

{
"name": "eraro",
"version": "1.1.0",
"version": "2.0.0",
"description": "Create JavaScript Error objects with code strings, context details, and templated messages.",
"main": "eraro.js",
"scripts": {
"test": "lab -v -P test -t 80 -I URL,URLSearchParams,BigUint64Array,BigInt64Array,BigInt",
"test": "lab -v -P test -t 80",
"coveralls": "lab -s -P test -r lcov -I URL,URLSearchParams | coveralls",
"prettier": "prettier --write --no-semi --single-quote *.js lib/*.js test/*.js",
"clean-npm": "rm -rf node_modules package-lock.json",
"repo-tag": "REPO_VERSION=`node -e \"console.log(require('./package').version)\"`; echo TAG: v$REPO_VERSION; git commit -a -m v$REPO_VERSION; git tag v$REPO_VERSION; git push --tags;",
"repo-publish": "npm run repo-tag; npm publish --access public"
"clean": "rm -rf node_modules package-lock.json yarn.lock",
"reset": "npm run clean && npm i && npm test",
"repo-tag": "REPO_VERSION=`node -e \"console.log(require('./package').version)\"` && echo TAG: v$REPO_VERSION && git commit -a -m v$REPO_VERSION && git push && git tag v$REPO_VERSION && git push --tags;",
"repo-publish": "npm run prettier && npm test && npm run repo-tag --registry http://registry.npmjs.org && npm publish --registry http://registry.npmjs.org "
},

@@ -33,3 +34,3 @@ "repository": {

"dependencies": {
"lodash": "4"
"lodash.template": "^4.5.0"
},

@@ -42,7 +43,7 @@ "files": [

"devDependencies": {
"code": "5",
"coveralls": "3",
"lab": "14",
"prettier": "1"
"@hapi/lab": "^21.0.0",
"@hapi/code": "^7.0.0",
"coveralls": "^3.0.9",
"prettier": "^1.19.1"
}
}
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