Initial
This commit is contained in:
53
resources/app/node_modules/jsprim/CHANGES.md
generated
vendored
Normal file
53
resources/app/node_modules/jsprim/CHANGES.md
generated
vendored
Normal file
@@ -0,0 +1,53 @@
|
||||
# Changelog
|
||||
|
||||
## not yet released
|
||||
|
||||
None yet.
|
||||
|
||||
## v1.4.2 (2021-11-29)
|
||||
|
||||
* #35 Backport json-schema 0.4.0 to version 1.4.x
|
||||
|
||||
## v1.4.1 (2017-08-02)
|
||||
|
||||
* #21 Update verror dep
|
||||
* #22 Update extsprintf dependency
|
||||
* #23 update contribution guidelines
|
||||
|
||||
## v1.4.0 (2017-03-13)
|
||||
|
||||
* #7 Add parseInteger() function for safer number parsing
|
||||
|
||||
## v1.3.1 (2016-09-12)
|
||||
|
||||
* #13 Incompatible with webpack
|
||||
|
||||
## v1.3.0 (2016-06-22)
|
||||
|
||||
* #14 add safer version of hasOwnProperty()
|
||||
* #15 forEachKey() should ignore inherited properties
|
||||
|
||||
## v1.2.2 (2015-10-15)
|
||||
|
||||
* #11 NPM package shouldn't include any code that does `require('JSV')`
|
||||
* #12 jsl.node.conf missing definition for "module"
|
||||
|
||||
## v1.2.1 (2015-10-14)
|
||||
|
||||
* #8 odd date parsing behaviour
|
||||
|
||||
## v1.2.0 (2015-10-13)
|
||||
|
||||
* #9 want function for returning RFC1123 dates
|
||||
|
||||
## v1.1.0 (2015-09-02)
|
||||
|
||||
* #6 a new suite of hrtime manipulation routines: `hrtimeAdd()`,
|
||||
`hrtimeAccum()`, `hrtimeNanosec()`, `hrtimeMicrosec()` and
|
||||
`hrtimeMillisec()`.
|
||||
|
||||
## v1.0.0 (2015-09-01)
|
||||
|
||||
First tracked release. Includes everything in previous releases, plus:
|
||||
|
||||
* #4 want function for merging objects
|
||||
19
resources/app/node_modules/jsprim/CONTRIBUTING.md
generated
vendored
Normal file
19
resources/app/node_modules/jsprim/CONTRIBUTING.md
generated
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
# Contributing
|
||||
|
||||
This repository uses [cr.joyent.us](https://cr.joyent.us) (Gerrit) for new
|
||||
changes. Anyone can submit changes. To get started, see the [cr.joyent.us user
|
||||
guide](https://github.com/joyent/joyent-gerrit/blob/master/docs/user/README.md).
|
||||
This repo does not use GitHub pull requests.
|
||||
|
||||
See the [Joyent Engineering
|
||||
Guidelines](https://github.com/joyent/eng/blob/master/docs/index.md) for general
|
||||
best practices expected in this repository.
|
||||
|
||||
Contributions should be "make prepush" clean. The "prepush" target runs the
|
||||
"check" target, which requires these separate tools:
|
||||
|
||||
* https://github.com/davepacheco/jsstyle
|
||||
* https://github.com/davepacheco/javascriptlint
|
||||
|
||||
If you're changing something non-trivial or user-facing, you may want to submit
|
||||
an issue first.
|
||||
19
resources/app/node_modules/jsprim/LICENSE
generated
vendored
Normal file
19
resources/app/node_modules/jsprim/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
Copyright (c) 2012, Joyent, Inc. All rights reserved.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE
|
||||
735
resources/app/node_modules/jsprim/lib/jsprim.js
generated
vendored
Normal file
735
resources/app/node_modules/jsprim/lib/jsprim.js
generated
vendored
Normal file
@@ -0,0 +1,735 @@
|
||||
/*
|
||||
* lib/jsprim.js: utilities for primitive JavaScript types
|
||||
*/
|
||||
|
||||
var mod_assert = require('assert-plus');
|
||||
var mod_util = require('util');
|
||||
|
||||
var mod_extsprintf = require('extsprintf');
|
||||
var mod_verror = require('verror');
|
||||
var mod_jsonschema = require('json-schema');
|
||||
|
||||
/*
|
||||
* Public interface
|
||||
*/
|
||||
exports.deepCopy = deepCopy;
|
||||
exports.deepEqual = deepEqual;
|
||||
exports.isEmpty = isEmpty;
|
||||
exports.hasKey = hasKey;
|
||||
exports.forEachKey = forEachKey;
|
||||
exports.pluck = pluck;
|
||||
exports.flattenObject = flattenObject;
|
||||
exports.flattenIter = flattenIter;
|
||||
exports.validateJsonObject = validateJsonObjectJS;
|
||||
exports.validateJsonObjectJS = validateJsonObjectJS;
|
||||
exports.randElt = randElt;
|
||||
exports.extraProperties = extraProperties;
|
||||
exports.mergeObjects = mergeObjects;
|
||||
|
||||
exports.startsWith = startsWith;
|
||||
exports.endsWith = endsWith;
|
||||
|
||||
exports.parseInteger = parseInteger;
|
||||
|
||||
exports.iso8601 = iso8601;
|
||||
exports.rfc1123 = rfc1123;
|
||||
exports.parseDateTime = parseDateTime;
|
||||
|
||||
exports.hrtimediff = hrtimeDiff;
|
||||
exports.hrtimeDiff = hrtimeDiff;
|
||||
exports.hrtimeAccum = hrtimeAccum;
|
||||
exports.hrtimeAdd = hrtimeAdd;
|
||||
exports.hrtimeNanosec = hrtimeNanosec;
|
||||
exports.hrtimeMicrosec = hrtimeMicrosec;
|
||||
exports.hrtimeMillisec = hrtimeMillisec;
|
||||
|
||||
|
||||
/*
|
||||
* Deep copy an acyclic *basic* Javascript object. This only handles basic
|
||||
* scalars (strings, numbers, booleans) and arbitrarily deep arrays and objects
|
||||
* containing these. This does *not* handle instances of other classes.
|
||||
*/
|
||||
function deepCopy(obj)
|
||||
{
|
||||
var ret, key;
|
||||
var marker = '__deepCopy';
|
||||
|
||||
if (obj && obj[marker])
|
||||
throw (new Error('attempted deep copy of cyclic object'));
|
||||
|
||||
if (obj && obj.constructor == Object) {
|
||||
ret = {};
|
||||
obj[marker] = true;
|
||||
|
||||
for (key in obj) {
|
||||
if (key == marker)
|
||||
continue;
|
||||
|
||||
ret[key] = deepCopy(obj[key]);
|
||||
}
|
||||
|
||||
delete (obj[marker]);
|
||||
return (ret);
|
||||
}
|
||||
|
||||
if (obj && obj.constructor == Array) {
|
||||
ret = [];
|
||||
obj[marker] = true;
|
||||
|
||||
for (key = 0; key < obj.length; key++)
|
||||
ret.push(deepCopy(obj[key]));
|
||||
|
||||
delete (obj[marker]);
|
||||
return (ret);
|
||||
}
|
||||
|
||||
/*
|
||||
* It must be a primitive type -- just return it.
|
||||
*/
|
||||
return (obj);
|
||||
}
|
||||
|
||||
function deepEqual(obj1, obj2)
|
||||
{
|
||||
if (typeof (obj1) != typeof (obj2))
|
||||
return (false);
|
||||
|
||||
if (obj1 === null || obj2 === null || typeof (obj1) != 'object')
|
||||
return (obj1 === obj2);
|
||||
|
||||
if (obj1.constructor != obj2.constructor)
|
||||
return (false);
|
||||
|
||||
var k;
|
||||
for (k in obj1) {
|
||||
if (!obj2.hasOwnProperty(k))
|
||||
return (false);
|
||||
|
||||
if (!deepEqual(obj1[k], obj2[k]))
|
||||
return (false);
|
||||
}
|
||||
|
||||
for (k in obj2) {
|
||||
if (!obj1.hasOwnProperty(k))
|
||||
return (false);
|
||||
}
|
||||
|
||||
return (true);
|
||||
}
|
||||
|
||||
function isEmpty(obj)
|
||||
{
|
||||
var key;
|
||||
for (key in obj)
|
||||
return (false);
|
||||
return (true);
|
||||
}
|
||||
|
||||
function hasKey(obj, key)
|
||||
{
|
||||
mod_assert.equal(typeof (key), 'string');
|
||||
return (Object.prototype.hasOwnProperty.call(obj, key));
|
||||
}
|
||||
|
||||
function forEachKey(obj, callback)
|
||||
{
|
||||
for (var key in obj) {
|
||||
if (hasKey(obj, key)) {
|
||||
callback(key, obj[key]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function pluck(obj, key)
|
||||
{
|
||||
mod_assert.equal(typeof (key), 'string');
|
||||
return (pluckv(obj, key));
|
||||
}
|
||||
|
||||
function pluckv(obj, key)
|
||||
{
|
||||
if (obj === null || typeof (obj) !== 'object')
|
||||
return (undefined);
|
||||
|
||||
if (obj.hasOwnProperty(key))
|
||||
return (obj[key]);
|
||||
|
||||
var i = key.indexOf('.');
|
||||
if (i == -1)
|
||||
return (undefined);
|
||||
|
||||
var key1 = key.substr(0, i);
|
||||
if (!obj.hasOwnProperty(key1))
|
||||
return (undefined);
|
||||
|
||||
return (pluckv(obj[key1], key.substr(i + 1)));
|
||||
}
|
||||
|
||||
/*
|
||||
* Invoke callback(row) for each entry in the array that would be returned by
|
||||
* flattenObject(data, depth). This is just like flattenObject(data,
|
||||
* depth).forEach(callback), except that the intermediate array is never
|
||||
* created.
|
||||
*/
|
||||
function flattenIter(data, depth, callback)
|
||||
{
|
||||
doFlattenIter(data, depth, [], callback);
|
||||
}
|
||||
|
||||
function doFlattenIter(data, depth, accum, callback)
|
||||
{
|
||||
var each;
|
||||
var key;
|
||||
|
||||
if (depth === 0) {
|
||||
each = accum.slice(0);
|
||||
each.push(data);
|
||||
callback(each);
|
||||
return;
|
||||
}
|
||||
|
||||
mod_assert.ok(data !== null);
|
||||
mod_assert.equal(typeof (data), 'object');
|
||||
mod_assert.equal(typeof (depth), 'number');
|
||||
mod_assert.ok(depth >= 0);
|
||||
|
||||
for (key in data) {
|
||||
each = accum.slice(0);
|
||||
each.push(key);
|
||||
doFlattenIter(data[key], depth - 1, each, callback);
|
||||
}
|
||||
}
|
||||
|
||||
function flattenObject(data, depth)
|
||||
{
|
||||
if (depth === 0)
|
||||
return ([ data ]);
|
||||
|
||||
mod_assert.ok(data !== null);
|
||||
mod_assert.equal(typeof (data), 'object');
|
||||
mod_assert.equal(typeof (depth), 'number');
|
||||
mod_assert.ok(depth >= 0);
|
||||
|
||||
var rv = [];
|
||||
var key;
|
||||
|
||||
for (key in data) {
|
||||
flattenObject(data[key], depth - 1).forEach(function (p) {
|
||||
rv.push([ key ].concat(p));
|
||||
});
|
||||
}
|
||||
|
||||
return (rv);
|
||||
}
|
||||
|
||||
function startsWith(str, prefix)
|
||||
{
|
||||
return (str.substr(0, prefix.length) == prefix);
|
||||
}
|
||||
|
||||
function endsWith(str, suffix)
|
||||
{
|
||||
return (str.substr(
|
||||
str.length - suffix.length, suffix.length) == suffix);
|
||||
}
|
||||
|
||||
function iso8601(d)
|
||||
{
|
||||
if (typeof (d) == 'number')
|
||||
d = new Date(d);
|
||||
mod_assert.ok(d.constructor === Date);
|
||||
return (mod_extsprintf.sprintf('%4d-%02d-%02dT%02d:%02d:%02d.%03dZ',
|
||||
d.getUTCFullYear(), d.getUTCMonth() + 1, d.getUTCDate(),
|
||||
d.getUTCHours(), d.getUTCMinutes(), d.getUTCSeconds(),
|
||||
d.getUTCMilliseconds()));
|
||||
}
|
||||
|
||||
var RFC1123_MONTHS = [
|
||||
'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
|
||||
'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
|
||||
var RFC1123_DAYS = [
|
||||
'Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];
|
||||
|
||||
function rfc1123(date) {
|
||||
return (mod_extsprintf.sprintf('%s, %02d %s %04d %02d:%02d:%02d GMT',
|
||||
RFC1123_DAYS[date.getUTCDay()], date.getUTCDate(),
|
||||
RFC1123_MONTHS[date.getUTCMonth()], date.getUTCFullYear(),
|
||||
date.getUTCHours(), date.getUTCMinutes(),
|
||||
date.getUTCSeconds()));
|
||||
}
|
||||
|
||||
/*
|
||||
* Parses a date expressed as a string, as either a number of milliseconds since
|
||||
* the epoch or any string format that Date accepts, giving preference to the
|
||||
* former where these two sets overlap (e.g., small numbers).
|
||||
*/
|
||||
function parseDateTime(str)
|
||||
{
|
||||
/*
|
||||
* This is irritatingly implicit, but significantly more concise than
|
||||
* alternatives. The "+str" will convert a string containing only a
|
||||
* number directly to a Number, or NaN for other strings. Thus, if the
|
||||
* conversion succeeds, we use it (this is the milliseconds-since-epoch
|
||||
* case). Otherwise, we pass the string directly to the Date
|
||||
* constructor to parse.
|
||||
*/
|
||||
var numeric = +str;
|
||||
if (!isNaN(numeric)) {
|
||||
return (new Date(numeric));
|
||||
} else {
|
||||
return (new Date(str));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Number.*_SAFE_INTEGER isn't present before node v0.12, so we hardcode
|
||||
* the ES6 definitions here, while allowing for them to someday be higher.
|
||||
*/
|
||||
var MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER || 9007199254740991;
|
||||
var MIN_SAFE_INTEGER = Number.MIN_SAFE_INTEGER || -9007199254740991;
|
||||
|
||||
|
||||
/*
|
||||
* Default options for parseInteger().
|
||||
*/
|
||||
var PI_DEFAULTS = {
|
||||
base: 10,
|
||||
allowSign: true,
|
||||
allowPrefix: false,
|
||||
allowTrailing: false,
|
||||
allowImprecise: false,
|
||||
trimWhitespace: false,
|
||||
leadingZeroIsOctal: false
|
||||
};
|
||||
|
||||
var CP_0 = 0x30;
|
||||
var CP_9 = 0x39;
|
||||
|
||||
var CP_A = 0x41;
|
||||
var CP_B = 0x42;
|
||||
var CP_O = 0x4f;
|
||||
var CP_T = 0x54;
|
||||
var CP_X = 0x58;
|
||||
var CP_Z = 0x5a;
|
||||
|
||||
var CP_a = 0x61;
|
||||
var CP_b = 0x62;
|
||||
var CP_o = 0x6f;
|
||||
var CP_t = 0x74;
|
||||
var CP_x = 0x78;
|
||||
var CP_z = 0x7a;
|
||||
|
||||
var PI_CONV_DEC = 0x30;
|
||||
var PI_CONV_UC = 0x37;
|
||||
var PI_CONV_LC = 0x57;
|
||||
|
||||
|
||||
/*
|
||||
* A stricter version of parseInt() that provides options for changing what
|
||||
* is an acceptable string (for example, disallowing trailing characters).
|
||||
*/
|
||||
function parseInteger(str, uopts)
|
||||
{
|
||||
mod_assert.string(str, 'str');
|
||||
mod_assert.optionalObject(uopts, 'options');
|
||||
|
||||
var baseOverride = false;
|
||||
var options = PI_DEFAULTS;
|
||||
|
||||
if (uopts) {
|
||||
baseOverride = hasKey(uopts, 'base');
|
||||
options = mergeObjects(options, uopts);
|
||||
mod_assert.number(options.base, 'options.base');
|
||||
mod_assert.ok(options.base >= 2, 'options.base >= 2');
|
||||
mod_assert.ok(options.base <= 36, 'options.base <= 36');
|
||||
mod_assert.bool(options.allowSign, 'options.allowSign');
|
||||
mod_assert.bool(options.allowPrefix, 'options.allowPrefix');
|
||||
mod_assert.bool(options.allowTrailing,
|
||||
'options.allowTrailing');
|
||||
mod_assert.bool(options.allowImprecise,
|
||||
'options.allowImprecise');
|
||||
mod_assert.bool(options.trimWhitespace,
|
||||
'options.trimWhitespace');
|
||||
mod_assert.bool(options.leadingZeroIsOctal,
|
||||
'options.leadingZeroIsOctal');
|
||||
|
||||
if (options.leadingZeroIsOctal) {
|
||||
mod_assert.ok(!baseOverride,
|
||||
'"base" and "leadingZeroIsOctal" are ' +
|
||||
'mutually exclusive');
|
||||
}
|
||||
}
|
||||
|
||||
var c;
|
||||
var pbase = -1;
|
||||
var base = options.base;
|
||||
var start;
|
||||
var mult = 1;
|
||||
var value = 0;
|
||||
var idx = 0;
|
||||
var len = str.length;
|
||||
|
||||
/* Trim any whitespace on the left side. */
|
||||
if (options.trimWhitespace) {
|
||||
while (idx < len && isSpace(str.charCodeAt(idx))) {
|
||||
++idx;
|
||||
}
|
||||
}
|
||||
|
||||
/* Check the number for a leading sign. */
|
||||
if (options.allowSign) {
|
||||
if (str[idx] === '-') {
|
||||
idx += 1;
|
||||
mult = -1;
|
||||
} else if (str[idx] === '+') {
|
||||
idx += 1;
|
||||
}
|
||||
}
|
||||
|
||||
/* Parse the base-indicating prefix if there is one. */
|
||||
if (str[idx] === '0') {
|
||||
if (options.allowPrefix) {
|
||||
pbase = prefixToBase(str.charCodeAt(idx + 1));
|
||||
if (pbase !== -1 && (!baseOverride || pbase === base)) {
|
||||
base = pbase;
|
||||
idx += 2;
|
||||
}
|
||||
}
|
||||
|
||||
if (pbase === -1 && options.leadingZeroIsOctal) {
|
||||
base = 8;
|
||||
}
|
||||
}
|
||||
|
||||
/* Parse the actual digits. */
|
||||
for (start = idx; idx < len; ++idx) {
|
||||
c = translateDigit(str.charCodeAt(idx));
|
||||
if (c !== -1 && c < base) {
|
||||
value *= base;
|
||||
value += c;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* If we didn't parse any digits, we have an invalid number. */
|
||||
if (start === idx) {
|
||||
return (new Error('invalid number: ' + JSON.stringify(str)));
|
||||
}
|
||||
|
||||
/* Trim any whitespace on the right side. */
|
||||
if (options.trimWhitespace) {
|
||||
while (idx < len && isSpace(str.charCodeAt(idx))) {
|
||||
++idx;
|
||||
}
|
||||
}
|
||||
|
||||
/* Check for trailing characters. */
|
||||
if (idx < len && !options.allowTrailing) {
|
||||
return (new Error('trailing characters after number: ' +
|
||||
JSON.stringify(str.slice(idx))));
|
||||
}
|
||||
|
||||
/* If our value is 0, we return now, to avoid returning -0. */
|
||||
if (value === 0) {
|
||||
return (0);
|
||||
}
|
||||
|
||||
/* Calculate our final value. */
|
||||
var result = value * mult;
|
||||
|
||||
/*
|
||||
* If the string represents a value that cannot be precisely represented
|
||||
* by JavaScript, then we want to check that:
|
||||
*
|
||||
* - We never increased the value past MAX_SAFE_INTEGER
|
||||
* - We don't make the result negative and below MIN_SAFE_INTEGER
|
||||
*
|
||||
* Because we only ever increment the value during parsing, there's no
|
||||
* chance of moving past MAX_SAFE_INTEGER and then dropping below it
|
||||
* again, losing precision in the process. This means that we only need
|
||||
* to do our checks here, at the end.
|
||||
*/
|
||||
if (!options.allowImprecise &&
|
||||
(value > MAX_SAFE_INTEGER || result < MIN_SAFE_INTEGER)) {
|
||||
return (new Error('number is outside of the supported range: ' +
|
||||
JSON.stringify(str.slice(start, idx))));
|
||||
}
|
||||
|
||||
return (result);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Interpret a character code as a base-36 digit.
|
||||
*/
|
||||
function translateDigit(d)
|
||||
{
|
||||
if (d >= CP_0 && d <= CP_9) {
|
||||
/* '0' to '9' -> 0 to 9 */
|
||||
return (d - PI_CONV_DEC);
|
||||
} else if (d >= CP_A && d <= CP_Z) {
|
||||
/* 'A' - 'Z' -> 10 to 35 */
|
||||
return (d - PI_CONV_UC);
|
||||
} else if (d >= CP_a && d <= CP_z) {
|
||||
/* 'a' - 'z' -> 10 to 35 */
|
||||
return (d - PI_CONV_LC);
|
||||
} else {
|
||||
/* Invalid character code */
|
||||
return (-1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Test if a value matches the ECMAScript definition of trimmable whitespace.
|
||||
*/
|
||||
function isSpace(c)
|
||||
{
|
||||
return (c === 0x20) ||
|
||||
(c >= 0x0009 && c <= 0x000d) ||
|
||||
(c === 0x00a0) ||
|
||||
(c === 0x1680) ||
|
||||
(c === 0x180e) ||
|
||||
(c >= 0x2000 && c <= 0x200a) ||
|
||||
(c === 0x2028) ||
|
||||
(c === 0x2029) ||
|
||||
(c === 0x202f) ||
|
||||
(c === 0x205f) ||
|
||||
(c === 0x3000) ||
|
||||
(c === 0xfeff);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Determine which base a character indicates (e.g., 'x' indicates hex).
|
||||
*/
|
||||
function prefixToBase(c)
|
||||
{
|
||||
if (c === CP_b || c === CP_B) {
|
||||
/* 0b/0B (binary) */
|
||||
return (2);
|
||||
} else if (c === CP_o || c === CP_O) {
|
||||
/* 0o/0O (octal) */
|
||||
return (8);
|
||||
} else if (c === CP_t || c === CP_T) {
|
||||
/* 0t/0T (decimal) */
|
||||
return (10);
|
||||
} else if (c === CP_x || c === CP_X) {
|
||||
/* 0x/0X (hexadecimal) */
|
||||
return (16);
|
||||
} else {
|
||||
/* Not a meaningful character */
|
||||
return (-1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function validateJsonObjectJS(schema, input)
|
||||
{
|
||||
var report = mod_jsonschema.validate(input, schema);
|
||||
|
||||
if (report.errors.length === 0)
|
||||
return (null);
|
||||
|
||||
/* Currently, we only do anything useful with the first error. */
|
||||
var error = report.errors[0];
|
||||
|
||||
/* The failed property is given by a URI with an irrelevant prefix. */
|
||||
var propname = error['property'];
|
||||
var reason = error['message'].toLowerCase();
|
||||
var i, j;
|
||||
|
||||
/*
|
||||
* There's at least one case where the property error message is
|
||||
* confusing at best. We work around this here.
|
||||
*/
|
||||
if ((i = reason.indexOf('the property ')) != -1 &&
|
||||
(j = reason.indexOf(' is not defined in the schema and the ' +
|
||||
'schema does not allow additional properties')) != -1) {
|
||||
i += 'the property '.length;
|
||||
if (propname === '')
|
||||
propname = reason.substr(i, j - i);
|
||||
else
|
||||
propname = propname + '.' + reason.substr(i, j - i);
|
||||
|
||||
reason = 'unsupported property';
|
||||
}
|
||||
|
||||
var rv = new mod_verror.VError('property "%s": %s', propname, reason);
|
||||
rv.jsv_details = error;
|
||||
return (rv);
|
||||
}
|
||||
|
||||
function randElt(arr)
|
||||
{
|
||||
mod_assert.ok(Array.isArray(arr) && arr.length > 0,
|
||||
'randElt argument must be a non-empty array');
|
||||
|
||||
return (arr[Math.floor(Math.random() * arr.length)]);
|
||||
}
|
||||
|
||||
function assertHrtime(a)
|
||||
{
|
||||
mod_assert.ok(a[0] >= 0 && a[1] >= 0,
|
||||
'negative numbers not allowed in hrtimes');
|
||||
mod_assert.ok(a[1] < 1e9, 'nanoseconds column overflow');
|
||||
}
|
||||
|
||||
/*
|
||||
* Compute the time elapsed between hrtime readings A and B, where A is later
|
||||
* than B. hrtime readings come from Node's process.hrtime(). There is no
|
||||
* defined way to represent negative deltas, so it's illegal to diff B from A
|
||||
* where the time denoted by B is later than the time denoted by A. If this
|
||||
* becomes valuable, we can define a representation and extend the
|
||||
* implementation to support it.
|
||||
*/
|
||||
function hrtimeDiff(a, b)
|
||||
{
|
||||
assertHrtime(a);
|
||||
assertHrtime(b);
|
||||
mod_assert.ok(a[0] > b[0] || (a[0] == b[0] && a[1] >= b[1]),
|
||||
'negative differences not allowed');
|
||||
|
||||
var rv = [ a[0] - b[0], 0 ];
|
||||
|
||||
if (a[1] >= b[1]) {
|
||||
rv[1] = a[1] - b[1];
|
||||
} else {
|
||||
rv[0]--;
|
||||
rv[1] = 1e9 - (b[1] - a[1]);
|
||||
}
|
||||
|
||||
return (rv);
|
||||
}
|
||||
|
||||
/*
|
||||
* Convert a hrtime reading from the array format returned by Node's
|
||||
* process.hrtime() into a scalar number of nanoseconds.
|
||||
*/
|
||||
function hrtimeNanosec(a)
|
||||
{
|
||||
assertHrtime(a);
|
||||
|
||||
return (Math.floor(a[0] * 1e9 + a[1]));
|
||||
}
|
||||
|
||||
/*
|
||||
* Convert a hrtime reading from the array format returned by Node's
|
||||
* process.hrtime() into a scalar number of microseconds.
|
||||
*/
|
||||
function hrtimeMicrosec(a)
|
||||
{
|
||||
assertHrtime(a);
|
||||
|
||||
return (Math.floor(a[0] * 1e6 + a[1] / 1e3));
|
||||
}
|
||||
|
||||
/*
|
||||
* Convert a hrtime reading from the array format returned by Node's
|
||||
* process.hrtime() into a scalar number of milliseconds.
|
||||
*/
|
||||
function hrtimeMillisec(a)
|
||||
{
|
||||
assertHrtime(a);
|
||||
|
||||
return (Math.floor(a[0] * 1e3 + a[1] / 1e6));
|
||||
}
|
||||
|
||||
/*
|
||||
* Add two hrtime readings A and B, overwriting A with the result of the
|
||||
* addition. This function is useful for accumulating several hrtime intervals
|
||||
* into a counter. Returns A.
|
||||
*/
|
||||
function hrtimeAccum(a, b)
|
||||
{
|
||||
assertHrtime(a);
|
||||
assertHrtime(b);
|
||||
|
||||
/*
|
||||
* Accumulate the nanosecond component.
|
||||
*/
|
||||
a[1] += b[1];
|
||||
if (a[1] >= 1e9) {
|
||||
/*
|
||||
* The nanosecond component overflowed, so carry to the seconds
|
||||
* field.
|
||||
*/
|
||||
a[0]++;
|
||||
a[1] -= 1e9;
|
||||
}
|
||||
|
||||
/*
|
||||
* Accumulate the seconds component.
|
||||
*/
|
||||
a[0] += b[0];
|
||||
|
||||
return (a);
|
||||
}
|
||||
|
||||
/*
|
||||
* Add two hrtime readings A and B, returning the result as a new hrtime array.
|
||||
* Does not modify either input argument.
|
||||
*/
|
||||
function hrtimeAdd(a, b)
|
||||
{
|
||||
assertHrtime(a);
|
||||
|
||||
var rv = [ a[0], a[1] ];
|
||||
|
||||
return (hrtimeAccum(rv, b));
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Check an object for unexpected properties. Accepts the object to check, and
|
||||
* an array of allowed property names (strings). Returns an array of key names
|
||||
* that were found on the object, but did not appear in the list of allowed
|
||||
* properties. If no properties were found, the returned array will be of
|
||||
* zero length.
|
||||
*/
|
||||
function extraProperties(obj, allowed)
|
||||
{
|
||||
mod_assert.ok(typeof (obj) === 'object' && obj !== null,
|
||||
'obj argument must be a non-null object');
|
||||
mod_assert.ok(Array.isArray(allowed),
|
||||
'allowed argument must be an array of strings');
|
||||
for (var i = 0; i < allowed.length; i++) {
|
||||
mod_assert.ok(typeof (allowed[i]) === 'string',
|
||||
'allowed argument must be an array of strings');
|
||||
}
|
||||
|
||||
return (Object.keys(obj).filter(function (key) {
|
||||
return (allowed.indexOf(key) === -1);
|
||||
}));
|
||||
}
|
||||
|
||||
/*
|
||||
* Given three sets of properties "provided" (may be undefined), "overrides"
|
||||
* (required), and "defaults" (may be undefined), construct an object containing
|
||||
* the union of these sets with "overrides" overriding "provided", and
|
||||
* "provided" overriding "defaults". None of the input objects are modified.
|
||||
*/
|
||||
function mergeObjects(provided, overrides, defaults)
|
||||
{
|
||||
var rv, k;
|
||||
|
||||
rv = {};
|
||||
if (defaults) {
|
||||
for (k in defaults)
|
||||
rv[k] = defaults[k];
|
||||
}
|
||||
|
||||
if (provided) {
|
||||
for (k in provided)
|
||||
rv[k] = provided[k];
|
||||
}
|
||||
|
||||
if (overrides) {
|
||||
for (k in overrides)
|
||||
rv[k] = overrides[k];
|
||||
}
|
||||
|
||||
return (rv);
|
||||
}
|
||||
28
resources/app/node_modules/jsprim/node_modules/verror/CHANGES.md
generated
vendored
Normal file
28
resources/app/node_modules/jsprim/node_modules/verror/CHANGES.md
generated
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
# Changelog
|
||||
|
||||
## Not yet released
|
||||
|
||||
None yet.
|
||||
|
||||
## v1.10.0
|
||||
|
||||
* #49 want convenience functions for MultiErrors
|
||||
|
||||
## v1.9.0
|
||||
|
||||
* #47 could use VError.hasCauseWithName()
|
||||
|
||||
## v1.8.1
|
||||
|
||||
* #39 captureStackTrace lost when inheriting from WError
|
||||
|
||||
## v1.8.0
|
||||
|
||||
* #23 Preserve original stack trace(s)
|
||||
|
||||
## v1.7.0
|
||||
|
||||
* #10 better support for extra properties on Errors
|
||||
* #11 make it easy to find causes of a particular kind
|
||||
* #29 No documentation on how to Install this package
|
||||
* #36 elide development-only files from npm package
|
||||
19
resources/app/node_modules/jsprim/node_modules/verror/CONTRIBUTING.md
generated
vendored
Normal file
19
resources/app/node_modules/jsprim/node_modules/verror/CONTRIBUTING.md
generated
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
# Contributing
|
||||
|
||||
This repository uses [cr.joyent.us](https://cr.joyent.us) (Gerrit) for new
|
||||
changes. Anyone can submit changes. To get started, see the [cr.joyent.us user
|
||||
guide](https://github.com/joyent/joyent-gerrit/blob/master/docs/user/README.md).
|
||||
This repo does not use GitHub pull requests.
|
||||
|
||||
See the [Joyent Engineering
|
||||
Guidelines](https://github.com/joyent/eng/blob/master/docs/index.md) for general
|
||||
best practices expected in this repository.
|
||||
|
||||
Contributions should be "make prepush" clean. The "prepush" target runs the
|
||||
"check" target, which requires these separate tools:
|
||||
|
||||
* https://github.com/davepacheco/jsstyle
|
||||
* https://github.com/davepacheco/javascriptlint
|
||||
|
||||
If you're changing something non-trivial or user-facing, you may want to submit
|
||||
an issue first.
|
||||
19
resources/app/node_modules/jsprim/node_modules/verror/LICENSE
generated
vendored
Normal file
19
resources/app/node_modules/jsprim/node_modules/verror/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
Copyright (c) 2016, Joyent, Inc. All rights reserved.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE
|
||||
451
resources/app/node_modules/jsprim/node_modules/verror/lib/verror.js
generated
vendored
Normal file
451
resources/app/node_modules/jsprim/node_modules/verror/lib/verror.js
generated
vendored
Normal file
@@ -0,0 +1,451 @@
|
||||
/*
|
||||
* verror.js: richer JavaScript errors
|
||||
*/
|
||||
|
||||
var mod_assertplus = require('assert-plus');
|
||||
var mod_util = require('util');
|
||||
|
||||
var mod_extsprintf = require('extsprintf');
|
||||
var mod_isError = require('core-util-is').isError;
|
||||
var sprintf = mod_extsprintf.sprintf;
|
||||
|
||||
/*
|
||||
* Public interface
|
||||
*/
|
||||
|
||||
/* So you can 'var VError = require('verror')' */
|
||||
module.exports = VError;
|
||||
/* For compatibility */
|
||||
VError.VError = VError;
|
||||
/* Other exported classes */
|
||||
VError.SError = SError;
|
||||
VError.WError = WError;
|
||||
VError.MultiError = MultiError;
|
||||
|
||||
/*
|
||||
* Common function used to parse constructor arguments for VError, WError, and
|
||||
* SError. Named arguments to this function:
|
||||
*
|
||||
* strict force strict interpretation of sprintf arguments, even
|
||||
* if the options in "argv" don't say so
|
||||
*
|
||||
* argv error's constructor arguments, which are to be
|
||||
* interpreted as described in README.md. For quick
|
||||
* reference, "argv" has one of the following forms:
|
||||
*
|
||||
* [ sprintf_args... ] (argv[0] is a string)
|
||||
* [ cause, sprintf_args... ] (argv[0] is an Error)
|
||||
* [ options, sprintf_args... ] (argv[0] is an object)
|
||||
*
|
||||
* This function normalizes these forms, producing an object with the following
|
||||
* properties:
|
||||
*
|
||||
* options equivalent to "options" in third form. This will never
|
||||
* be a direct reference to what the caller passed in
|
||||
* (i.e., it may be a shallow copy), so it can be freely
|
||||
* modified.
|
||||
*
|
||||
* shortmessage result of sprintf(sprintf_args), taking options.strict
|
||||
* into account as described in README.md.
|
||||
*/
|
||||
function parseConstructorArguments(args)
|
||||
{
|
||||
var argv, options, sprintf_args, shortmessage, k;
|
||||
|
||||
mod_assertplus.object(args, 'args');
|
||||
mod_assertplus.bool(args.strict, 'args.strict');
|
||||
mod_assertplus.array(args.argv, 'args.argv');
|
||||
argv = args.argv;
|
||||
|
||||
/*
|
||||
* First, figure out which form of invocation we've been given.
|
||||
*/
|
||||
if (argv.length === 0) {
|
||||
options = {};
|
||||
sprintf_args = [];
|
||||
} else if (mod_isError(argv[0])) {
|
||||
options = { 'cause': argv[0] };
|
||||
sprintf_args = argv.slice(1);
|
||||
} else if (typeof (argv[0]) === 'object') {
|
||||
options = {};
|
||||
for (k in argv[0]) {
|
||||
options[k] = argv[0][k];
|
||||
}
|
||||
sprintf_args = argv.slice(1);
|
||||
} else {
|
||||
mod_assertplus.string(argv[0],
|
||||
'first argument to VError, SError, or WError ' +
|
||||
'constructor must be a string, object, or Error');
|
||||
options = {};
|
||||
sprintf_args = argv;
|
||||
}
|
||||
|
||||
/*
|
||||
* Now construct the error's message.
|
||||
*
|
||||
* extsprintf (which we invoke here with our caller's arguments in order
|
||||
* to construct this Error's message) is strict in its interpretation of
|
||||
* values to be processed by the "%s" specifier. The value passed to
|
||||
* extsprintf must actually be a string or something convertible to a
|
||||
* String using .toString(). Passing other values (notably "null" and
|
||||
* "undefined") is considered a programmer error. The assumption is
|
||||
* that if you actually want to print the string "null" or "undefined",
|
||||
* then that's easy to do that when you're calling extsprintf; on the
|
||||
* other hand, if you did NOT want that (i.e., there's actually a bug
|
||||
* where the program assumes some variable is non-null and tries to
|
||||
* print it, which might happen when constructing a packet or file in
|
||||
* some specific format), then it's better to stop immediately than
|
||||
* produce bogus output.
|
||||
*
|
||||
* However, sometimes the bug is only in the code calling VError, and a
|
||||
* programmer might prefer to have the error message contain "null" or
|
||||
* "undefined" rather than have the bug in the error path crash the
|
||||
* program (making the first bug harder to identify). For that reason,
|
||||
* by default VError converts "null" or "undefined" arguments to their
|
||||
* string representations and passes those to extsprintf. Programmers
|
||||
* desiring the strict behavior can use the SError class or pass the
|
||||
* "strict" option to the VError constructor.
|
||||
*/
|
||||
mod_assertplus.object(options);
|
||||
if (!options.strict && !args.strict) {
|
||||
sprintf_args = sprintf_args.map(function (a) {
|
||||
return (a === null ? 'null' :
|
||||
a === undefined ? 'undefined' : a);
|
||||
});
|
||||
}
|
||||
|
||||
if (sprintf_args.length === 0) {
|
||||
shortmessage = '';
|
||||
} else {
|
||||
shortmessage = sprintf.apply(null, sprintf_args);
|
||||
}
|
||||
|
||||
return ({
|
||||
'options': options,
|
||||
'shortmessage': shortmessage
|
||||
});
|
||||
}
|
||||
|
||||
/*
|
||||
* See README.md for reference documentation.
|
||||
*/
|
||||
function VError()
|
||||
{
|
||||
var args, obj, parsed, cause, ctor, message, k;
|
||||
|
||||
args = Array.prototype.slice.call(arguments, 0);
|
||||
|
||||
/*
|
||||
* This is a regrettable pattern, but JavaScript's built-in Error class
|
||||
* is defined to work this way, so we allow the constructor to be called
|
||||
* without "new".
|
||||
*/
|
||||
if (!(this instanceof VError)) {
|
||||
obj = Object.create(VError.prototype);
|
||||
VError.apply(obj, arguments);
|
||||
return (obj);
|
||||
}
|
||||
|
||||
/*
|
||||
* For convenience and backwards compatibility, we support several
|
||||
* different calling forms. Normalize them here.
|
||||
*/
|
||||
parsed = parseConstructorArguments({
|
||||
'argv': args,
|
||||
'strict': false
|
||||
});
|
||||
|
||||
/*
|
||||
* If we've been given a name, apply it now.
|
||||
*/
|
||||
if (parsed.options.name) {
|
||||
mod_assertplus.string(parsed.options.name,
|
||||
'error\'s "name" must be a string');
|
||||
this.name = parsed.options.name;
|
||||
}
|
||||
|
||||
/*
|
||||
* For debugging, we keep track of the original short message (attached
|
||||
* this Error particularly) separately from the complete message (which
|
||||
* includes the messages of our cause chain).
|
||||
*/
|
||||
this.jse_shortmsg = parsed.shortmessage;
|
||||
message = parsed.shortmessage;
|
||||
|
||||
/*
|
||||
* If we've been given a cause, record a reference to it and update our
|
||||
* message appropriately.
|
||||
*/
|
||||
cause = parsed.options.cause;
|
||||
if (cause) {
|
||||
mod_assertplus.ok(mod_isError(cause), 'cause is not an Error');
|
||||
this.jse_cause = cause;
|
||||
|
||||
if (!parsed.options.skipCauseMessage) {
|
||||
message += ': ' + cause.message;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* If we've been given an object with properties, shallow-copy that
|
||||
* here. We don't want to use a deep copy in case there are non-plain
|
||||
* objects here, but we don't want to use the original object in case
|
||||
* the caller modifies it later.
|
||||
*/
|
||||
this.jse_info = {};
|
||||
if (parsed.options.info) {
|
||||
for (k in parsed.options.info) {
|
||||
this.jse_info[k] = parsed.options.info[k];
|
||||
}
|
||||
}
|
||||
|
||||
this.message = message;
|
||||
Error.call(this, message);
|
||||
|
||||
if (Error.captureStackTrace) {
|
||||
ctor = parsed.options.constructorOpt || this.constructor;
|
||||
Error.captureStackTrace(this, ctor);
|
||||
}
|
||||
|
||||
return (this);
|
||||
}
|
||||
|
||||
mod_util.inherits(VError, Error);
|
||||
VError.prototype.name = 'VError';
|
||||
|
||||
VError.prototype.toString = function ve_toString()
|
||||
{
|
||||
var str = (this.hasOwnProperty('name') && this.name ||
|
||||
this.constructor.name || this.constructor.prototype.name);
|
||||
if (this.message)
|
||||
str += ': ' + this.message;
|
||||
|
||||
return (str);
|
||||
};
|
||||
|
||||
/*
|
||||
* This method is provided for compatibility. New callers should use
|
||||
* VError.cause() instead. That method also uses the saner `null` return value
|
||||
* when there is no cause.
|
||||
*/
|
||||
VError.prototype.cause = function ve_cause()
|
||||
{
|
||||
var cause = VError.cause(this);
|
||||
return (cause === null ? undefined : cause);
|
||||
};
|
||||
|
||||
/*
|
||||
* Static methods
|
||||
*
|
||||
* These class-level methods are provided so that callers can use them on
|
||||
* instances of Errors that are not VErrors. New interfaces should be provided
|
||||
* only using static methods to eliminate the class of programming mistake where
|
||||
* people fail to check whether the Error object has the corresponding methods.
|
||||
*/
|
||||
|
||||
VError.cause = function (err)
|
||||
{
|
||||
mod_assertplus.ok(mod_isError(err), 'err must be an Error');
|
||||
return (mod_isError(err.jse_cause) ? err.jse_cause : null);
|
||||
};
|
||||
|
||||
VError.info = function (err)
|
||||
{
|
||||
var rv, cause, k;
|
||||
|
||||
mod_assertplus.ok(mod_isError(err), 'err must be an Error');
|
||||
cause = VError.cause(err);
|
||||
if (cause !== null) {
|
||||
rv = VError.info(cause);
|
||||
} else {
|
||||
rv = {};
|
||||
}
|
||||
|
||||
if (typeof (err.jse_info) == 'object' && err.jse_info !== null) {
|
||||
for (k in err.jse_info) {
|
||||
rv[k] = err.jse_info[k];
|
||||
}
|
||||
}
|
||||
|
||||
return (rv);
|
||||
};
|
||||
|
||||
VError.findCauseByName = function (err, name)
|
||||
{
|
||||
var cause;
|
||||
|
||||
mod_assertplus.ok(mod_isError(err), 'err must be an Error');
|
||||
mod_assertplus.string(name, 'name');
|
||||
mod_assertplus.ok(name.length > 0, 'name cannot be empty');
|
||||
|
||||
for (cause = err; cause !== null; cause = VError.cause(cause)) {
|
||||
mod_assertplus.ok(mod_isError(cause));
|
||||
if (cause.name == name) {
|
||||
return (cause);
|
||||
}
|
||||
}
|
||||
|
||||
return (null);
|
||||
};
|
||||
|
||||
VError.hasCauseWithName = function (err, name)
|
||||
{
|
||||
return (VError.findCauseByName(err, name) !== null);
|
||||
};
|
||||
|
||||
VError.fullStack = function (err)
|
||||
{
|
||||
mod_assertplus.ok(mod_isError(err), 'err must be an Error');
|
||||
|
||||
var cause = VError.cause(err);
|
||||
|
||||
if (cause) {
|
||||
return (err.stack + '\ncaused by: ' + VError.fullStack(cause));
|
||||
}
|
||||
|
||||
return (err.stack);
|
||||
};
|
||||
|
||||
VError.errorFromList = function (errors)
|
||||
{
|
||||
mod_assertplus.arrayOfObject(errors, 'errors');
|
||||
|
||||
if (errors.length === 0) {
|
||||
return (null);
|
||||
}
|
||||
|
||||
errors.forEach(function (e) {
|
||||
mod_assertplus.ok(mod_isError(e));
|
||||
});
|
||||
|
||||
if (errors.length == 1) {
|
||||
return (errors[0]);
|
||||
}
|
||||
|
||||
return (new MultiError(errors));
|
||||
};
|
||||
|
||||
VError.errorForEach = function (err, func)
|
||||
{
|
||||
mod_assertplus.ok(mod_isError(err), 'err must be an Error');
|
||||
mod_assertplus.func(func, 'func');
|
||||
|
||||
if (err instanceof MultiError) {
|
||||
err.errors().forEach(function iterError(e) { func(e); });
|
||||
} else {
|
||||
func(err);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
* SError is like VError, but stricter about types. You cannot pass "null" or
|
||||
* "undefined" as string arguments to the formatter.
|
||||
*/
|
||||
function SError()
|
||||
{
|
||||
var args, obj, parsed, options;
|
||||
|
||||
args = Array.prototype.slice.call(arguments, 0);
|
||||
if (!(this instanceof SError)) {
|
||||
obj = Object.create(SError.prototype);
|
||||
SError.apply(obj, arguments);
|
||||
return (obj);
|
||||
}
|
||||
|
||||
parsed = parseConstructorArguments({
|
||||
'argv': args,
|
||||
'strict': true
|
||||
});
|
||||
|
||||
options = parsed.options;
|
||||
VError.call(this, options, '%s', parsed.shortmessage);
|
||||
|
||||
return (this);
|
||||
}
|
||||
|
||||
/*
|
||||
* We don't bother setting SError.prototype.name because once constructed,
|
||||
* SErrors are just like VErrors.
|
||||
*/
|
||||
mod_util.inherits(SError, VError);
|
||||
|
||||
|
||||
/*
|
||||
* Represents a collection of errors for the purpose of consumers that generally
|
||||
* only deal with one error. Callers can extract the individual errors
|
||||
* contained in this object, but may also just treat it as a normal single
|
||||
* error, in which case a summary message will be printed.
|
||||
*/
|
||||
function MultiError(errors)
|
||||
{
|
||||
mod_assertplus.array(errors, 'list of errors');
|
||||
mod_assertplus.ok(errors.length > 0, 'must be at least one error');
|
||||
this.ase_errors = errors;
|
||||
|
||||
VError.call(this, {
|
||||
'cause': errors[0]
|
||||
}, 'first of %d error%s', errors.length, errors.length == 1 ? '' : 's');
|
||||
}
|
||||
|
||||
mod_util.inherits(MultiError, VError);
|
||||
MultiError.prototype.name = 'MultiError';
|
||||
|
||||
MultiError.prototype.errors = function me_errors()
|
||||
{
|
||||
return (this.ase_errors.slice(0));
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
* See README.md for reference details.
|
||||
*/
|
||||
function WError()
|
||||
{
|
||||
var args, obj, parsed, options;
|
||||
|
||||
args = Array.prototype.slice.call(arguments, 0);
|
||||
if (!(this instanceof WError)) {
|
||||
obj = Object.create(WError.prototype);
|
||||
WError.apply(obj, args);
|
||||
return (obj);
|
||||
}
|
||||
|
||||
parsed = parseConstructorArguments({
|
||||
'argv': args,
|
||||
'strict': false
|
||||
});
|
||||
|
||||
options = parsed.options;
|
||||
options['skipCauseMessage'] = true;
|
||||
VError.call(this, options, '%s', parsed.shortmessage);
|
||||
|
||||
return (this);
|
||||
}
|
||||
|
||||
mod_util.inherits(WError, VError);
|
||||
WError.prototype.name = 'WError';
|
||||
|
||||
WError.prototype.toString = function we_toString()
|
||||
{
|
||||
var str = (this.hasOwnProperty('name') && this.name ||
|
||||
this.constructor.name || this.constructor.prototype.name);
|
||||
if (this.message)
|
||||
str += ': ' + this.message;
|
||||
if (this.jse_cause && this.jse_cause.message)
|
||||
str += '; caused by ' + this.jse_cause.toString();
|
||||
|
||||
return (str);
|
||||
};
|
||||
|
||||
/*
|
||||
* For purely historical reasons, WError's cause() function allows you to set
|
||||
* the cause.
|
||||
*/
|
||||
WError.prototype.cause = function we_cause(c)
|
||||
{
|
||||
if (mod_isError(c))
|
||||
this.jse_cause = c;
|
||||
|
||||
return (this.jse_cause);
|
||||
};
|
||||
19
resources/app/node_modules/jsprim/node_modules/verror/package.json
generated
vendored
Normal file
19
resources/app/node_modules/jsprim/node_modules/verror/package.json
generated
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
{
|
||||
"name": "verror",
|
||||
"version": "1.10.0",
|
||||
"description": "richer JavaScript errors",
|
||||
"main": "./lib/verror.js",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/davepacheco/node-verror.git"
|
||||
},
|
||||
"dependencies": {
|
||||
"assert-plus": "^1.0.0",
|
||||
"core-util-is": "1.0.2",
|
||||
"extsprintf": "^1.2.0"
|
||||
},
|
||||
"engines": [
|
||||
"node >=0.6.0"
|
||||
],
|
||||
"license": "MIT"
|
||||
}
|
||||
20
resources/app/node_modules/jsprim/package.json
generated
vendored
Normal file
20
resources/app/node_modules/jsprim/package.json
generated
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
{
|
||||
"name": "jsprim",
|
||||
"version": "1.4.2",
|
||||
"description": "utilities for primitive JavaScript types",
|
||||
"main": "./lib/jsprim.js",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/joyent/node-jsprim.git"
|
||||
},
|
||||
"dependencies": {
|
||||
"assert-plus": "1.0.0",
|
||||
"extsprintf": "1.3.0",
|
||||
"json-schema": "0.4.0",
|
||||
"verror": "1.10.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=0.6.0"
|
||||
},
|
||||
"license": "MIT"
|
||||
}
|
||||
Reference in New Issue
Block a user