Comparing version 10.1.2 to 10.2.0
45
index.js
@@ -5,7 +5,7 @@ 'use strict' | ||
const stringTemplate = require('./string-template') | ||
const nargs = /\{([0-9a-zA-Z_]+)\}/g | ||
const lowerCaseKebabRegex = /([a-z])([0-9A-Z])/g | ||
const upperCaseKebabRegex = /([A-Z])([A-Z])(?=[a-z])/g | ||
const hasOwnProperty = Object.prototype.hasOwnProperty | ||
const PLAIN_ERROR_FIELDS = [ | ||
@@ -55,3 +55,3 @@ 'code', | ||
static get type () { | ||
if (Object.prototype.hasOwnProperty.call(this, '__type')) { | ||
if (hasOwnProperty.call(this, '__type')) { | ||
return this.__type | ||
@@ -134,3 +134,3 @@ } | ||
static get type () { | ||
if (Object.prototype.hasOwnProperty.call(this, '__type')) { | ||
if (hasOwnProperty.call(this, '__type')) { | ||
return this.__type | ||
@@ -317,1 +317,38 @@ } | ||
} | ||
/** | ||
* Taken from https://www.npmjs.com/package/string-template. | ||
* source: https://github.com/Matt-Esch/string-template | ||
*/ | ||
function stringTemplate (string) { | ||
var args | ||
if (arguments.length === 2 && typeof arguments[1] === 'object') { | ||
args = arguments[1] | ||
} else { | ||
args = new Array(arguments.length - 1) | ||
for (var i = 1; i < arguments.length; ++i) { | ||
args[i - 1] = arguments[i] | ||
} | ||
} | ||
if (!args || !args.hasOwnProperty) { | ||
args = {} | ||
} | ||
return string.replace(nargs, function replaceArg (match, i, index) { | ||
var result | ||
if (string[index - 1] === '{' && | ||
string[index + match.length] === '}') { | ||
return i | ||
} else { | ||
result = hasOwnProperty.call(args, i) ? args[i] : null | ||
if (result === null || result === undefined) { | ||
return '' | ||
} | ||
return result | ||
} | ||
}) | ||
} |
{ | ||
"name": "error", | ||
"version": "10.1.2", | ||
"version": "10.2.0", | ||
"description": "Custom errors", | ||
@@ -5,0 +5,0 @@ "keywords": [], |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
36814
12
838