mirror of
https://github.com/mgerb/mywebsite
synced 2026-01-12 10:52:47 +00:00
updated bunch of file paths and changed the way posts are loaded
This commit is contained in:
30
node_modules/jsprim/CHANGES.md
generated
vendored
Normal file
30
node_modules/jsprim/CHANGES.md
generated
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
# Changelog
|
||||
|
||||
## not yet released
|
||||
|
||||
None yet.
|
||||
|
||||
## 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
node_modules/jsprim/LICENSE
generated
vendored
Normal file
19
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
|
||||
228
node_modules/jsprim/README.md
generated
vendored
Normal file
228
node_modules/jsprim/README.md
generated
vendored
Normal file
@@ -0,0 +1,228 @@
|
||||
# jsprim: utilities for primitive JavaScript types
|
||||
|
||||
This module provides miscellaneous facilities for working with strings,
|
||||
numbers, dates, and objects and arrays of these basic types.
|
||||
|
||||
|
||||
### deepCopy(obj)
|
||||
|
||||
Creates a deep copy of a primitive type, object, or array of primitive types.
|
||||
|
||||
|
||||
### deepEqual(obj1, obj2)
|
||||
|
||||
Returns whether two objects are equal.
|
||||
|
||||
|
||||
### isEmpty(obj)
|
||||
|
||||
Returns true if the given object has no properties and false otherwise. This
|
||||
is O(1) (unlike `Object.keys(obj).length === 0`, which is O(N)).
|
||||
|
||||
|
||||
### forEachKey(obj, callback)
|
||||
|
||||
Like Array.forEach, but iterates properties of an object rather than elements
|
||||
of an array. Equivalent to:
|
||||
|
||||
for (var key in obj)
|
||||
callback(key, obj[key]);
|
||||
|
||||
|
||||
### flattenObject(obj, depth)
|
||||
|
||||
Flattens an object up to a given level of nesting, returning an array of arrays
|
||||
of length "depth + 1", where the first "depth" elements correspond to flattened
|
||||
columns and the last element contains the remaining object . For example:
|
||||
|
||||
flattenObject({
|
||||
'I': {
|
||||
'A': {
|
||||
'i': {
|
||||
'datum1': [ 1, 2 ],
|
||||
'datum2': [ 3, 4 ]
|
||||
},
|
||||
'ii': {
|
||||
'datum1': [ 3, 4 ]
|
||||
}
|
||||
},
|
||||
'B': {
|
||||
'i': {
|
||||
'datum1': [ 5, 6 ]
|
||||
},
|
||||
'ii': {
|
||||
'datum1': [ 7, 8 ],
|
||||
'datum2': [ 3, 4 ],
|
||||
},
|
||||
'iii': {
|
||||
}
|
||||
}
|
||||
},
|
||||
'II': {
|
||||
'A': {
|
||||
'i': {
|
||||
'datum1': [ 1, 2 ],
|
||||
'datum2': [ 3, 4 ]
|
||||
}
|
||||
}
|
||||
}
|
||||
}, 3)
|
||||
|
||||
becomes:
|
||||
|
||||
[
|
||||
[ 'I', 'A', 'i', { 'datum1': [ 1, 2 ], 'datum2': [ 3, 4 ] } ],
|
||||
[ 'I', 'A', 'ii', { 'datum1': [ 3, 4 ] } ],
|
||||
[ 'I', 'B', 'i', { 'datum1': [ 5, 6 ] } ],
|
||||
[ 'I', 'B', 'ii', { 'datum1': [ 7, 8 ], 'datum2': [ 3, 4 ] } ],
|
||||
[ 'I', 'B', 'iii', {} ],
|
||||
[ 'II', 'A', 'i', { 'datum1': [ 1, 2 ], 'datum2': [ 3, 4 ] } ]
|
||||
]
|
||||
|
||||
This function is strict: "depth" must be a non-negative integer and "obj" must
|
||||
be a non-null object with at least "depth" levels of nesting under all keys.
|
||||
|
||||
|
||||
### flattenIter(obj, depth, func)
|
||||
|
||||
This is similar to `flattenObject` except that instead of returning an array,
|
||||
this function invokes `func(entry)` for each `entry` in the array that
|
||||
`flattenObject` would return. `flattenIter(obj, depth, func)` is logically
|
||||
equivalent to `flattenObject(obj, depth).forEach(func)`. Importantly, this
|
||||
version never constructs the full array. Its memory usage is O(depth) rather
|
||||
than O(n) (where `n` is the number of flattened elements).
|
||||
|
||||
There's another difference between `flattenObject` and `flattenIter` that's
|
||||
related to the special case where `depth === 0`. In this case, `flattenObject`
|
||||
omits the array wrapping `obj` (which is regrettable).
|
||||
|
||||
|
||||
### pluck(obj, key)
|
||||
|
||||
Fetch nested property "key" from object "obj", traversing objects as needed.
|
||||
For example, `pluck(obj, "foo.bar.baz")` is roughly equivalent to
|
||||
`obj.foo.bar.baz`, except that:
|
||||
|
||||
1. If traversal fails, the resulting value is undefined, and no error is
|
||||
thrown. For example, `pluck({}, "foo.bar")` is just undefined.
|
||||
2. If "obj" has property "key" directly (without traversing), the
|
||||
corresponding property is returned. For example,
|
||||
`pluck({ 'foo.bar': 1 }, 'foo.bar')` is 1, not undefined. This is also
|
||||
true recursively, so `pluck({ 'a': { 'foo.bar': 1 } }, 'a.foo.bar')` is
|
||||
also 1, not undefined.
|
||||
|
||||
|
||||
### randElt(array)
|
||||
|
||||
Returns an element from "array" selected uniformly at random. If "array" is
|
||||
empty, throws an Error.
|
||||
|
||||
|
||||
### startsWith(str, prefix)
|
||||
|
||||
Returns true if the given string starts with the given prefix and false
|
||||
otherwise.
|
||||
|
||||
|
||||
### endsWith(str, suffix)
|
||||
|
||||
Returns true if the given string ends with the given suffix and false
|
||||
otherwise.
|
||||
|
||||
|
||||
### iso8601(date)
|
||||
|
||||
Converts a Date object to an ISO8601 date string of the form
|
||||
"YYYY-MM-DDTHH:MM:SS.sssZ". This format is not customizable.
|
||||
|
||||
|
||||
### parseDateTime(str)
|
||||
|
||||
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., strings containing small numbers).
|
||||
|
||||
|
||||
### hrtimeDiff(timeA, timeB)
|
||||
|
||||
Given two hrtime readings (as from Node's `process.hrtime()`), where timeA is
|
||||
later than timeB, compute the difference and return that as an hrtime. It is
|
||||
illegal to invoke this for a pair of times where timeB is newer than timeA.
|
||||
|
||||
### hrtimeAdd(timeA, timeB)
|
||||
|
||||
Add two hrtime intervals (as from Node's `process.hrtime()`), returning a new
|
||||
hrtime interval array. This function does not modify either input argument.
|
||||
|
||||
|
||||
### hrtimeAccum(timeA, timeB)
|
||||
|
||||
Add two hrtime intervals (as from Node's `process.hrtime()`), storing the
|
||||
result in `timeA`. This function overwrites (and returns) the first argument
|
||||
passed in.
|
||||
|
||||
|
||||
### hrtimeNanosec(timeA), hrtimeMicrosec(timeA), hrtimeMillisec(timeA)
|
||||
|
||||
This suite of functions converts a hrtime interval (as from Node's
|
||||
`process.hrtime()`) into a scalar number of nanoseconds, microseconds or
|
||||
milliseconds. Results are truncated, as with `Math.floor()`.
|
||||
|
||||
|
||||
### validateJsonObject(schema, object)
|
||||
|
||||
Uses JSON validation (via JSV) to validate the given object against the given
|
||||
schema. On success, returns null. On failure, *returns* (does not throw) a
|
||||
useful Error object.
|
||||
|
||||
|
||||
### extraProperties(object, allowed)
|
||||
|
||||
Check an object for unexpected properties. Accepts the object to check, and an
|
||||
array of allowed property name strings. If extra properties are detected, an
|
||||
array of extra property names is returned. If no properties other than those
|
||||
in the allowed list are present on the object, the returned array will be of
|
||||
zero length.
|
||||
|
||||
### mergeObjects(provided, overrides, defaults)
|
||||
|
||||
Merge properties from objects "provided", "overrides", and "defaults". The
|
||||
intended use case is for functions that accept named arguments in an "args"
|
||||
object, but want to provide some default values and override other values. In
|
||||
that case, "provided" is what the caller specified, "overrides" are what the
|
||||
function wants to override, and "defaults" contains default values.
|
||||
|
||||
The function starts with the values in "defaults", overrides them with the
|
||||
values in "provided", and then overrides those with the values in "overrides".
|
||||
For convenience, any of these objects may be falsey, in which case they will be
|
||||
ignored. The input objects are never modified, but properties in the returned
|
||||
object are not deep-copied.
|
||||
|
||||
For example:
|
||||
|
||||
mergeObjects(undefined, { 'objectMode': true }, { 'highWaterMark': 0 })
|
||||
|
||||
returns:
|
||||
|
||||
{ 'objectMode': true, 'highWaterMark': 0 }
|
||||
|
||||
For another example:
|
||||
|
||||
mergeObjects(
|
||||
{ 'highWaterMark': 16, 'objectMode': 7 }, /* from caller */
|
||||
{ 'objectMode': true }, /* overrides */
|
||||
{ 'highWaterMark': 0 }); /* default */
|
||||
|
||||
returns:
|
||||
|
||||
{ 'objectMode': true, 'highWaterMark': 16 }
|
||||
|
||||
|
||||
# Contributing
|
||||
|
||||
Code should be "make check" clean. This target assumes that
|
||||
[jsl](http://github.com/davepacheco/javascriptlint) and
|
||||
[jsstyle](http://github.com/davepacheco/jsstyle) are on your path.
|
||||
|
||||
New tests should generally accompany new functions and bug fixes. The tests
|
||||
should pass cleanly (run tests/basic.js).
|
||||
478
node_modules/jsprim/lib/jsprim.js
generated
vendored
Normal file
478
node_modules/jsprim/lib/jsprim.js
generated
vendored
Normal file
@@ -0,0 +1,478 @@
|
||||
/*
|
||||
* lib/jsprim.js: utilities for primitive JavaScript types
|
||||
*/
|
||||
|
||||
var mod_assert = require('assert');
|
||||
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.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.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 forEachKey(obj, callback)
|
||||
{
|
||||
for (var key in obj)
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
73
node_modules/jsprim/package.json
generated
vendored
Normal file
73
node_modules/jsprim/package.json
generated
vendored
Normal file
@@ -0,0 +1,73 @@
|
||||
{
|
||||
"_args": [
|
||||
[
|
||||
"jsprim@^1.2.2",
|
||||
"/home/mitchell/Desktop/test-mywebsite/mywebsite/node_modules/http-signature"
|
||||
]
|
||||
],
|
||||
"_from": "jsprim@>=1.2.2 <2.0.0",
|
||||
"_id": "jsprim@1.2.2",
|
||||
"_inCache": true,
|
||||
"_installable": true,
|
||||
"_location": "/jsprim",
|
||||
"_nodeVersion": "0.12.2",
|
||||
"_npmUser": {
|
||||
"email": "dap@cs.brown.edu",
|
||||
"name": "dap"
|
||||
},
|
||||
"_npmVersion": "2.7.4",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"name": "jsprim",
|
||||
"raw": "jsprim@^1.2.2",
|
||||
"rawSpec": "^1.2.2",
|
||||
"scope": null,
|
||||
"spec": ">=1.2.2 <2.0.0",
|
||||
"type": "range"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/http-signature"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/jsprim/-/jsprim-1.2.2.tgz",
|
||||
"_shasum": "f20c906ac92abd58e3b79ac8bc70a48832512da1",
|
||||
"_shrinkwrap": null,
|
||||
"_spec": "jsprim@^1.2.2",
|
||||
"_where": "/home/mitchell/Desktop/test-mywebsite/mywebsite/node_modules/http-signature",
|
||||
"bugs": {
|
||||
"url": "https://github.com/davepacheco/node-jsprim/issues"
|
||||
},
|
||||
"dependencies": {
|
||||
"extsprintf": "1.0.2",
|
||||
"json-schema": "0.2.2",
|
||||
"verror": "1.3.6"
|
||||
},
|
||||
"description": "utilities for primitive JavaScript types",
|
||||
"devDependencies": {},
|
||||
"directories": {},
|
||||
"dist": {
|
||||
"shasum": "f20c906ac92abd58e3b79ac8bc70a48832512da1",
|
||||
"tarball": "http://registry.npmjs.org/jsprim/-/jsprim-1.2.2.tgz"
|
||||
},
|
||||
"engines": [
|
||||
"node >=0.6.0"
|
||||
],
|
||||
"gitHead": "0e709876c35eddfe4c1f95104ac3c4abfc9dab84",
|
||||
"homepage": "https://github.com/davepacheco/node-jsprim",
|
||||
"license": "MIT",
|
||||
"main": "./lib/jsprim.js",
|
||||
"maintainers": [
|
||||
{
|
||||
"name": "dap",
|
||||
"email": "dap@cs.brown.edu"
|
||||
}
|
||||
],
|
||||
"name": "jsprim",
|
||||
"optionalDependencies": {},
|
||||
"readme": "ERROR: No README data found!",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/davepacheco/node-jsprim.git"
|
||||
},
|
||||
"scripts": {},
|
||||
"version": "1.2.2"
|
||||
}
|
||||
Reference in New Issue
Block a user