File Index
+ + +jsv.js
+ JSV: JSON Schema Validator +A JavaScript implementation of a extendable, fully compliant JSON Schema validator. +-
+
+
- Author: +
- Gary Court + + +
- Version: +
- 4.0 + + + +
+ + +
diff --git a/html/RentForCamp/app.js b/html/RentForCamp/app.js
index 6856e02..acee97d 100644
--- a/html/RentForCamp/app.js
+++ b/html/RentForCamp/app.js
@@ -7,6 +7,10 @@ var session = require('express-session');
var helmet = require('helmet');
var logger = require('morgan');
+const Log = require('./app/logging');
+var MainConf = require('./config.json');
+var DB = require('./app/database');
+
var indexRouter = require('./routes/index');
var app = express();
@@ -24,6 +28,10 @@ app.use(helmet());
app.use(lessMiddleware(path.join(__dirname, 'public')));
app.use(express.static(path.join(__dirname, 'public')));
+app.set('LOG', Log);
+app.set('CONF', MainConf);
+app.set('DB', DB.init(app));
+
app.use(session({
secret: 'RentForCamp.s3Cur3',
name: 'sessionId',
diff --git a/html/RentForCamp/app/database.js b/html/RentForCamp/app/database.js
new file mode 100644
index 0000000..ddcae84
--- /dev/null
+++ b/html/RentForCamp/app/database.js
@@ -0,0 +1,38 @@
+var mysql = require('mysql');
+
+var app = null
+var pool = null
+const connectionLimit = 66
+
+
+exports.init = function(express) {
+ app = express
+
+ app.get('LOG').log('Database | Server to connect to is ' + app.get('CONF').database.host + '')
+
+ pool = mysql.createPool({
+ connectionLimit : connectionLimit,
+ host : app.get('CONF').database.host,
+ port : app.get('CONF').database.port,
+ database : app.get('CONF').database.database,
+ user : app.get('CONF').database.user,
+ password : app.get('CONF').database.password,
+ waitForConnections : true
+ });
+
+ var connectionCountTemp = 0;
+ setInterval(function() {
+ const connectionCount = pool._freeConnections.length
+ if(connectionCount != connectionCountTemp) {
+ connectionCountTemp = connectionCount
+
+ if(connectionCount > (connectionLimit / 2)) {
+ app.get('LOG').error(`Database | Connection count: ${connectionCount}`)
+ } else {
+ app.get('LOG').debug(`Connection count: ${connectionCount}`)
+ }
+ }
+ }, 1000)
+
+ return this;
+}
\ No newline at end of file
diff --git a/html/RentForCamp/app/helper.js b/html/RentForCamp/app/helper.js
new file mode 100644
index 0000000..0df0372
--- /dev/null
+++ b/html/RentForCamp/app/helper.js
@@ -0,0 +1,139 @@
+/**
+ * File: app/helper.js
+ * Author: Gerrit Linnemann
+ *
+ * Swiss-knife.
+ */
+
+
+// load the things we need
+var logger = require('./logging')
+, jsonlint = require("jsonlint");
+
+
+exports.init = function(express) {
+
+ return this;
+}
+
+exports.timeSince = function(date) {
+
+ var seconds = Math.floor((new Date() - date) / 1000);
+
+ var interval = Math.floor(seconds / 31536000);
+
+ if (interval > 1) {
+ return interval + " years";
+ }
+ interval = Math.floor(seconds / 2592000);
+ if (interval > 1) {
+ return interval + " months";
+ }
+ interval = Math.floor(seconds / 86400);
+ if (interval > 1) {
+ return interval + " days";
+ }
+ interval = Math.floor(seconds / 3600);
+ if (interval > 1) {
+ return interval + " hours";
+ }
+ interval = Math.floor(seconds / 60);
+ if (interval > 1) {
+ return interval + " minutes";
+ }
+ return Math.floor(seconds) + " seconds";
+}
+
+exports.isOlderThanXMinutes = function(date, minutes) {
+ var seconds = Math.floor((new Date() - date) / 1000)
+ interval = seconds / 60
+
+ return interval > minutes
+}
+
+exports.dayOfYear = function() {
+ var now = new Date();
+ var start = new Date(now.getFullYear(), 0, 0);
+ var diff = now - start;
+ var oneDay = 1000 * 60 * 60 * 24;
+ var day = Math.floor(diff / oneDay);
+
+ logger.trace('Helper | day of year: ' + day);
+ return day;
+}
+
+exports.isJSON = function(jsonString) {
+ try {
+ return jsonlint.parse(jsonString)
+ } catch (e) {
+ if(logger.isDebug()) {
+ logger.error(e.message)
+ //logger.inspect('Error checking JSON', e)
+ }
+ }
+
+ return false;
+}
+
+exports.isArray = function(toCheck) {
+ return (Object.prototype.toString.call( toCheck ) === '[object Array]');
+}
+
+exports.isDefinedAndNotNull = function(toCheck) {
+ return (
+ typeof toCheck !== 'undefined' &&
+ toCheck != null
+ );
+}
+
+exports.getRandomInt = function(min, max) {
+ min = Math.ceil(min);
+ max = Math.floor(max);
+ return Math.floor(Math.random() * (max - min + 1)) + min;
+}
+
+exports.bytesToSize = function(bytes, precision){
+ var kilobyte = 1024;
+ var megabyte = kilobyte * 1024;
+ var gigabyte = megabyte * 1024;
+ var terabyte = gigabyte * 1024;
+
+ if ((bytes >= 0) && (bytes < kilobyte)) {
+ return bytes + ' B';
+
+ } else if ((bytes >= kilobyte) && (bytes < megabyte)) {
+ return (bytes / kilobyte).toFixed(precision) + ' KB';
+
+ } else if ((bytes >= megabyte) && (bytes < gigabyte)) {
+ return (bytes / megabyte).toFixed(precision) + ' MB';
+
+ } else if ((bytes >= gigabyte) && (bytes < terabyte)) {
+ return (bytes / gigabyte).toFixed(precision) + ' GB';
+
+ } else if (bytes >= terabyte) {
+ return (bytes / terabyte).toFixed(precision) + ' TB';
+
+ } else {
+ return bytes + ' B';
+ }
+}
+
+/* private */
+function bytesToGB(bytes, precision) {
+ var kilobyte = 1024;
+ var megabyte = kilobyte * 1024;
+ var gigabyte = megabyte * 1024;
+ var terabyte = gigabyte * 1024;
+
+ return (bytes / gigabyte).toFixed(precision);
+}
+
+/* private */
+function bytesToMB(bytes, precision) {
+ var kilobyte = 1024;
+ var megabyte = kilobyte * 1024;
+ var gigabyte = megabyte * 1024;
+ var terabyte = gigabyte * 1024;
+
+ return (bytes / megabyte).toFixed(precision);
+}
diff --git a/html/RentForCamp/app/logging.js b/html/RentForCamp/app/logging.js
new file mode 100644
index 0000000..237172b
--- /dev/null
+++ b/html/RentForCamp/app/logging.js
@@ -0,0 +1,105 @@
+/**
+ * File: app/logging.js
+ * Author: Gerrit Linnemann
+ *
+ * Logging with several log-level.
+ * - debug: Printed only in development-state.
+ * - log: Needed log-output.
+ * - error: Prints log in error-level.
+ * - inspect: Prints a message and details of an object.
+ */
+
+
+// load the things we need
+var Conf = require('../config.json')
+, Inspect = require('eyespect').inspector()
+, Helper = require('./helper.js')
+, DateFormat = require('dateformat');
+
+
+var eyeFriendly = (Conf.logging.mode === 'friendly');
+var isTrace = (Conf.logging.trace === 'yes');
+var isDebug = true;
+
+
+exports.init = function(express) {
+ return this;
+}
+
+exports.isEyeFriendlyMode = function() {
+ return eyeFriendly;
+}
+
+exports.isTrace = function() {
+ return isTrace;
+}
+
+exports.isDebug = function() {
+ return isDebug;
+}
+
+exports.trace = function(msg) {
+ msg = DateFormat(new Date(), "yyyy-mm-dd h:MM:ss TT") + " TRACE " + msg;
+ if(isTrace) {
+ consoleOut(msg);
+ }
+}
+
+exports.debug = function(msg) {
+ msg = DateFormat(new Date(), "yyyy-mm-dd h:MM:ss TT") + " DEBUG " + msg;
+
+ if(isDebug) {
+ consoleOut(msg);
+ }
+}
+
+exports.log = function(msg) {
+ msg = DateFormat(new Date(), "yyyy-mm-dd h:MM:ss TT") + " INFO " + msg;
+ consoleOut(msg);
+}
+
+exports.error = function(msg) {
+ msg = DateFormat(new Date(), "yyyy-mm-dd h:MM:ss TT") + " ERROR " + msg;
+ consoleErr(msg);
+}
+
+exports.inspect = function(msg, content) {
+ msg = DateFormat(new Date(), "yyyy-mm-dd h:MM:ss TT") + " INSPECT " + msg;
+
+ if(eyeFriendly) {
+ Inspect(content, msg);
+ } else {
+ var msgOut = msg + (Helper.isDefinedAndNotNull(content) ? ": "+JSON.stringify(content) : "");
+ consoleOut(msgOut);
+ }
+}
+
+
+
+/* private */
+function consoleOut(msg, content) {
+ var hasContent = Helper.isDefinedAndNotNull(content);
+
+ if(hasContent) {
+ var msgAddon = (hasContent ? " | " + content : "");
+ if(Helper.isDefinedAndNotNull(msg)) {
+ console.log(msg + msgAddon);
+ }
+ } else if(Helper.isDefinedAndNotNull(msg)) {
+ console.log(msg);
+ }
+}
+
+/* private */
+function consoleErr(msg, content) {
+ var hasContent = Helper.isDefinedAndNotNull(content);
+
+ if(hasContent) {
+ var msgAddon = (hasContent ? " | " + content : "");
+ if(Helper.isDefinedAndNotNull(msg)) {
+ console.error(msg + msgAddon);
+ }
+ } else if(Helper.isDefinedAndNotNull(msg)) {
+ console.error(msg);
+ }
+}
\ No newline at end of file
diff --git a/html/RentForCamp/node_modules/.bin/jsonlint b/html/RentForCamp/node_modules/.bin/jsonlint
new file mode 120000
index 0000000..aefbf4e
--- /dev/null
+++ b/html/RentForCamp/node_modules/.bin/jsonlint
@@ -0,0 +1 @@
+../jsonlint/lib/cli.js
\ No newline at end of file
diff --git a/html/RentForCamp/node_modules/.bin/strip-ansi b/html/RentForCamp/node_modules/.bin/strip-ansi
new file mode 120000
index 0000000..b65c9f8
--- /dev/null
+++ b/html/RentForCamp/node_modules/.bin/strip-ansi
@@ -0,0 +1 @@
+../strip-ansi/cli.js
\ No newline at end of file
diff --git a/html/RentForCamp/node_modules/JSV/.project b/html/RentForCamp/node_modules/JSV/.project
new file mode 100644
index 0000000..75cc49c
--- /dev/null
+++ b/html/RentForCamp/node_modules/JSV/.project
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
+
+
Defined in: jsv.js.
+
+
| Constructor Attributes | +Constructor Name and Description | +
|---|---|
| + |
+
+ Environment()
+
+ An Environment is a sandbox of schemas thats behavior is different from other environments.
+ |
+
| Method Attributes | +Method Name and Description | +
|---|---|
| + |
+ clone()
+
+ Returns a clone of the target environment.
+ |
+
| + |
+
+ Creates an empty schema.
+ |
+
| + |
+ createInstance(data, uri)
+
+ Returns a new JSONInstance of the provided data.
+ |
+
| + |
+ createSchema(data, schema, uri)
+
+ Creates a new JSONSchema from the provided data, and registers it with the environment.
+ |
+
| + |
+ findSchema(uri)
+
+ Returns the schema registered with the provided URI.
+ |
+
| + |
+
+ Returns the default fragment delimiter of the environment.
+ |
+
| + |
+ getDefaultSchema()
+
+ Returns the default schema of the environment.
+ |
+
| + |
+ getOption(name)
+
+ Returns the specified environment option.
+ |
+
| + |
+
+ Sets the default fragment delimiter of the environment.
+ |
+
| + |
+ setDefaultSchemaURI(uri)
+
+ Sets the URI of the default schema for the environment.
+ |
+
| + |
+ setOption(name, value)
+
+ Sets the specified environment option to the specified value.
+ |
+
| + |
+ validate(instanceJSON, schemaJSON)
+
+ Validates both the provided schema and the provided instance, and returns a Report.
+ |
+
undefined, the environment's default schema will be used. If true, the instance's schema will be itself.undefined if not found+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + +
+
+
+
+
+
+
+
Defined in: jsv.js.
+
+
| Constructor Attributes | +Constructor Name and Description | +
|---|---|
| + |
+
+ InitializationError(instance, schema, attr, message, details)
+
+ The exception that is thrown when a schema fails to be created.
+ |
+
+
+
+
+
+
+
+
Defined in: jsv.js.
+
+
| Constructor Attributes | +Constructor Name and Description | +
|---|---|
| + |
+
+ JSONInstance(env, json, uri, fd)
+
+ A wrapper class for binding an Environment, URI and helper methods to an instance.
+ |
+
| Method Attributes | +Method Name and Description | +
|---|---|
| + |
+ equals(instance)
+
+ Return if the provided value is the same as the value of the instance.
+ |
+
| + |
+ getEnvironment()
+
+ Returns the environment the instance is bound to.
+ |
+
| + |
+ getProperties()
+
+ Returns all the property instances of the target instance.
+ |
+
| + |
+ getProperty(key)
+
+ Returns a JSONInstance of the value of the provided property name.
+ |
+
| + |
+ getPropertyNames()
+
+ Returns an array of the names of all the properties.
+ |
+
| + |
+ getType()
+
+ Returns the name of the type of the instance.
+ |
+
| + |
+ getURI()
+
+ Returns the URI of the instance.
+ |
+
| + |
+ getValue()
+
+ Returns the JSON value of the instance.
+ |
+
| + |
+ getValueOfProperty(key)
+
+ Returns the JSON value of the provided property name.
+ |
+
| + |
+ resolveURI(uri)
+
+ Returns a resolved URI of a provided relative URI against the URI of the instance.
+ |
+
If the target instance is an Object, then the method will return a hash table of JSONInstances of all the properties. If the target instance is an Array, then the method will return an array of JSONInstances of all the items.
+ + +instance.getProperty(key).getValue().
+
+
+
+
+
Extends
+ JSONInstance.
+
+
+
+
+
+
Defined in: jsv.js.
+
+
| Constructor Attributes | +Constructor Name and Description | +
|---|---|
| + |
+
+ JSONSchema(env, json, uri, schema)
+
+ This class binds a JSONInstance with a JSONSchema to provided context aware methods.
+ |
+
| Method Attributes | +Method Name and Description | +
|---|---|
| + |
+ getAttribute(key, arg)
+
+ Returns the value of the provided attribute name.
+ |
+
| + |
+ getAttributes()
+
+ Returns all the attributes of the schema.
+ |
+
| + |
+ getLink(rel, instance)
+
+ Convenience method for retrieving a link or link object from a schema.
+ |
+
| + |
+ getReference(name)
+
+ Returns the value of the provided reference name.
+ |
+
| + |
+ getSchema()
+
+ Returns the schema of the schema.
+ |
+
| + |
+ setReference(name, uri)
+
+ Set the provided reference to the given value.
+ |
+
| + |
+ validate(instance, report, parent, parentSchema, name)
+
+ Validates the provided instance against the target schema and returns a Report.
+ |
+
undefined, the environment's default schema will be used. If true, the instance's schema will be itself.This method is different from JSONInstance#getProperty as the named property is converted using a parser defined by the schema's schema before being returned. This makes the return value of this method attribute dependent.
+ + +schema.getAttribute("links", [rel, instance])[0];.
+
+
+ instance is provided, a string containing the resolve URI of the link is returned.
If instance is not provided, a link object is returned with details of the link.
If no link with the provided relationship exists, undefined is returned.fulldescribedbyundefined, a new Report is created.
+
+
+
+
+
+
+
Defined in: jsv.js.
+
+
| Constructor Attributes | +Constructor Name and Description | +
|---|---|
| + |
+
+ JSV
+
+ A globaly accessible object that provides the ability to create and manage Environments,
as well as providing utility methods.
+ |
+
| Method Attributes | +Method Name and Description | +
|---|---|
| <static> | +
+ JSV.createEnvironment(id)
+
+ Creates and returns a new Environment that is a clone of the environment registered with the provided ID.
+ |
+
| <static> | +
+ JSV.getDefaultEnvironmentID()
+
+ Returns the ID of the default environment.
+ |
+
| <static> | +
+ JSV.isJSONInstance(o)
+
+ Returns if the provide value is an instance of JSONInstance.
+ |
+
| <static> | +
+ JSV.isJSONSchema(o)
+
+ Returns if the provide value is an instance of JSONSchema.
+ |
+
| <static> | +
+ JSV.registerEnvironment(id, env)
+
+ Registers the provided Environment with the provided ID.
+ |
+
| <static> | +
+ JSV.setDefaultEnvironmentID(id)
+
+ Sets which registered ID is the default environment.
+ |
+
| Utility Method Attributes | +Utility Method Name and Description | +
|---|---|
| <static> | +
+ JSV.clone(o, deep)
+
+ Creates a copy of the target object.
+ |
+
| <static> | +
+ JSV.createObject(proto)
+
+ Return a new object that inherits all of the properties of the provided object.
+ |
+
| <static> | +
+ JSV.escapeURIComponent(str)
+
+ Properly escapes a URI component for embedding into a URI string.
+ |
+
| <static> | +
+ JSV.filterArray(arr, iterator, scope)
+
+ Returns a new array that only contains the items allowed by the iterator.
+ |
+
| <static> | +
+ JSV.formatURI(uri)
+
+ Returns a URI that is formated for JSV.
+ |
+
| <static> | +
+ JSV.inherits(base, extra, extension)
+
+ Merges two schemas/instance together.
+ |
+
| <static> | +
+ JSV.keys(o)
+
+ Returns an array of the names of all properties of an object.
+ |
+
| <static> | +
+ JSV.mapArray(arr, iterator, scope)
+
+ Returns a new array with each item transformed by the iterator.
+ |
+
| <static> | +
+ JSV.mapObject(obj, iterator, scope)
+
+ Returns a new object with each property transformed by the iterator.
+ |
+
| <static> | +
+ JSV.popFirst(arr, o)
+
+ Mutates the array by removing the first item that matches the provided value in the array.
+ |
+
| <static> | +
+ JSV.pushUnique(arr, o)
+
+ Mutates the array by pushing the provided value onto the array only if it is not already there.
+ |
+
| <static> | +
+ JSV.randomUUID()
+
+ Generates a pseudo-random UUID.
+ |
+
| <static> | +
+ JSV.searchArray(arr, o)
+
+ Returns the first index in the array that the provided item is located at.
+ |
+
| <static> | +
+ JSV.toArray(o)
+
+ Returns an array representation of a value.
+ |
+
| <static> | +
+ JSV.typeOf(o)
+
+ Returns the name of the type of the provided value.
+ |
+
undefined, the default environment ID is used.
This method will create a new instance of the target, and then mixin the properties of the target.
If deep is true, then each property will be cloned before mixin.
Warning: This is not a generic clone function, as it will only properly clone objects and arrays.
+ + +this within the iterator#).
+
+
+ this in the iteratorthis in the iterator-1 if not found
+
+
+
+
+
+
+
Defined in: jsv.js.
+
+
| Constructor Attributes | +Constructor Name and Description | +
|---|---|
| + |
+
+ Report()
+
+ Reports are returned from validation methods to describe the result of a validation.
+ |
+
| Field Attributes | +Field Name and Description | +
|---|---|
| + |
+
+ errors
+
+ An array of ValidationError objects that define all the errors generated by the schema against the instance.
+ |
+
| + |
+
+ instance
+
+ If the report is generated by Environment#validate, this field is the generated instance.
+ |
+
| + |
+
+ schema
+
+ If the report is generated by Environment#validate, this field is the generated schema.
+ |
+
| + |
+
+ schemaSchema
+
+ If the report is generated by Environment#validate, this field is the schema's schema.
+ |
+
| + |
+
+ validated
+
+ A hash table of every instance and what schemas were validated against it.
+ |
+
| Method Attributes | +Method Name and Description | +
|---|---|
| + |
+ addError(instance, schema, attr, message, details)
+
+ Adds a ValidationError object to the
+ errors field. |
+
| + |
+ isValidatedBy(uri, schemaUri)
+
+ Returns if an instance with the provided URI has been validated by the schema with the provided URI.
+ |
+
| + |
+ registerValidation(uri, schemaUri)
+
+ Registers that the provided instance URI has been validated by the provided schema URI.
+ |
+
schema.getSchema().
+
+
+ The key of each item in the table is the URI of the instance that was validated. The value of this key is an array of strings of URIs of the schema that validated it.
+ + +errors field.
+
+
+ validated field.
+
+
+
+
+
+
+
+
+
+
Defined in: jsv.js.
+
+
| Constructor Attributes | +Constructor Name and Description | +
|---|---|
| + |
+
+ ValidationError()
+
+ Defines an error, found by a schema, with an instance.
+ |
+
| Field Attributes | +Field Name and Description | +
|---|---|
| + |
+
+ attribute
+
+ The name of the schema attribute that generated the error.
+ |
+
| + |
+
+ details
+
+ The value of the schema attribute that generated the error.
+ |
+
| + |
+
+ message
+
+ An user-friendly (English) message about what failed to validate.
+ |
+
| + |
+
+ schemaUri
+
+ The URI of the schema that generated the error.
+ |
+
| + |
+
+ uri
+
+ The URI of the instance that has the error.
+ |
+
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + +1 /** + 2 * JSV: JSON Schema Validator + 3 * + 4 * @fileOverview A JavaScript implementation of a extendable, fully compliant JSON Schema validator. + 5 * @author <a href="mailto:gary.court@gmail.com">Gary Court</a> + 6 * @version 4.0 + 7 * @see http://github.com/garycourt/JSV + 8 */ + 9 + 10 /* + 11 * Copyright 2010 Gary Court. All rights reserved. + 12 * + 13 * Redistribution and use in source and binary forms, with or without modification, are + 14 * permitted provided that the following conditions are met: + 15 * + 16 * 1. Redistributions of source code must retain the above copyright notice, this list of + 17 * conditions and the following disclaimer. + 18 * + 19 * 2. Redistributions in binary form must reproduce the above copyright notice, this list + 20 * of conditions and the following disclaimer in the documentation and/or other materials + 21 * provided with the distribution. + 22 * + 23 * THIS SOFTWARE IS PROVIDED BY GARY COURT ``AS IS'' AND ANY EXPRESS OR IMPLIED + 24 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + 25 * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GARY COURT OR + 26 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + 27 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + 28 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + 29 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + 30 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + 31 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + 32 * + 33 * The views and conclusions contained in the software and documentation are those of the + 34 * authors and should not be interpreted as representing official policies, either expressed + 35 * or implied, of Gary Court or the JSON Schema specification. + 36 */ + 37 + 38 /*jslint white: true, sub: true, onevar: true, undef: true, eqeqeq: true, newcap: true, immed: true, indent: 4 */ + 39 + 40 var exports = exports || this, + 41 require = require || function () { + 42 return exports; + 43 }; + 44 + 45 (function () { + 46 + 47 var URI = require("./uri/uri").URI, + 48 O = {}, + 49 I2H = "0123456789abcdef".split(""), + 50 mapArray, filterArray, searchArray, + 51 + 52 JSV; + 53 + 54 // + 55 // Utility functions + 56 // + 57 + 58 function typeOf(o) { + 59 return o === undefined ? "undefined" : (o === null ? "null" : Object.prototype.toString.call(o).split(" ").pop().split("]").shift().toLowerCase()); + 60 } + 61 + 62 /** @inner */ + 63 function F() {} + 64 + 65 function createObject(proto) { + 66 F.prototype = proto || {}; + 67 return new F(); + 68 } + 69 + 70 function mapObject(obj, func, scope) { + 71 var newObj = {}, key; + 72 for (key in obj) { + 73 if (obj[key] !== O[key]) { + 74 newObj[key] = func.call(scope, obj[key], key, obj); + 75 } + 76 } + 77 return newObj; + 78 } + 79 + 80 /** @ignore */ + 81 mapArray = function (arr, func, scope) { + 82 var x = 0, xl = arr.length, newArr = new Array(xl); + 83 for (; x < xl; ++x) { + 84 newArr[x] = func.call(scope, arr[x], x, arr); + 85 } + 86 return newArr; + 87 }; + 88 + 89 if (Array.prototype.map) { + 90 /** @ignore */ + 91 mapArray = function (arr, func, scope) { + 92 return Array.prototype.map.call(arr, func, scope); + 93 }; + 94 } + 95 + 96 /** @ignore */ + 97 filterArray = function (arr, func, scope) { + 98 var x = 0, xl = arr.length, newArr = []; + 99 for (; x < xl; ++x) { +100 if (func.call(scope, arr[x], x, arr)) { +101 newArr[newArr.length] = arr[x]; +102 } +103 } +104 return newArr; +105 }; +106 +107 if (Array.prototype.filter) { +108 /** @ignore */ +109 filterArray = function (arr, func, scope) { +110 return Array.prototype.filter.call(arr, func, scope); +111 }; +112 } +113 +114 /** @ignore */ +115 searchArray = function (arr, o) { +116 var x = 0, xl = arr.length; +117 for (; x < xl; ++x) { +118 if (arr[x] === o) { +119 return x; +120 } +121 } +122 return -1; +123 }; +124 +125 if (Array.prototype.indexOf) { +126 /** @ignore */ +127 searchArray = function (arr, o) { +128 return Array.prototype.indexOf.call(arr, o); +129 }; +130 } +131 +132 function toArray(o) { +133 return o !== undefined && o !== null ? (o instanceof Array && !o.callee ? o : (typeof o.length !== "number" || o.split || o.setInterval || o.call ? [ o ] : Array.prototype.slice.call(o))) : []; +134 } +135 +136 function keys(o) { +137 var result = [], key; +138 +139 switch (typeOf(o)) { +140 case "object": +141 for (key in o) { +142 if (o[key] !== O[key]) { +143 result[result.length] = key; +144 } +145 } +146 break; +147 case "array": +148 for (key = o.length - 1; key >= 0; --key) { +149 result[key] = key; +150 } +151 break; +152 } +153 +154 return result; +155 } +156 +157 function pushUnique(arr, o) { +158 if (searchArray(arr, o) === -1) { +159 arr.push(o); +160 } +161 return arr; +162 } +163 +164 function popFirst(arr, o) { +165 var index = searchArray(arr, o); +166 if (index > -1) { +167 arr.splice(index, 1); +168 } +169 return arr; +170 } +171 +172 function randomUUID() { +173 return [ +174 I2H[Math.floor(Math.random() * 0x10)], +175 I2H[Math.floor(Math.random() * 0x10)], +176 I2H[Math.floor(Math.random() * 0x10)], +177 I2H[Math.floor(Math.random() * 0x10)], +178 I2H[Math.floor(Math.random() * 0x10)], +179 I2H[Math.floor(Math.random() * 0x10)], +180 I2H[Math.floor(Math.random() * 0x10)], +181 I2H[Math.floor(Math.random() * 0x10)], +182 "-", +183 I2H[Math.floor(Math.random() * 0x10)], +184 I2H[Math.floor(Math.random() * 0x10)], +185 I2H[Math.floor(Math.random() * 0x10)], +186 I2H[Math.floor(Math.random() * 0x10)], +187 "-4", //set 4 high bits of time_high field to version +188 I2H[Math.floor(Math.random() * 0x10)], +189 I2H[Math.floor(Math.random() * 0x10)], +190 I2H[Math.floor(Math.random() * 0x10)], +191 "-", +192 I2H[(Math.floor(Math.random() * 0x10) & 0x3) | 0x8], //specify 2 high bits of clock sequence +193 I2H[Math.floor(Math.random() * 0x10)], +194 I2H[Math.floor(Math.random() * 0x10)], +195 I2H[Math.floor(Math.random() * 0x10)], +196 "-", +197 I2H[Math.floor(Math.random() * 0x10)], +198 I2H[Math.floor(Math.random() * 0x10)], +199 I2H[Math.floor(Math.random() * 0x10)], +200 I2H[Math.floor(Math.random() * 0x10)], +201 I2H[Math.floor(Math.random() * 0x10)], +202 I2H[Math.floor(Math.random() * 0x10)], +203 I2H[Math.floor(Math.random() * 0x10)], +204 I2H[Math.floor(Math.random() * 0x10)], +205 I2H[Math.floor(Math.random() * 0x10)], +206 I2H[Math.floor(Math.random() * 0x10)], +207 I2H[Math.floor(Math.random() * 0x10)], +208 I2H[Math.floor(Math.random() * 0x10)] +209 ].join(""); +210 } +211 +212 function escapeURIComponent(str) { +213 return encodeURIComponent(str).replace(/!/g, '%21').replace(/'/g, '%27').replace(/\(/g, '%28').replace(/\)/g, '%29').replace(/\*/g, '%2A'); +214 } +215 +216 function formatURI(uri) { +217 if (typeof uri === "string" && uri.indexOf("#") === -1) { +218 uri += "#"; +219 } +220 return uri; +221 } +222 +223 function stripInstances(o) { +224 if (o instanceof JSONInstance) { +225 return o.getURI(); +226 } +227 +228 switch (typeOf(o)) { +229 case "undefined": +230 case "null": +231 case "boolean": +232 case "number": +233 case "string": +234 return o; //do nothing +235 +236 case "object": +237 return mapObject(o, stripInstances); +238 +239 case "array": +240 return mapArray(o, stripInstances); +241 +242 default: +243 return o.toString(); +244 } +245 } +246 +247 /** +248 * The exception that is thrown when a schema fails to be created. +249 * +250 * @name InitializationError +251 * @class +252 * @param {JSONInstance|String} instance The instance (or instance URI) that is invalid +253 * @param {JSONSchema|String} schema The schema (or schema URI) that was validating the instance +254 * @param {String} attr The attribute that failed to validated +255 * @param {String} message A user-friendly message on why the schema attribute failed to validate the instance +256 * @param {Any} details The value of the schema attribute +257 */ +258 +259 function InitializationError(instance, schema, attr, message, details) { +260 Error.call(this, message); +261 +262 this.uri = instance instanceof JSONInstance ? instance.getURI() : instance; +263 this.schemaUri = schema instanceof JSONInstance ? schema.getURI() : schema; +264 this.attribute = attr; +265 this.message = message; +266 this.description = message; //IE +267 this.details = details; +268 } +269 +270 InitializationError.prototype = new Error(); +271 InitializationError.prototype.constructor = InitializationError; +272 InitializationError.prototype.name = "InitializationError"; +273 +274 /** +275 * Defines an error, found by a schema, with an instance. +276 * This class can only be instantiated by {@link Report#addError}. +277 * +278 * @name ValidationError +279 * @class +280 * @see Report#addError +281 */ +282 +283 /** +284 * The URI of the instance that has the error. +285 * +286 * @name ValidationError.prototype.uri +287 * @type String +288 */ +289 +290 /** +291 * The URI of the schema that generated the error. +292 * +293 * @name ValidationError.prototype.schemaUri +294 * @type String +295 */ +296 +297 /** +298 * The name of the schema attribute that generated the error. +299 * +300 * @name ValidationError.prototype.attribute +301 * @type String +302 */ +303 +304 /** +305 * An user-friendly (English) message about what failed to validate. +306 * +307 * @name ValidationError.prototype.message +308 * @type String +309 */ +310 +311 /** +312 * The value of the schema attribute that generated the error. +313 * +314 * @name ValidationError.prototype.details +315 * @type Any +316 */ +317 +318 /** +319 * Reports are returned from validation methods to describe the result of a validation. +320 * +321 * @name Report +322 * @class +323 * @see JSONSchema#validate +324 * @see Environment#validate +325 */ +326 +327 function Report() { +328 /** +329 * An array of {@link ValidationError} objects that define all the errors generated by the schema against the instance. +330 * +331 * @name Report.prototype.errors +332 * @type Array +333 * @see Report#addError +334 */ +335 this.errors = []; +336 +337 /** +338 * A hash table of every instance and what schemas were validated against it. +339 * <p> +340 * The key of each item in the table is the URI of the instance that was validated. +341 * The value of this key is an array of strings of URIs of the schema that validated it. +342 * </p> +343 * +344 * @name Report.prototype.validated +345 * @type Object +346 * @see Report#registerValidation +347 * @see Report#isValidatedBy +348 */ +349 this.validated = {}; +350 +351 /** +352 * If the report is generated by {@link Environment#validate}, this field is the generated instance. +353 * +354 * @name Report.prototype.instance +355 * @type JSONInstance +356 * @see Environment#validate +357 */ +358 +359 /** +360 * If the report is generated by {@link Environment#validate}, this field is the generated schema. +361 * +362 * @name Report.prototype.schema +363 * @type JSONSchema +364 * @see Environment#validate +365 */ +366 +367 /** +368 * If the report is generated by {@link Environment#validate}, this field is the schema's schema. +369 * This value is the same as calling <code>schema.getSchema()</code>. +370 * +371 * @name Report.prototype.schemaSchema +372 * @type JSONSchema +373 * @see Environment#validate +374 * @see JSONSchema#getSchema +375 */ +376 } +377 +378 /** +379 * Adds a {@link ValidationError} object to the <a href="#errors"><code>errors</code></a> field. +380 * +381 * @param {JSONInstance|String} instance The instance (or instance URI) that is invalid +382 * @param {JSONSchema|String} schema The schema (or schema URI) that was validating the instance +383 * @param {String} attr The attribute that failed to validated +384 * @param {String} message A user-friendly message on why the schema attribute failed to validate the instance +385 * @param {Any} details The value of the schema attribute +386 */ +387 +388 Report.prototype.addError = function (instance, schema, attr, message, details) { +389 this.errors.push({ +390 uri : instance instanceof JSONInstance ? instance.getURI() : instance, +391 schemaUri : schema instanceof JSONInstance ? schema.getURI() : schema, +392 attribute : attr, +393 message : message, +394 details : stripInstances(details) +395 }); +396 }; +397 +398 /** +399 * Registers that the provided instance URI has been validated by the provided schema URI. +400 * This is recorded in the <a href="#validated"><code>validated</code></a> field. +401 * +402 * @param {String} uri The URI of the instance that was validated +403 * @param {String} schemaUri The URI of the schema that validated the instance +404 */ +405 +406 Report.prototype.registerValidation = function (uri, schemaUri) { +407 if (!this.validated[uri]) { +408 this.validated[uri] = [ schemaUri ]; +409 } else { +410 this.validated[uri].push(schemaUri); +411 } +412 }; +413 +414 /** +415 * Returns if an instance with the provided URI has been validated by the schema with the provided URI. +416 * +417 * @param {String} uri The URI of the instance +418 * @param {String} schemaUri The URI of a schema +419 * @returns {Boolean} If the instance has been validated by the schema. +420 */ +421 +422 Report.prototype.isValidatedBy = function (uri, schemaUri) { +423 return !!this.validated[uri] && searchArray(this.validated[uri], schemaUri) !== -1; +424 }; +425 +426 /** +427 * A wrapper class for binding an Environment, URI and helper methods to an instance. +428 * This class is most commonly instantiated with {@link Environment#createInstance}. +429 * +430 * @name JSONInstance +431 * @class +432 * @param {Environment} env The environment this instance belongs to +433 * @param {JSONInstance|Any} json The value of the instance +434 * @param {String} [uri] The URI of the instance. If undefined, the URI will be a randomly generated UUID. +435 * @param {String} [fd] The fragment delimiter for properties. If undefined, uses the environment default. +436 */ +437 +438 function JSONInstance(env, json, uri, fd) { +439 if (json instanceof JSONInstance) { +440 if (typeof fd !== "string") { +441 fd = json._fd; +442 } +443 if (typeof uri !== "string") { +444 uri = json._uri; +445 } +446 json = json._value; +447 } +448 +449 if (typeof uri !== "string") { +450 uri = "urn:uuid:" + randomUUID() + "#"; +451 } else if (uri.indexOf(":") === -1) { +452 uri = formatURI(URI.resolve("urn:uuid:" + randomUUID() + "#", uri)); +453 } +454 +455 this._env = env; +456 this._value = json; +457 this._uri = uri; +458 this._fd = fd || this._env._options["defaultFragmentDelimiter"]; +459 } +460 +461 /** +462 * Returns the environment the instance is bound to. +463 * +464 * @returns {Environment} The environment of the instance +465 */ +466 +467 JSONInstance.prototype.getEnvironment = function () { +468 return this._env; +469 }; +470 +471 /** +472 * Returns the name of the type of the instance. +473 * +474 * @returns {String} The name of the type of the instance +475 */ +476 +477 JSONInstance.prototype.getType = function () { +478 return typeOf(this._value); +479 }; +480 +481 /** +482 * Returns the JSON value of the instance. +483 * +484 * @returns {Any} The actual JavaScript value of the instance +485 */ +486 +487 JSONInstance.prototype.getValue = function () { +488 return this._value; +489 }; +490 +491 /** +492 * Returns the URI of the instance. +493 * +494 * @returns {String} The URI of the instance +495 */ +496 +497 JSONInstance.prototype.getURI = function () { +498 return this._uri; +499 }; +500 +501 /** +502 * Returns a resolved URI of a provided relative URI against the URI of the instance. +503 * +504 * @param {String} uri The relative URI to resolve +505 * @returns {String} The resolved URI +506 */ +507 +508 JSONInstance.prototype.resolveURI = function (uri) { +509 return formatURI(URI.resolve(this._uri, uri)); +510 }; +511 +512 /** +513 * Returns an array of the names of all the properties. +514 * +515 * @returns {Array} An array of strings which are the names of all the properties +516 */ +517 +518 JSONInstance.prototype.getPropertyNames = function () { +519 return keys(this._value); +520 }; +521 +522 /** +523 * Returns a {@link JSONInstance} of the value of the provided property name. +524 * +525 * @param {String} key The name of the property to fetch +526 * @returns {JSONInstance} The instance of the property value +527 */ +528 +529 JSONInstance.prototype.getProperty = function (key) { +530 var value = this._value ? this._value[key] : undefined; +531 if (value instanceof JSONInstance) { +532 return value; +533 } +534 //else +535 return new JSONInstance(this._env, value, this._uri + this._fd + escapeURIComponent(key), this._fd); +536 }; +537 +538 /** +539 * Returns all the property instances of the target instance. +540 * <p> +541 * If the target instance is an Object, then the method will return a hash table of {@link JSONInstance}s of all the properties. +542 * If the target instance is an Array, then the method will return an array of {@link JSONInstance}s of all the items. +543 * </p> +544 * +545 * @returns {Object|Array|undefined} The list of instances for all the properties +546 */ +547 +548 JSONInstance.prototype.getProperties = function () { +549 var type = typeOf(this._value), +550 self = this; +551 +552 if (type === "object") { +553 return mapObject(this._value, function (value, key) { +554 if (value instanceof JSONInstance) { +555 return value; +556 } +557 return new JSONInstance(self._env, value, self._uri + self._fd + escapeURIComponent(key), self._fd); +558 }); +559 } else if (type === "array") { +560 return mapArray(this._value, function (value, key) { +561 if (value instanceof JSONInstance) { +562 return value; +563 } +564 return new JSONInstance(self._env, value, self._uri + self._fd + escapeURIComponent(key), self._fd); +565 }); +566 } +567 }; +568 +569 /** +570 * Returns the JSON value of the provided property name. +571 * This method is a faster version of calling <code>instance.getProperty(key).getValue()</code>. +572 * +573 * @param {String} key The name of the property +574 * @returns {Any} The JavaScript value of the instance +575 * @see JSONInstance#getProperty +576 * @see JSONInstance#getValue +577 */ +578 +579 JSONInstance.prototype.getValueOfProperty = function (key) { +580 if (this._value) { +581 if (this._value[key] instanceof JSONInstance) { +582 return this._value[key]._value; +583 } +584 return this._value[key]; +585 } +586 }; +587 +588 /** +589 * Return if the provided value is the same as the value of the instance. +590 * +591 * @param {JSONInstance|Any} instance The value to compare +592 * @returns {Boolean} If both the instance and the value match +593 */ +594 +595 JSONInstance.prototype.equals = function (instance) { +596 if (instance instanceof JSONInstance) { +597 return this._value === instance._value; +598 } +599 //else +600 return this._value === instance; +601 }; +602 +603 /** +604 * Warning: Not a generic clone function +605 * Produces a JSV acceptable clone +606 */ +607 +608 function clone(obj, deep) { +609 var newObj, x; +610 +611 if (obj instanceof JSONInstance) { +612 obj = obj.getValue(); +613 } +614 +615 switch (typeOf(obj)) { +616 case "object": +617 if (deep) { +618 newObj = {}; +619 for (x in obj) { +620 if (obj[x] !== O[x]) { +621 newObj[x] = clone(obj[x], deep); +622 } +623 } +624 return newObj; +625 } else { +626 return createObject(obj); +627 } +628 break; +629 case "array": +630 if (deep) { +631 newObj = new Array(obj.length); +632 x = obj.length; +633 while (--x >= 0) { +634 newObj[x] = clone(obj[x], deep); +635 } +636 return newObj; +637 } else { +638 return Array.prototype.slice.call(obj); +639 } +640 break; +641 default: +642 return obj; +643 } +644 } +645 +646 /** +647 * This class binds a {@link JSONInstance} with a {@link JSONSchema} to provided context aware methods. +648 * +649 * @name JSONSchema +650 * @class +651 * @param {Environment} env The environment this schema belongs to +652 * @param {JSONInstance|Any} json The value of the schema +653 * @param {String} [uri] The URI of the schema. If undefined, the URI will be a randomly generated UUID. +654 * @param {JSONSchema|Boolean} [schema] The schema to bind to the instance. If <code>undefined</code>, the environment's default schema will be used. If <code>true</code>, the instance's schema will be itself. +655 * @extends JSONInstance +656 */ +657 +658 function JSONSchema(env, json, uri, schema) { +659 var fr; +660 JSONInstance.call(this, env, json, uri); +661 +662 if (schema === true) { +663 this._schema = this; +664 } else if (json instanceof JSONSchema && !(schema instanceof JSONSchema)) { +665 this._schema = json._schema; //TODO: Make sure cross environments don't mess everything up +666 } else { +667 this._schema = schema instanceof JSONSchema ? schema : this._env.getDefaultSchema() || this._env.createEmptySchema(); +668 } +669 +670 //determine fragment delimiter from schema +671 fr = this._schema.getValueOfProperty("fragmentResolution"); +672 if (fr === "dot-delimited") { +673 this._fd = "."; +674 } else if (fr === "slash-delimited") { +675 this._fd = "/"; +676 } +677 +678 return this.rebuild(); //this works even when called with "new" +679 } +680 +681 JSONSchema.prototype = createObject(JSONInstance.prototype); +682 +683 /** +684 * Returns the schema of the schema. +685 * +686 * @returns {JSONSchema} The schema of the schema +687 */ +688 +689 JSONSchema.prototype.getSchema = function () { +690 var uri = this._refs && this._refs["describedby"], +691 newSchema; +692 +693 if (uri) { +694 newSchema = uri && this._env.findSchema(uri); +695 +696 if (newSchema) { +697 if (!newSchema.equals(this._schema)) { +698 this._schema = newSchema; +699 this.rebuild(); //if the schema has changed, the context has changed - so everything must be rebuilt +700 } +701 } else if (this._env._options["enforceReferences"]) { +702 throw new InitializationError(this, this._schema, "{describedby}", "Unknown schema reference", uri); +703 } +704 } +705 +706 return this._schema; +707 }; +708 +709 /** +710 * Returns the value of the provided attribute name. +711 * <p> +712 * This method is different from {@link JSONInstance#getProperty} as the named property +713 * is converted using a parser defined by the schema's schema before being returned. This +714 * makes the return value of this method attribute dependent. +715 * </p> +716 * +717 * @param {String} key The name of the attribute +718 * @param {Any} [arg] Some attribute parsers accept special arguments for returning resolved values. This is attribute dependent. +719 * @returns {JSONSchema|Any} The value of the attribute +720 */ +721 +722 JSONSchema.prototype.getAttribute = function (key, arg) { +723 var schemaProperty, parser, property, result, +724 schema = this.getSchema(); //we do this here to make sure the "describedby" reference has not changed, and that the attribute cache is up-to-date +725 +726 if (!arg && this._attributes && this._attributes.hasOwnProperty(key)) { +727 return this._attributes[key]; +728 } +729 +730 schemaProperty = schema.getProperty("properties").getProperty(key); +731 parser = schemaProperty.getValueOfProperty("parser"); +732 property = this.getProperty(key); +733 if (typeof parser === "function") { +734 result = parser(property, schemaProperty, arg); +735 if (!arg && this._attributes) { +736 this._attributes[key] = result; +737 } +738 return result; +739 } +740 //else +741 return property.getValue(); +742 }; +743 +744 /** +745 * Returns all the attributes of the schema. +746 * +747 * @returns {Object} A map of all parsed attribute values +748 */ +749 +750 JSONSchema.prototype.getAttributes = function () { +751 var properties, schemaProperties, key, schemaProperty, parser, +752 schema = this.getSchema(); //we do this here to make sure the "describedby" reference has not changed, and that the attribute cache is up-to-date +753 +754 if (!this._attributes && this.getType() === "object") { +755 properties = this.getProperties(); +756 schemaProperties = schema.getProperty("properties"); +757 this._attributes = {}; +758 for (key in properties) { +759 if (properties[key] !== O[key]) { +760 schemaProperty = schemaProperties && schemaProperties.getProperty(key); +761 parser = schemaProperty && schemaProperty.getValueOfProperty("parser"); +762 if (typeof parser === "function") { +763 this._attributes[key] = parser(properties[key], schemaProperty); +764 } else { +765 this._attributes[key] = properties[key].getValue(); +766 } +767 } +768 } +769 } +770 +771 return clone(this._attributes, false); +772 }; +773 +774 /** +775 * Convenience method for retrieving a link or link object from a schema. +776 * This method is the same as calling <code>schema.getAttribute("links", [rel, instance])[0];</code>. +777 * +778 * @param {String} rel The link relationship +779 * @param {JSONInstance} [instance] The instance to resolve any URIs from +780 * @returns {String|Object|undefined} If <code>instance</code> is provided, a string containing the resolve URI of the link is returned. +781 * If <code>instance</code> is not provided, a link object is returned with details of the link. +782 * If no link with the provided relationship exists, <code>undefined</code> is returned. +783 * @see JSONSchema#getAttribute +784 */ +785 +786 JSONSchema.prototype.getLink = function (rel, instance) { +787 var schemaLinks = this.getAttribute("links", [rel, instance]); +788 if (schemaLinks && schemaLinks.length && schemaLinks[schemaLinks.length - 1]) { +789 return schemaLinks[schemaLinks.length - 1]; +790 } +791 }; +792 +793 /** +794 * Validates the provided instance against the target schema and returns a {@link Report}. +795 * +796 * @param {JSONInstance|Any} instance The instance to validate; may be a {@link JSONInstance} or any JavaScript value +797 * @param {Report} [report] A {@link Report} to concatenate the result of the validation to. If <code>undefined</code>, a new {@link Report} is created. +798 * @param {JSONInstance} [parent] The parent/containing instance of the provided instance +799 * @param {JSONSchema} [parentSchema] The schema of the parent/containing instance +800 * @param {String} [name] The name of the parent object's property that references the instance +801 * @returns {Report} The result of the validation +802 */ +803 +804 JSONSchema.prototype.validate = function (instance, report, parent, parentSchema, name) { +805 var schemaSchema = this.getSchema(), +806 validator = schemaSchema.getValueOfProperty("validator"); +807 +808 if (!(instance instanceof JSONInstance)) { +809 instance = this.getEnvironment().createInstance(instance); +810 } +811 +812 if (!(report instanceof Report)) { +813 report = new Report(); +814 } +815 +816 if (this._env._options["validateReferences"] && this._refs) { +817 if (this._refs["describedby"] && !this._env.findSchema(this._refs["describedby"])) { +818 report.addError(this, this._schema, "{describedby}", "Unknown schema reference", this._refs["describedby"]); +819 } +820 if (this._refs["full"] && !this._env.findSchema(this._refs["full"])) { +821 report.addError(this, this._schema, "{full}", "Unknown schema reference", this._refs["full"]); +822 } +823 } +824 +825 if (typeof validator === "function" && !report.isValidatedBy(instance.getURI(), this.getURI())) { +826 report.registerValidation(instance.getURI(), this.getURI()); +827 validator(instance, this, schemaSchema, report, parent, parentSchema, name); +828 } +829 +830 return report; +831 }; +832 +833 /** @inner */ +834 function createFullLookupWrapper(func) { +835 return /** @inner */ function fullLookupWrapper() { +836 var scope = this, +837 stack = [], +838 uri = scope._refs && scope._refs["full"], +839 schema; +840 +841 while (uri) { +842 schema = scope._env.findSchema(uri); +843 if (schema) { +844 if (schema._value === scope._value) { +845 break; +846 } +847 scope = schema; +848 stack.push(uri); +849 uri = scope._refs && scope._refs["full"]; +850 if (stack.indexOf(uri) > -1) { +851 break; //stop infinite loop +852 } +853 } else if (scope._env._options["enforceReferences"]) { +854 throw new InitializationError(scope, scope._schema, "{full}", "Unknown schema reference", uri); +855 } else { +856 uri = null; +857 } +858 } +859 return func.apply(scope, arguments); +860 }; +861 } +862 +863 /** +864 * Wraps all JSONInstance methods with a function that resolves the "full" reference. +865 * +866 * @inner +867 */ +868 +869 (function () { +870 var key; +871 for (key in JSONSchema.prototype) { +872 if (JSONSchema.prototype[key] !== O[key] && typeOf(JSONSchema.prototype[key]) === "function") { +873 JSONSchema.prototype[key] = createFullLookupWrapper(JSONSchema.prototype[key]); +874 } +875 } +876 }()); +877 +878 /** +879 * Reinitializes/re-registers/rebuilds the schema. +880 * <br/> +881 * This is used internally, and should only be called when a schema's private variables are modified directly. +882 * +883 * @private +884 * @return {JSONSchema} The newly rebuilt schema +885 */ +886 +887 JSONSchema.prototype.rebuild = function () { +888 var instance = this, +889 initializer = instance.getSchema().getValueOfProperty("initializer"); +890 +891 //clear previous built values +892 instance._refs = null; +893 instance._attributes = null; +894 +895 if (typeof initializer === "function") { +896 instance = initializer(instance); +897 } +898 +899 //register schema +900 instance._env._schemas[instance._uri] = instance; +901 +902 //build & cache the rest of the schema +903 instance.getAttributes(); +904 +905 return instance; +906 }; +907 +908 /** +909 * Set the provided reference to the given value. +910 * <br/> +911 * References are used for establishing soft-links to other {@link JSONSchema}s. +912 * Currently, the following references are natively supported: +913 * <dl> +914 * <dt><code>full</code></dt> +915 * <dd>The value is the URI to the full instance of this instance.</dd> +916 * <dt><code>describedby</code></dt> +917 * <dd>The value is the URI to the schema of this instance.</dd> +918 * </dl> +919 * +920 * @param {String} name The name of the reference +921 * @param {String} uri The URI of the schema to refer to +922 */ +923 +924 JSONSchema.prototype.setReference = function (name, uri) { +925 if (!this._refs) { +926 this._refs = {}; +927 } +928 this._refs[name] = this.resolveURI(uri); +929 }; +930 +931 /** +932 * Returns the value of the provided reference name. +933 * +934 * @param {String} name The name of the reference +935 * @return {String} The value of the provided reference name +936 */ +937 +938 JSONSchema.prototype.getReference = function (name) { +939 return this._refs && this._refs[name]; +940 }; +941 +942 /** +943 * Merges two schemas/instances together. +944 */ +945 +946 function inherits(base, extra, extension) { +947 var baseType = typeOf(base), +948 extraType = typeOf(extra), +949 child, x; +950 +951 if (extraType === "undefined") { +952 return clone(base, true); +953 } else if (baseType === "undefined" || extraType !== baseType) { +954 return clone(extra, true); +955 } else if (extraType === "object") { +956 if (base instanceof JSONSchema) { +957 base = base.getAttributes(); +958 } +959 if (extra instanceof JSONSchema) { +960 extra = extra.getAttributes(); +961 if (extra["extends"] && extension && extra["extends"] instanceof JSONSchema) { +962 extra["extends"] = [ extra["extends"] ]; +963 } +964 } +965 child = clone(base, true); //this could be optimized as some properties get overwritten +966 for (x in extra) { +967 if (extra[x] !== O[x]) { +968 child[x] = inherits(base[x], extra[x], extension); +969 } +970 } +971 return child; +972 } else { +973 return clone(extra, true); +974 } +975 } +976 +977 /** +978 * An Environment is a sandbox of schemas thats behavior is different from other environments. +979 * +980 * @name Environment +981 * @class +982 */ +983 +984 function Environment() { +985 this._id = randomUUID(); +986 this._schemas = {}; +987 this._options = {}; +988 +989 this.createSchema({}, true, "urn:jsv:empty-schema#"); +990 } +991 +992 /** +993 * Returns a clone of the target environment. +994 * +995 * @returns {Environment} A new {@link Environment} that is a exact copy of the target environment +996 */ +997 +998 Environment.prototype.clone = function () { +999 var env = new Environment(); +1000 env._schemas = createObject(this._schemas); +1001 env._options = createObject(this._options); +1002 +1003 return env; +1004 }; +1005 +1006 /** +1007 * Returns a new {@link JSONInstance} of the provided data. +1008 * +1009 * @param {JSONInstance|Any} data The value of the instance +1010 * @param {String} [uri] The URI of the instance. If undefined, the URI will be a randomly generated UUID. +1011 * @returns {JSONInstance} A new {@link JSONInstance} from the provided data +1012 */ +1013 +1014 Environment.prototype.createInstance = function (data, uri) { +1015 uri = formatURI(uri); +1016 +1017 if (data instanceof JSONInstance && (!uri || data.getURI() === uri)) { +1018 return data; +1019 } +1020 +1021 return new JSONInstance(this, data, uri); +1022 }; +1023 +1024 /** +1025 * Creates a new {@link JSONSchema} from the provided data, and registers it with the environment. +1026 * +1027 * @param {JSONInstance|Any} data The value of the schema +1028 * @param {JSONSchema|Boolean} [schema] The schema to bind to the instance. If <code>undefined</code>, the environment's default schema will be used. If <code>true</code>, the instance's schema will be itself. +1029 * @param {String} [uri] The URI of the schema. If undefined, the URI will be a randomly generated UUID. +1030 * @returns {JSONSchema} A new {@link JSONSchema} from the provided data +1031 * @throws {InitializationError} If a schema that is not registered with the environment is referenced +1032 */ +1033 +1034 Environment.prototype.createSchema = function (data, schema, uri) { +1035 uri = formatURI(uri); +1036 +1037 if (data instanceof JSONSchema && (!uri || data._uri === uri) && (!schema || data.getSchema().equals(schema))) { +1038 return data; +1039 } +1040 +1041 return new JSONSchema(this, data, uri, schema); +1042 }; +1043 +1044 /** +1045 * Creates an empty schema. +1046 * +1047 * @returns {JSONSchema} The empty schema, who's schema is itself. +1048 */ +1049 +1050 Environment.prototype.createEmptySchema = function () { +1051 return this._schemas["urn:jsv:empty-schema#"]; +1052 }; +1053 +1054 /** +1055 * Returns the schema registered with the provided URI. +1056 * +1057 * @param {String} uri The absolute URI of the required schema +1058 * @returns {JSONSchema|undefined} The request schema, or <code>undefined</code> if not found +1059 */ +1060 +1061 Environment.prototype.findSchema = function (uri) { +1062 return this._schemas[formatURI(uri)]; +1063 }; +1064 +1065 /** +1066 * Sets the specified environment option to the specified value. +1067 * +1068 * @param {String} name The name of the environment option to set +1069 * @param {Any} value The new value of the environment option +1070 */ +1071 +1072 Environment.prototype.setOption = function (name, value) { +1073 this._options[name] = value; +1074 }; +1075 +1076 /** +1077 * Returns the specified environment option. +1078 * +1079 * @param {String} name The name of the environment option to set +1080 * @returns {Any} The value of the environment option +1081 */ +1082 +1083 Environment.prototype.getOption = function (name) { +1084 return this._options[name]; +1085 }; +1086 +1087 /** +1088 * Sets the default fragment delimiter of the environment. +1089 * +1090 * @deprecated Use {@link Environment#setOption} with option "defaultFragmentDelimiter" +1091 * @param {String} fd The fragment delimiter character +1092 */ +1093 +1094 Environment.prototype.setDefaultFragmentDelimiter = function (fd) { +1095 if (typeof fd === "string" && fd.length > 0) { +1096 this._options["defaultFragmentDelimiter"] = fd; +1097 } +1098 }; +1099 +1100 /** +1101 * Returns the default fragment delimiter of the environment. +1102 * +1103 * @deprecated Use {@link Environment#getOption} with option "defaultFragmentDelimiter" +1104 * @returns {String} The fragment delimiter character +1105 */ +1106 +1107 Environment.prototype.getDefaultFragmentDelimiter = function () { +1108 return this._options["defaultFragmentDelimiter"]; +1109 }; +1110 +1111 /** +1112 * Sets the URI of the default schema for the environment. +1113 * +1114 * @deprecated Use {@link Environment#setOption} with option "defaultSchemaURI" +1115 * @param {String} uri The default schema URI +1116 */ +1117 +1118 Environment.prototype.setDefaultSchemaURI = function (uri) { +1119 if (typeof uri === "string") { +1120 this._options["defaultSchemaURI"] = formatURI(uri); +1121 } +1122 }; +1123 +1124 /** +1125 * Returns the default schema of the environment. +1126 * +1127 * @returns {JSONSchema} The default schema +1128 */ +1129 +1130 Environment.prototype.getDefaultSchema = function () { +1131 return this.findSchema(this._options["defaultSchemaURI"]); +1132 }; +1133 +1134 /** +1135 * Validates both the provided schema and the provided instance, and returns a {@link Report}. +1136 * If the schema fails to validate, the instance will not be validated. +1137 * +1138 * @param {JSONInstance|Any} instanceJSON The {@link JSONInstance} or JavaScript value to validate. +1139 * @param {JSONSchema|Any} schemaJSON The {@link JSONSchema} or JavaScript value to use in the validation. This will also be validated againt the schema's schema. +1140 * @returns {Report} The result of the validation +1141 */ +1142 +1143 Environment.prototype.validate = function (instanceJSON, schemaJSON) { +1144 var instance, +1145 schema, +1146 schemaSchema, +1147 report = new Report(); +1148 +1149 try { +1150 instance = this.createInstance(instanceJSON); +1151 report.instance = instance; +1152 } catch (e) { +1153 report.addError(e.uri, e.schemaUri, e.attribute, e.message, e.details); +1154 } +1155 +1156 try { +1157 schema = this.createSchema(schemaJSON); +1158 report.schema = schema; +1159 +1160 schemaSchema = schema.getSchema(); +1161 report.schemaSchema = schemaSchema; +1162 } catch (f) { +1163 report.addError(f.uri, f.schemaUri, f.attribute, f.message, f.details); +1164 } +1165 +1166 if (schemaSchema) { +1167 schemaSchema.validate(schema, report); +1168 } +1169 +1170 if (report.errors.length) { +1171 return report; +1172 } +1173 +1174 return schema.validate(instance, report); +1175 }; +1176 +1177 /** +1178 * @private +1179 */ +1180 +1181 Environment.prototype._checkForInvalidInstances = function (stackSize, schemaURI) { +1182 var result = [], +1183 stack = [ +1184 [schemaURI, this._schemas[schemaURI]] +1185 ], +1186 counter = 0, +1187 item, uri, instance, properties, key; +1188 +1189 while (counter++ < stackSize && stack.length) { +1190 item = stack.shift(); +1191 uri = item[0]; +1192 instance = item[1]; +1193 +1194 if (instance instanceof JSONSchema) { +1195 if (this._schemas[instance._uri] !== instance) { +1196 result.push("Instance " + uri + " does not match " + instance._uri); +1197 } else { +1198 //schema = instance.getSchema(); +1199 //stack.push([uri + "/{schema}", schema]); +1200 +1201 properties = instance.getAttributes(); +1202 for (key in properties) { +1203 if (properties[key] !== O[key]) { +1204 stack.push([uri + "/" + escapeURIComponent(key), properties[key]]); +1205 } +1206 } +1207 } +1208 } else if (typeOf(instance) === "object") { +1209 properties = instance; +1210 for (key in properties) { +1211 if (properties.hasOwnProperty(key)) { +1212 stack.push([uri + "/" + escapeURIComponent(key), properties[key]]); +1213 } +1214 } +1215 } else if (typeOf(instance) === "array") { +1216 properties = instance; +1217 for (key = 0; key < properties.length; ++key) { +1218 stack.push([uri + "/" + escapeURIComponent(key), properties[key]]); +1219 } +1220 } +1221 } +1222 +1223 return result.length ? result : counter; +1224 }; +1225 +1226 /** +1227 * A globaly accessible object that provides the ability to create and manage {@link Environments}, +1228 * as well as providing utility methods. +1229 * +1230 * @namespace +1231 */ +1232 +1233 JSV = { +1234 _environments : {}, +1235 _defaultEnvironmentID : "", +1236 +1237 /** +1238 * Returns if the provide value is an instance of {@link JSONInstance}. +1239 * +1240 * @param o The value to test +1241 * @returns {Boolean} If the provide value is an instance of {@link JSONInstance} +1242 */ +1243 +1244 isJSONInstance : function (o) { +1245 return o instanceof JSONInstance; +1246 }, +1247 +1248 /** +1249 * Returns if the provide value is an instance of {@link JSONSchema}. +1250 * +1251 * @param o The value to test +1252 * @returns {Boolean} If the provide value is an instance of {@link JSONSchema} +1253 */ +1254 +1255 isJSONSchema : function (o) { +1256 return o instanceof JSONSchema; +1257 }, +1258 +1259 /** +1260 * Creates and returns a new {@link Environment} that is a clone of the environment registered with the provided ID. +1261 * If no environment ID is provided, the default environment is cloned. +1262 * +1263 * @param {String} [id] The ID of the environment to clone. If <code>undefined</code>, the default environment ID is used. +1264 * @returns {Environment} A newly cloned {@link Environment} +1265 * @throws {Error} If there is no environment registered with the provided ID +1266 */ +1267 +1268 createEnvironment : function (id) { +1269 id = id || this._defaultEnvironmentID; +1270 +1271 if (!this._environments[id]) { +1272 throw new Error("Unknown Environment ID"); +1273 } +1274 //else +1275 return this._environments[id].clone(); +1276 }, +1277 +1278 Environment : Environment, +1279 +1280 /** +1281 * Registers the provided {@link Environment} with the provided ID. +1282 * +1283 * @param {String} id The ID of the environment +1284 * @param {Environment} env The environment to register +1285 */ +1286 +1287 registerEnvironment : function (id, env) { +1288 id = id || (env || 0)._id; +1289 if (id && !this._environments[id] && env instanceof Environment) { +1290 env._id = id; +1291 this._environments[id] = env; +1292 } +1293 }, +1294 +1295 /** +1296 * Sets which registered ID is the default environment. +1297 * +1298 * @param {String} id The ID of the registered environment that is default +1299 * @throws {Error} If there is no registered environment with the provided ID +1300 */ +1301 +1302 setDefaultEnvironmentID : function (id) { +1303 if (typeof id === "string") { +1304 if (!this._environments[id]) { +1305 throw new Error("Unknown Environment ID"); +1306 } +1307 +1308 this._defaultEnvironmentID = id; +1309 } +1310 }, +1311 +1312 /** +1313 * Returns the ID of the default environment. +1314 * +1315 * @returns {String} The ID of the default environment +1316 */ +1317 +1318 getDefaultEnvironmentID : function () { +1319 return this._defaultEnvironmentID; +1320 }, +1321 +1322 // +1323 // Utility Functions +1324 // +1325 +1326 /** +1327 * Returns the name of the type of the provided value. +1328 * +1329 * @event //utility +1330 * @param {Any} o The value to determine the type of +1331 * @returns {String} The name of the type of the value +1332 */ +1333 typeOf : typeOf, +1334 +1335 /** +1336 * Return a new object that inherits all of the properties of the provided object. +1337 * +1338 * @event //utility +1339 * @param {Object} proto The prototype of the new object +1340 * @returns {Object} A new object that inherits all of the properties of the provided object +1341 */ +1342 createObject : createObject, +1343 +1344 /** +1345 * Returns a new object with each property transformed by the iterator. +1346 * +1347 * @event //utility +1348 * @param {Object} obj The object to transform +1349 * @param {Function} iterator A function that returns the new value of the provided property +1350 * @param {Object} [scope] The value of <code>this</code> in the iterator +1351 * @returns {Object} A new object with each property transformed +1352 */ +1353 mapObject : mapObject, +1354 +1355 /** +1356 * Returns a new array with each item transformed by the iterator. +1357 * +1358 * @event //utility +1359 * @param {Array} arr The array to transform +1360 * @param {Function} iterator A function that returns the new value of the provided item +1361 * @param {Object} scope The value of <code>this</code> in the iterator +1362 * @returns {Array} A new array with each item transformed +1363 */ +1364 mapArray : mapArray, +1365 +1366 /** +1367 * Returns a new array that only contains the items allowed by the iterator. +1368 * +1369 * @event //utility +1370 * @param {Array} arr The array to filter +1371 * @param {Function} iterator The function that returns true if the provided property should be added to the array +1372 * @param {Object} scope The value of <code>this</code> within the iterator +1373 * @returns {Array} A new array that contains the items allowed by the iterator +1374 */ +1375 filterArray : filterArray, +1376 +1377 /** +1378 * Returns the first index in the array that the provided item is located at. +1379 * +1380 * @event //utility +1381 * @param {Array} arr The array to search +1382 * @param {Any} o The item being searched for +1383 * @returns {Number} The index of the item in the array, or <code>-1</code> if not found +1384 */ +1385 searchArray : searchArray, +1386 +1387 /** +1388 * Returns an array representation of a value. +1389 * <ul> +1390 * <li>For array-like objects, the value will be casted as an Array type.</li> +1391 * <li>If an array is provided, the function will simply return the same array.</li> +1392 * <li>For a null or undefined value, the result will be an empty Array.</li> +1393 * <li>For all other values, the value will be the first element in a new Array. </li> +1394 * </ul> +1395 * +1396 * @event //utility +1397 * @param {Any} o The value to convert into an array +1398 * @returns {Array} The value as an array +1399 */ +1400 toArray : toArray, +1401 +1402 /** +1403 * Returns an array of the names of all properties of an object. +1404 * +1405 * @event //utility +1406 * @param {Object|Array} o The object in question +1407 * @returns {Array} The names of all properties +1408 */ +1409 keys : keys, +1410 +1411 /** +1412 * Mutates the array by pushing the provided value onto the array only if it is not already there. +1413 * +1414 * @event //utility +1415 * @param {Array} arr The array to modify +1416 * @param {Any} o The object to add to the array if it is not already there +1417 * @returns {Array} The provided array for chaining +1418 */ +1419 pushUnique : pushUnique, +1420 +1421 /** +1422 * Mutates the array by removing the first item that matches the provided value in the array. +1423 * +1424 * @event //utility +1425 * @param {Array} arr The array to modify +1426 * @param {Any} o The object to remove from the array +1427 * @returns {Array} The provided array for chaining +1428 */ +1429 popFirst : popFirst, +1430 +1431 /** +1432 * Creates a copy of the target object. +1433 * <p> +1434 * This method will create a new instance of the target, and then mixin the properties of the target. +1435 * If <code>deep</code> is <code>true</code>, then each property will be cloned before mixin. +1436 * </p> +1437 * <p><b>Warning</b>: This is not a generic clone function, as it will only properly clone objects and arrays.</p> +1438 * +1439 * @event //utility +1440 * @param {Any} o The value to clone +1441 * @param {Boolean} [deep=false] If each property should be recursively cloned +1442 * @returns A cloned copy of the provided value +1443 */ +1444 clone : clone, +1445 +1446 /** +1447 * Generates a pseudo-random UUID. +1448 * +1449 * @event //utility +1450 * @returns {String} A new universally unique ID +1451 */ +1452 randomUUID : randomUUID, +1453 +1454 /** +1455 * Properly escapes a URI component for embedding into a URI string. +1456 * +1457 * @event //utility +1458 * @param {String} str The URI component to escape +1459 * @returns {String} The escaped URI component +1460 */ +1461 escapeURIComponent : escapeURIComponent, +1462 +1463 /** +1464 * Returns a URI that is formated for JSV. Currently, this only ensures that the URI ends with a hash tag (<code>#</code>). +1465 * +1466 * @event //utility +1467 * @param {String} uri The URI to format +1468 * @returns {String} The URI formatted for JSV +1469 */ +1470 formatURI : formatURI, +1471 +1472 /** +1473 * Merges two schemas/instance together. +1474 * +1475 * @event //utility +1476 * @param {JSONSchema|Any} base The old value to merge +1477 * @param {JSONSchema|Any} extra The new value to merge +1478 * @param {Boolean} extension If the merge is a JSON Schema extension +1479 * @return {Any} The modified base value +1480 */ +1481 +1482 inherits : inherits, +1483 +1484 /** +1485 * @private +1486 * @event //utility +1487 */ +1488 +1489 InitializationError : InitializationError +1490 }; +1491 +1492 this.JSV = JSV; //set global object +1493 exports.JSV = JSV; //export to CommonJS +1494 +1495 require("./environments"); //load default environments +1496 +1497 }());\ No newline at end of file diff --git a/html/RentForCamp/node_modules/JSV/examples/index.html b/html/RentForCamp/node_modules/JSV/examples/index.html new file mode 100644 index 0000000..752ab66 --- /dev/null +++ b/html/RentForCamp/node_modules/JSV/examples/index.html @@ -0,0 +1,260 @@ + + + +
+This is a lightly modified version of Kevin Jones' JavaScript +library Data.Dump. To download the original visit: + http://openjsan.org/doc/k/ke/kevinj/Data/Dump/ + +AUTHORS + +The Data.Dump JavaScript module is written by Kevin Jones +(kevinj@cpan.org), based on Data::Dump by Gisle Aas (gisle@aas.no), +based on Data::Dumper by Gurusamy Sarathy (gsar@umich.edu). + +COPYRIGHT + +Copyright 2007 Kevin Jones. Copyright 1998-2000,2003-2004 Gisle Aas. +Copyright 1996-1998 Gurusamy Sarathy. + +This program is free software; you can redistribute it and/or modify +it under the terms of the Perl Artistic License + +See http://www.perl.com/perl/misc/Artistic.html ++ * @static + */ +Dumper = { + /** @param [...] The objects to dump. */ + dump: function () { + if (arguments.length > 1) + return this._dump(arguments); + else if (arguments.length == 1) + return this._dump(arguments[0]); + else + return "()"; + }, + + _dump: function (obj) { + if (typeof obj == 'undefined') return 'undefined'; + var out; + if (obj.serialize) { return obj.serialize(); } + var type = this._typeof(obj); + if (obj.circularReference) obj.circularReference++; + switch (type) { + case 'circular': + out = "{ //circularReference\n}"; + break; + case 'object': + var pairs = new Array; + + for (var prop in obj) { + if (prop != "circularReference" && obj.hasOwnProperty(prop)) { //hide inherited properties + pairs.push(prop + ': ' + this._dump(obj[prop])); + } + } + + out = '{' + this._format_list(pairs) + '}'; + break; + + case 'string': + for (var prop in Dumper.ESC) { + if (Dumper.ESC.hasOwnProperty(prop)) { + obj = obj.replace(prop, Dumper.ESC[prop]); + } + } + + // Escape UTF-8 Strings + if (obj.match(/^[\x00-\x7f]*$/)) { + out = '"' + obj.replace(/\"/g, "\\\"").replace(/([\n\r]+)/g, "\\$1") + '"'; + } + else { + out = "unescape('"+escape(obj)+"')"; + } + break; + + case 'array': + var elems = new Array; + + for (var i=0; i
"; + this.footer = ""; + this.showLinenumbers = true; +} + +JsHilite.cache = {}; + +JsHilite.prototype.hilite = function() { + var hilited = this.tokens.join(""); + var line = 1; + if (this.showLinenumbers) hilited = hilited.replace(/(^|\n)/g, function(m){return m+""+((line<10)? " ":"")+((line<100)? " ":"")+(line++)+" "}); + + return this.header+hilited+this.footer; +} \ No newline at end of file diff --git a/html/RentForCamp/node_modules/JSV/jsdoc-toolkit/app/plugins/symbolLink.js b/html/RentForCamp/node_modules/JSV/jsdoc-toolkit/app/plugins/symbolLink.js new file mode 100644 index 0000000..c87f1ca --- /dev/null +++ b/html/RentForCamp/node_modules/JSV/jsdoc-toolkit/app/plugins/symbolLink.js @@ -0,0 +1,10 @@ +JSDOC.PluginManager.registerPlugin( + "JSDOC.symbolLink", + { + onSymbolLink: function(link) { + // modify link.linkPath (the href part of the link) + // or link.linkText (the text displayed) + // or link.linkInner (the #name part of the link) + } + } +); \ No newline at end of file diff --git a/html/RentForCamp/node_modules/JSV/jsdoc-toolkit/app/plugins/tagParamConfig.js b/html/RentForCamp/node_modules/JSV/jsdoc-toolkit/app/plugins/tagParamConfig.js new file mode 100644 index 0000000..3ea8a1b --- /dev/null +++ b/html/RentForCamp/node_modules/JSV/jsdoc-toolkit/app/plugins/tagParamConfig.js @@ -0,0 +1,31 @@ +JSDOC.PluginManager.registerPlugin( + "JSDOC.tagParamConfig", + { + onDocCommentTags: function(comment) { + var currentParam = null; + var tags = comment.tags; + for (var i = 0, l = tags.length; i < l; i++) { + + if (tags[i].title == "param") { + if (tags[i].name.indexOf(".") == -1) { + currentParam = i; + } + } + else if (tags[i].title == "config") { + tags[i].title = "param"; + if (currentParam == null) { + tags[i].name = "arguments"+"."+tags[i].name; + } + else if (tags[i].name.indexOf(tags[currentParam].name+".") != 0) { + tags[i].name = tags[currentParam].name+"."+tags[i].name; + } + currentParam != null + //tags[currentParam].properties.push(tags[i]); + } + else { + currentParam = null; + } + } + } + } +); diff --git a/html/RentForCamp/node_modules/JSV/jsdoc-toolkit/app/plugins/tagSynonyms.js b/html/RentForCamp/node_modules/JSV/jsdoc-toolkit/app/plugins/tagSynonyms.js new file mode 100644 index 0000000..49a874f --- /dev/null +++ b/html/RentForCamp/node_modules/JSV/jsdoc-toolkit/app/plugins/tagSynonyms.js @@ -0,0 +1,43 @@ +JSDOC.PluginManager.registerPlugin( + "JSDOC.tagSynonyms", + { + onDocCommentSrc: function(comment) { + comment.src = comment.src.replace(/@methodOf\b/i, "@function\n@memberOf"); + comment.src = comment.src.replace(/@fieldOf\b/i, "@field\n@memberOf"); + }, + + onDocCommentTags: function(comment) { + for (var i = 0, l = comment.tags.length; i < l; i++) { + var title = comment.tags[i].title.toLowerCase(); + var syn; + if ((syn = JSDOC.tagSynonyms.synonyms["="+title])) { + comment.tags[i].title = syn; + } + } + } + } +); + +new Namespace( + "JSDOC.tagSynonyms", + function() { + JSDOC.tagSynonyms.synonyms = { + "=member": "memberOf", + "=memberof": "memberOf", + "=description": "desc", + "=exception": "throws", + "=argument": "param", + "=returns": "return", + "=classdescription": "class", + "=fileoverview": "overview", + "=extends": "augments", + "=base": "augments", + "=projectdescription": "overview", + "=classdescription": "class", + "=link": "see", + "=borrows": "inherits", + "=scope": "lends", + "=construct": "constructor" + } + } +); \ No newline at end of file diff --git a/html/RentForCamp/node_modules/JSV/jsdoc-toolkit/app/run.js b/html/RentForCamp/node_modules/JSV/jsdoc-toolkit/app/run.js new file mode 100644 index 0000000..1f875cd --- /dev/null +++ b/html/RentForCamp/node_modules/JSV/jsdoc-toolkit/app/run.js @@ -0,0 +1,348 @@ +/** + * @fileOverview + * A bootstrap script that creates some basic required objects + * for loading other scripts. + * @author Michael Mathews, micmath@gmail.com + * @version $Id: run.js 756 2009-01-07 21:32:58Z micmath $ + */ + +/** + * @namespace Keep track of any messages from the running script. + */ +LOG = { + warn: function(msg, e) { + if (JSDOC.opt.q) return; + if (e) msg = e.fileName+", line "+e.lineNumber+": "+msg; + + msg = ">> WARNING: "+msg; + LOG.warnings.push(msg); + if (LOG.out) LOG.out.write(msg+"\n"); + else print(msg); + }, + + inform: function(msg) { + if (JSDOC.opt.q) return; + msg = " > "+msg; + if (LOG.out) LOG.out.write(msg+"\n"); + else if (typeof LOG.verbose != "undefined" && LOG.verbose) print(msg); + } +}; +LOG.warnings = []; +LOG.verbose = false +LOG.out = undefined; + +/** + * @class Manipulate a filepath. + */ +function FilePath(absPath, separator) { + this.slash = separator || "/"; + this.root = this.slash; + this.path = []; + this.file = ""; + + var parts = absPath.split(/[\\\/]/); + if (parts) { + if (parts.length) this.root = parts.shift() + this.slash; + if (parts.length) this.file = parts.pop() + if (parts.length) this.path = parts; + } + + this.path = this.resolvePath(); +} + +/** Collapse any dot-dot or dot items in a filepath. */ +FilePath.prototype.resolvePath = function() { + var resolvedPath = []; + for (var i = 0; i < this.path.length; i++) { + if (this.path[i] == "..") resolvedPath.pop(); + else if (this.path[i] != ".") resolvedPath.push(this.path[i]); + } + return resolvedPath; +} + +/** Trim off the filename. */ +FilePath.prototype.toDir = function() { + if (this.file) this.file = ""; + return this; +} + +/** Go up a directory. */ +FilePath.prototype.upDir = function() { + this.toDir(); + if (this.path.length) this.path.pop(); + return this; +} + +FilePath.prototype.toString = function() { + return this.root + + this.path.join(this.slash) + + ((this.path.length > 0)? this.slash : "") + + this.file; +} + +/** + * Turn a path into just the name of the file. + */ +FilePath.fileName = function(path) { + var nameStart = Math.max(path.lastIndexOf("/")+1, path.lastIndexOf("\\")+1, 0); + return path.substring(nameStart); +} + +/** + * Get the extension of a filename + */ +FilePath.fileExtension = function(filename) { + return filename.split(".").pop().toLowerCase(); +}; + +/** + * Turn a path into just the directory part. + */ +FilePath.dir = function(path) { + var nameStart = Math.max(path.lastIndexOf("/")+1, path.lastIndexOf("\\")+1, 0); + return path.substring(0, nameStart-1); +} + + +importClass(java.lang.System); + +/** + * @namespace A collection of information about your system. + */ +SYS = { + /** + * Information about your operating system: arch, name, version. + * @type string + */ + os: [ + new String(System.getProperty("os.arch")), + new String(System.getProperty("os.name")), + new String(System.getProperty("os.version")) + ].join(", "), + + /** + * Which way does your slash lean. + * @type string + */ + slash: System.getProperty("file.separator")||"/", + + /** + * The path to the working directory where you ran java. + * @type string + */ + userDir: new String(System.getProperty("user.dir")), + + /** + * Where is Java's home folder. + * @type string + */ + javaHome: new String(System.getProperty("java.home")), + + /** + * The absolute path to the directory containing this script. + * @type string + */ + pwd: undefined +}; + +// jsrun appends an argument, with the path to here. +if (arguments[arguments.length-1].match(/^-j=(.+)/)) { + if (RegExp.$1.charAt(0) == SYS.slash || RegExp.$1.charAt(1) == ":") { // absolute path to here + SYS.pwd = new FilePath(RegExp.$1).toDir().toString(); + } + else { // relative path to here + SYS.pwd = new FilePath(SYS.userDir + SYS.slash + RegExp.$1).toDir().toString(); + } + arguments.pop(); +} +else { + print("The run.js script requires you use jsrun.jar."); + quit(); +} + +// shortcut +var File = Packages.java.io.File; + +/** + * @namespace A collection of functions that deal with reading a writing to disk. + */ +IO = { + + /** + * Create a new file in the given directory, with the given name and contents. + */ + saveFile: function(/**string*/ outDir, /**string*/ fileName, /**string*/ content) { + var out = new Packages.java.io.PrintWriter( + new Packages.java.io.OutputStreamWriter( + new Packages.java.io.FileOutputStream(outDir+SYS.slash+fileName), + IO.encoding + ) + ); + out.write(content); + out.flush(); + out.close(); + }, + + /** + * @type string + */ + readFile: function(/**string*/ path) { + if (!IO.exists(path)) { + throw "File doesn't exist there: "+path; + } + return readFile(path, IO.encoding); + }, + + /** + * @param inFile + * @param outDir + * @param [fileName=The original filename] + */ + copyFile: function(/**string*/ inFile, /**string*/ outDir, /**string*/ fileName) { + if (fileName == null) fileName = FilePath.fileName(inFile); + + var inFile = new File(inFile); + var outFile = new File(outDir+SYS.slash+fileName); + + var bis = new Packages.java.io.BufferedInputStream(new Packages.java.io.FileInputStream(inFile), 4096); + var bos = new Packages.java.io.BufferedOutputStream(new Packages.java.io.FileOutputStream(outFile), 4096); + var theChar; + while ((theChar = bis.read()) != -1) { + bos.write(theChar); + } + bos.close(); + bis.close(); + }, + + /** + * Creates a series of nested directories. + */ + mkPath: function(/**Array*/ path) { + if (path.constructor != Array) path = path.split(/[\\\/]/); + var make = ""; + for (var i = 0, l = path.length; i < l; i++) { + make += path[i] + SYS.slash; + if (! IO.exists(make)) { + IO.makeDir(make); + } + } + }, + + /** + * Creates a directory at the given path. + */ + makeDir: function(/**string*/ path) { + (new File(path)).mkdir(); + }, + + /** + * @type string[] + * @param dir The starting directory to look in. + * @param [recurse=1] How many levels deep to scan. + * @returns An array of all the paths to files in the given dir. + */ + ls: function(/**string*/ dir, /**number*/ recurse, _allFiles, _path) { + if (_path === undefined) { // initially + var _allFiles = []; + var _path = [dir]; + } + if (_path.length == 0) return _allFiles; + if (recurse === undefined) recurse = 1; + + dir = new File(dir); + if (!dir.directory) return [String(dir)]; + var files = dir.list(); + + for (var f = 0; f < files.length; f++) { + var file = String(files[f]); + if (file.match(/^\.[^\.\/\\]/)) continue; // skip dot files + + if ((new File(_path.join(SYS.slash)+SYS.slash+file)).list()) { // it's a directory + _path.push(file); + if (_path.length-1 < recurse) IO.ls(_path.join(SYS.slash), recurse, _allFiles, _path); + _path.pop(); + } + else { + _allFiles.push((_path.join(SYS.slash)+SYS.slash+file).replace(SYS.slash+SYS.slash, SYS.slash)); + } + } + + return _allFiles; + }, + + /** + * @type boolean + */ + exists: function(/**string*/ path) { + file = new File(path); + + if (file.isDirectory()){ + return true; + } + if (!file.exists()){ + return false; + } + if (!file.canRead()){ + return false; + } + return true; + }, + + /** + * + */ + open: function(/**string*/ path, /**string*/ append) { + var append = true; + var outFile = new File(path); + var out = new Packages.java.io.PrintWriter( + new Packages.java.io.OutputStreamWriter( + new Packages.java.io.FileOutputStream(outFile, append), + IO.encoding + ) + ); + return out; + }, + + /** + * Sets {@link IO.encoding}. + * Encoding is used when reading and writing text to files, + * and in the meta tags of HTML output. + */ + setEncoding: function(/**string*/ encoding) { + if (/ISO-8859-([0-9]+)/i.test(encoding)) { + IO.encoding = "ISO8859_"+RegExp.$1; + } + else { + IO.encoding = encoding; + } + }, + + /** + * @default "utf-8" + * @private + */ + encoding: "utf-8", + + /** + * Load the given script. + */ + include: function(relativePath) { + load(SYS.pwd+relativePath); + }, + + /** + * Loads all scripts from the given directory path. + */ + includeDir: function(path) { + if (!path) return; + + for (var lib = IO.ls(SYS.pwd+path), i = 0; i < lib.length; i++) + if (/\.js$/i.test(lib[i])) load(lib[i]); + } +} + +// now run the application +IO.include("frame.js"); +IO.include("main.js"); + +main(); diff --git a/html/RentForCamp/node_modules/JSV/jsdoc-toolkit/app/t/TestDoc.js b/html/RentForCamp/node_modules/JSV/jsdoc-toolkit/app/t/TestDoc.js new file mode 100644 index 0000000..c0768b7 --- /dev/null +++ b/html/RentForCamp/node_modules/JSV/jsdoc-toolkit/app/t/TestDoc.js @@ -0,0 +1,144 @@ +var TestDoc = { + fails: 0, + plans: 0, + passes: 0, + results: [] +}; + +TestDoc.record = function(result) { + TestDoc.results.push(result); + if (typeof result.verdict == "boolean") { + if (result.verdict === false) TestDoc.fails++; + if (result.verdict === true) TestDoc.passes++; + } +} + +TestDoc.prove = function(filePath) { + if (typeof document != "undefined" && typeof document.write != "undefined") { + if (TestDoc.console) print = function(s) { TestDoc.console.appendChild(document.createTextNode(s+"\n")); } + else print = function(s) { document.write(s+"
@extends tag), but in
+ * reality it is completely unrelated to Shape.
+ * @param {int} sideLength The length of one side for the new Hexagon
+ * @example
+ * var h = new Hexagon(2);
+ * @example
+ * if (hasHex) {
+ * hex = new Hexagon(5);
+ * color = hex.getColor();
+ * }
+ */
+function Hexagon(sideLength) {
+}
+
+
+/**
+ * This is an unattached (static) function that adds two integers together.
+ * @param {int} One The first number to add
+ * @param {int} Two The second number to add
+ * @author Gabriel Reid
+ * @deprecated So you shouldn't use it anymore! Use {@link Shape#getClassName} instead.
+ */
+function Add(One, Two){
+ return One + Two;
+}
+
+
+/**
+ * The color of this shape
+ * @type Color
+ */
+Shape.prototype.color = null;
+
+/**
+ * The border of this shape.
+ * @field
+ * @type int
+ */
+Shape.prototype.border = function(){return border;};
+
+/*
+ * These are all the instance method implementations for Shape
+ */
+
+/**
+ * Get the coordinates of this shape. It is assumed that we're always talking
+ * about shapes in a 2D location here.
+ * @requires The {@link Shape} class
+ * @returns A Coordinate object representing the location of this Shape
+ * @type Coordinate[]
+ */
+Shape.prototype.getCoords = function(){
+ return this.coords;
+}
+
+/**
+ * Get the color of this shape.
+ * @see #setColor
+ * @see The Color library.
+ * @link Shape
+ * @type Color
+ */
+Shape.prototype.getColor = function(){
+ return this.color;
+}
+
+/**
+ * Set the coordinates for this Shape
+ * @param {Coordinate} coordinates The coordinates to set for this Shape
+ */
+Shape.prototype.setCoords = function(coordinates){
+ this.coords = coordinates;
+}
+
+/**
+ * Set the color for this Shape
+ * @param {Color} color The color to set for this Shape
+ * @param other There is no other param, but it can still be documented if
+ * optional parameters are used
+ * @throws NonExistantColorException (no, not really!)
+ * @see #getColor
+ */
+Shape.prototype.setColor = function(color){
+ this.color = color;
+}
+
+/**
+ * Clone this shape
+ * @returns A copy of this shape
+ * @type Shape
+ * @author Gabriel Reid
+ */
+Shape.prototype.clone = function(){
+ return new Shape();
+}
+
+/**
+ * Create a new Rectangle instance.
+ * @class A basic rectangle class, inherits from Shape.
+ * This class could be considered a concrete implementation class
+ * @constructor
+ * @param {int} width The optional width for this Rectangle
+ * @param {int} height Thie optional height for this Rectangle
+ * @author Gabriel Reid
+ * @see Shape is the base class for this
+ * @augments Shape
+ * @hilited
+ */
+function Rectangle(width, // This is the width
+ height // This is the height
+ ){
+ if (width){
+ this.width = width;
+ if (height){
+ this.height = height;
+ }
+ }
+}
+
+
+/* Inherit from Shape */
+Rectangle.prototype = new Shape();
+
+/**
+ * Value to represent the width of the Rectangle.
+ *
+ var x (x < 1);
+ alert("This 'is' \"code\"");
+
+ * @name My Cool Library
+ * @author Joe Smith jsmith@company.com
+ * @version 0.1
+ */
+
+/**
+ * Gets the current foo
+ * @param {String} fooId The unique identifier for the foo.
+ * @return {Object} Returns the current foo.
+ */
+function getFoo(fooID){
+}
\ No newline at end of file
diff --git a/html/RentForCamp/node_modules/JSV/jsdoc-toolkit/app/test/param_inline.js b/html/RentForCamp/node_modules/JSV/jsdoc-toolkit/app/test/param_inline.js
new file mode 100644
index 0000000..09845b2
--- /dev/null
+++ b/html/RentForCamp/node_modules/JSV/jsdoc-toolkit/app/test/param_inline.js
@@ -0,0 +1,37 @@
+/**
+ @constructor
+ @param columns The number of columns.
+*/
+function Layout(/**int*/columns){
+ /**
+ @param [id] The id of the element.
+ @param elName The name of the element.
+ */
+ this.getElement = function(
+ /** string */ elName,
+ /** number|string */ id
+ ) {
+ };
+
+ /**
+ @constructor
+ */
+ this.Canvas = function(top, left, /**int*/width, height) {
+ /** Is it initiated yet? */
+ this.initiated = true;
+ }
+
+ this.rotate = function(/**nothing*/) {
+ }
+
+ /**
+ @param x
+ @param y
+ @param {zoppler} z*/
+ this.init = function(x, y, /**abbler*/z) {
+ /** The xyz. */
+ this.xyz = x+y+z;
+ this.getXyz = function() {
+ }
+ }
+}
diff --git a/html/RentForCamp/node_modules/JSV/jsdoc-toolkit/app/test/params_optional.js b/html/RentForCamp/node_modules/JSV/jsdoc-toolkit/app/test/params_optional.js
new file mode 100644
index 0000000..18bf598
--- /dev/null
+++ b/html/RentForCamp/node_modules/JSV/jsdoc-toolkit/app/test/params_optional.js
@@ -0,0 +1,8 @@
+
+/**
+ * @param {Page[]} pages
+ * @param {number} [id] Specifies the id, if applicable.
+ * @param {String} [title = This is untitled.] Specifies the title.
+ */
+function Document(pages, id, title){
+}
\ No newline at end of file
diff --git a/html/RentForCamp/node_modules/JSV/jsdoc-toolkit/app/test/prototype.js b/html/RentForCamp/node_modules/JSV/jsdoc-toolkit/app/test/prototype.js
new file mode 100644
index 0000000..1147008
--- /dev/null
+++ b/html/RentForCamp/node_modules/JSV/jsdoc-toolkit/app/test/prototype.js
@@ -0,0 +1,17 @@
+/** @constructor */
+function Article() {
+}
+
+Article.prototype.init = function(title) {
+ /** the instance title */
+ this.title = title;
+
+ /** the static counter */
+ Article.counter = 1;
+}
+
+a = new Article();
+a.Init("my title");
+
+print(a.title);
+print(Article.counter);
\ No newline at end of file
diff --git a/html/RentForCamp/node_modules/JSV/jsdoc-toolkit/app/test/prototype_nested.js b/html/RentForCamp/node_modules/JSV/jsdoc-toolkit/app/test/prototype_nested.js
new file mode 100644
index 0000000..e8ca1ce
--- /dev/null
+++ b/html/RentForCamp/node_modules/JSV/jsdoc-toolkit/app/test/prototype_nested.js
@@ -0,0 +1,9 @@
+/** @constructor */
+function Word() {
+}
+
+Word.prototype.reverse = function() {
+}
+
+Word.prototype.reverse.utf8 = function() {
+}
\ No newline at end of file
diff --git a/html/RentForCamp/node_modules/JSV/jsdoc-toolkit/app/test/prototype_oblit.js b/html/RentForCamp/node_modules/JSV/jsdoc-toolkit/app/test/prototype_oblit.js
new file mode 100644
index 0000000..6cfc39c
--- /dev/null
+++ b/html/RentForCamp/node_modules/JSV/jsdoc-toolkit/app/test/prototype_oblit.js
@@ -0,0 +1,13 @@
+/** @constructor */
+function Article() {
+}
+
+Article.prototype = {
+ /** instance get title */
+ getTitle: function(){
+ }
+}
+
+/** static get title */
+Article.getTitle = function(){
+}
\ No newline at end of file
diff --git a/html/RentForCamp/node_modules/JSV/jsdoc-toolkit/app/test/prototype_oblit_constructor.js b/html/RentForCamp/node_modules/JSV/jsdoc-toolkit/app/test/prototype_oblit_constructor.js
new file mode 100644
index 0000000..9248248
--- /dev/null
+++ b/html/RentForCamp/node_modules/JSV/jsdoc-toolkit/app/test/prototype_oblit_constructor.js
@@ -0,0 +1,24 @@
+/** @constructor */
+function Article() {
+}
+
+Article.prototype = {
+ /** @constructor */
+ Title: function(title) {
+ /** the value of the Title instance */
+ this.title = title;
+ },
+
+ init: function(pages) {
+ /** the value of the pages of the Article instance */
+ this.pages = pages;
+ }
+}
+
+f = new Article();
+f.init("one two three");
+
+t = new f.Title("my title");
+
+print(f.pages);
+print(t.title);
\ No newline at end of file
diff --git a/html/RentForCamp/node_modules/JSV/jsdoc-toolkit/app/test/public.js b/html/RentForCamp/node_modules/JSV/jsdoc-toolkit/app/test/public.js
new file mode 100644
index 0000000..35d34f6
--- /dev/null
+++ b/html/RentForCamp/node_modules/JSV/jsdoc-toolkit/app/test/public.js
@@ -0,0 +1,10 @@
+/**@constructor*/
+function Foo() {
+ /**
+ @public
+ @static
+ @field
+ */
+ var bar = function(x) {
+ }
+}
\ No newline at end of file
diff --git a/html/RentForCamp/node_modules/JSV/jsdoc-toolkit/app/test/scripts/code.js b/html/RentForCamp/node_modules/JSV/jsdoc-toolkit/app/test/scripts/code.js
new file mode 100644
index 0000000..e9d7ed2
--- /dev/null
+++ b/html/RentForCamp/node_modules/JSV/jsdoc-toolkit/app/test/scripts/code.js
@@ -0,0 +1,5 @@
+/**
+ @class
+ */
+function thisiscode() {
+}
\ No newline at end of file
diff --git a/html/RentForCamp/node_modules/JSV/jsdoc-toolkit/app/test/scripts/notcode.txt b/html/RentForCamp/node_modules/JSV/jsdoc-toolkit/app/test/scripts/notcode.txt
new file mode 100644
index 0000000..fcd737e
--- /dev/null
+++ b/html/RentForCamp/node_modules/JSV/jsdoc-toolkit/app/test/scripts/notcode.txt
@@ -0,0 +1,5 @@
+(This is not code)
+function foo(){{{{
+(
+!
+@
\ No newline at end of file
diff --git a/html/RentForCamp/node_modules/JSV/jsdoc-toolkit/app/test/shared.js b/html/RentForCamp/node_modules/JSV/jsdoc-toolkit/app/test/shared.js
new file mode 100644
index 0000000..e1c277a
--- /dev/null
+++ b/html/RentForCamp/node_modules/JSV/jsdoc-toolkit/app/test/shared.js
@@ -0,0 +1,42 @@
+
+/**
+ * Builtin object.
+ * @class
+ * @name Array
+ */
+
+/**#@+
+ * Extension to builtin array.
+ * @memberOf Array
+ * @method
+ */
+
+/**
+ * @returns Boolen if some array members...
+ */
+Array.prototype.some = function(){};
+
+/**
+ * Change every element of an array.
+ * @returns Filtered array copy.
+ */
+Array.prototype.filter = function(){};
+
+/**#@-*/
+
+
+/**
+ * A first in, first out data structure.
+ * @constructor
+ */
+Queue = function(){};
+
+/**#@+
+ * Extension to Queue.
+ * @memberOf Queue
+ */
+
+rewind = function(){
+}
+
+// should close automatically here.
\ No newline at end of file
diff --git a/html/RentForCamp/node_modules/JSV/jsdoc-toolkit/app/test/shared2.js b/html/RentForCamp/node_modules/JSV/jsdoc-toolkit/app/test/shared2.js
new file mode 100644
index 0000000..3f7736a
--- /dev/null
+++ b/html/RentForCamp/node_modules/JSV/jsdoc-toolkit/app/test/shared2.js
@@ -0,0 +1,2 @@
+startOver = function(){
+}
\ No newline at end of file
diff --git a/html/RentForCamp/node_modules/JSV/jsdoc-toolkit/app/test/shortcuts.js b/html/RentForCamp/node_modules/JSV/jsdoc-toolkit/app/test/shortcuts.js
new file mode 100644
index 0000000..f738f1e
--- /dev/null
+++ b/html/RentForCamp/node_modules/JSV/jsdoc-toolkit/app/test/shortcuts.js
@@ -0,0 +1,22 @@
+// /**#=+
+// * {
+// * 'D': 'Date.prototype',
+// * '$N': 'Number'
+// * }
+// */
+// var D = Date.prototype,
+// $N = Number;
+//
+// D.locale = function(){
+// };
+//
+// /**
+// @return {string} The cardinal number string.
+// */
+// $N.nth = function(n){
+// };
+//
+// LOAD.file = function(){
+// }
+//
+// /**#=-*/
\ No newline at end of file
diff --git a/html/RentForCamp/node_modules/JSV/jsdoc-toolkit/app/test/static_this.js b/html/RentForCamp/node_modules/JSV/jsdoc-toolkit/app/test/static_this.js
new file mode 100644
index 0000000..9407b20
--- /dev/null
+++ b/html/RentForCamp/node_modules/JSV/jsdoc-toolkit/app/test/static_this.js
@@ -0,0 +1,13 @@
+/** the parent */
+var box = {};
+
+/** @namespace */
+box.holder = {}
+
+box.holder.foo = function() {
+ /** the counter */
+ this.counter = 1;
+}
+
+box.holder.foo();
+print(box.holder.counter);
diff --git a/html/RentForCamp/node_modules/JSV/jsdoc-toolkit/app/test/synonyms.js b/html/RentForCamp/node_modules/JSV/jsdoc-toolkit/app/test/synonyms.js
new file mode 100644
index 0000000..09066b9
--- /dev/null
+++ b/html/RentForCamp/node_modules/JSV/jsdoc-toolkit/app/test/synonyms.js
@@ -0,0 +1,31 @@
+/**
+ @class
+ @inherits Bar#zop as #my_zop
+*/
+function Foo() {
+ /** this is a zip. */
+ this.zip = function() {}
+
+ /** from Bar */
+ this.my_zop = new Bar().zop;
+}
+
+/**
+ @class
+ @borrows Foo#zip as this.my_zip
+*/
+function Bar() {
+ /** this is a zop. */
+ this.zop = function() {}
+
+ /** from Foo */
+ this.my_zip = new Foo().zip;
+}
+
+/** @namespace */
+var myObject = {
+ /**
+ @type function
+ */
+ myFunc: getFunction()
+}
\ No newline at end of file
diff --git a/html/RentForCamp/node_modules/JSV/jsdoc-toolkit/app/test/tosource.js b/html/RentForCamp/node_modules/JSV/jsdoc-toolkit/app/test/tosource.js
new file mode 100644
index 0000000..706d476
--- /dev/null
+++ b/html/RentForCamp/node_modules/JSV/jsdoc-toolkit/app/test/tosource.js
@@ -0,0 +1,23 @@
+/**
+ * @param {Object} object
+ * @return {string}
+ */
+function valueOf(object) {}
+
+/**
+ * @param {Object} object
+ * @return {string}
+ */
+function toString(object) {}
+
+/**
+ * @param {Object} object
+ * @return {string}
+ */
+function toSource(object) {}
+
+/**
+ * @param {Object} object
+ * @return {string}
+ */
+function constructor(object) {}
\ No newline at end of file
diff --git a/html/RentForCamp/node_modules/JSV/jsdoc-toolkit/app/test/variable_redefine.js b/html/RentForCamp/node_modules/JSV/jsdoc-toolkit/app/test/variable_redefine.js
new file mode 100644
index 0000000..2c07da0
--- /dev/null
+++ b/html/RentForCamp/node_modules/JSV/jsdoc-toolkit/app/test/variable_redefine.js
@@ -0,0 +1,14 @@
+/** @constructor */
+function Foo() {
+ var bar = 1;
+ bar = 2; // redefining a private
+
+ this.baz = 1;
+ baz = 2; // global
+
+ /** a private */
+ var blap = {
+ /** in here */
+ tada: 1
+ }
+}
\ No newline at end of file
diff --git a/html/RentForCamp/node_modules/JSV/jsdoc-toolkit/changes.txt b/html/RentForCamp/node_modules/JSV/jsdoc-toolkit/changes.txt
new file mode 100644
index 0000000..b0acbab
--- /dev/null
+++ b/html/RentForCamp/node_modules/JSV/jsdoc-toolkit/changes.txt
@@ -0,0 +1,124 @@
+== 2.4.0 ==
+
+ * Fixed bug that added mutiple symbols with the same name to docs.
+ * Added support for the -m option to suppress warnings for multiple docs.
+ * Added patch by brownsea42 to support quoted user variables on the command line. ( issue #281 )
+ * Fixed bug that sometimes caused links to events to be incorrect. ( issue #292 )
+
+== 2.3.3 ==
+
+ * Fixed bug that made all fields declared with the @property tag static. ( issue #262 )
+ * Minor fix to better handle trailing slash on path to template (from jwmetrocat). ( issue #237 )
+ * Fix for @memberOf when applied to inner members. ( issue #264 )
+ * Fix for @memberOf when applied to symbols documented with @name. ( issue #260 )
+ * Applied patch from kunhualqk, fix for bug where @link to borrowed member did not resolve to parent class. ( issue #218 )
+ * Fix for @requires not linking back to the required class
+ * Added experimental support for @constructs to have an argument, the class name, when applied to a function assignment.
+
+== 2.3.2 ==
+
+ * Minor update to the usage notes and corrected the version number displayed in the output.
+
+== 2.3.1 ==
+
+ * Fixed HTML typo in allfiles template. ( issue #228 )
+ * Modified template to display version information for classes.
+ * Modified template to better support multiple methods with the same name.
+ * Fixed bug that caused template to error when backtick characters appeared around class names.
+
+== 2.3.0 ==
+
+ * Added option -u, --unique to avoid bug that causes multiple symbols with names that differ only by case to overwrite each others output on case-insensitive filesystems. ( issue #162 )
+ * Fixed bug where {@links} in @deprecated tags did not resolve. ( issue #220 )
+ * Fixed bug that caused parens around a function to make it to be unrecognized. ( issue #213 )
+ * Fixed bug prevented explicit links to named anchors from working (thanks katgao.pku). ( issue #215 )
+ * Fixed bug that prevented full description from appearing in file overview. ( issue #224 )
+
+== 2.2.1 ==
+
+ * Fixed bug with class template, where sorting of methods was accidentally removed (thanks dezfowler).
+ * Added missing test files for the @exports unit tests.
+
+== 2.2.0 ==
+
+ * Fixed bug that caused exception when given a folder containing non-js files, even with the x commandline option set to "js". ( issue #193 )
+ * Fixed typo in index template [patch submitted by olle]. ( issue #198 )
+ * Modified @borrows tag experimentally to allow for missing "as ..." clause.
+ * Added support for the @exports tag, to allow one symbol to be documented as another.
+ * Added support for the -S option to document code following the Secure Modules pattern.
+
+== 2.1.0 ==
+
+ * Added support for the @event tag.
+ * Fixed bug that prevented the : character from appearing in symbol names.
+ * Fixed bug that prevented underscored symbols marked with @public being tagged as private. (issue #184 )
+ * Fixed bug that randomly affected the @memberOf tag when the name of the symbol did not include the parent name.
+ * Fixed bug that prevented templates that were not in the jsdoc-toolkit folder from being found. ( issue #176 )
+ * Added ability to check for trailing slash on template path. ( issue #177 )
+ * Modified classDesc so that it no longer is appended with the constructor desc.
+ * Fixed call to plugin onDocCommentSrc.
+ * Added missing support for inline doc comments for function return types. ( issue #189 )
+ * Added command line option -q, --quiet.
+ * Added command line option -E, --exclude. ( issue #143 )
+ * Added 2 more hooks for plugins. ( issue #163 )
+ * Added support for extending built-ins. ( issue #160 )
+ * Added "compact" option to JSDOC.JsPlate.prototype.process. ( issue #159 )
+ * @augments no longer documents static members as inherited. ( issue #138 )
+ * @link to a class now goes to the page for that class, not the constructor. ( issue #178 )
+ * Warnings of mismatched curly brace now include filename. ( issue #166 )
+ * Fixed bug affecting template paths loaded via a configuration file when the trailing slash is missing. ( issue #191 )
+ * Minor optimizations.
+
+== 2.0.2 ==
+
+ * Fixed bug that sometimes caused an example of division in the source code to be interpretted as a regex by the JsDoc Toolkit analyzer. ( issue #158 )
+ * Fixed a bug that prevented private variables marked as @public from appearing in the documentation. ( issue #161 )
+ * Fixed bug that prevented variable names with underscored properties from appearing in summaries. ( issue #173 )
+
+== 2.0.1 ==
+
+ * Fixed bug that prevented @fileOverview tag from being recognized.
+ * Added support for @fieldOf as a synonym for @field plus @memberOf.
+ * Added support for @name tag in a @fileOverview comment to control the displayed name of the file.
+ * Added support for multiple @example tags. ( issue #152 )
+ * Modified style sheet of jsdoc template to make more readable. ( issue #151 )
+ * Fixed bug that prevented @since documentation from displaying correctly when it appeared in a class. ( issue #150 )
+ * Fixed bug that caused inhertited properties to sometimes not resolve correctly. ( issue #144 )
+ * Modified so that trailing whitespace in @example is always trimmed. ( issue #153 )
+ * Added support for elseif to JsPlate. (hat tip to fredck)
+ * Added support for @location urls in the @overview comment to the jsdoc template.
+
+== Changes From Versions 1.4.0 to 2.0.0 ==
+
+ * Upgraded included version of Rhino from 1.6 to 1.7R1.
+ * Removed circular references in parsed documentation objects.
+ * Improved inheritance handling, now properties and events can be inherited same as methods.
+ * Improved handling of cross-file relationships, now having two related objects in separate files is not a problem.
+ * Improved ability to recognize membership of previously defined objects.
+ * Added ability to redefine parsing behavior with plugins.
+ * @methodOf is a synonym for @function and @memberOf.
+ * Added @default to document default values of members that are objects.
+ * Added ability to parse and refer to inner functions.
+ * Fixed bug that appeared when calling a method to set properties of the instance referred to by "this".
+ * Added ability to automatically create links to other symbols.
+ * New "jsdoc" template now produces fully W3C valid XHTML.
+ * Inline parameter type hint comments are now documented.
+ * Fixed error: Locally scoped variables (declared with var) no longer appear as global.
+ * It is now possible to run JsDoc Toolkit from any directory.
+ * Added support for inline {@link ...} tags.
+ * Added support for the -H command-line option to allow for custom content handlers.
+ * Tag names @inherits and @scope changed to @borrows and @lends.
+ ? Combining @constructor in a doclet with @lends now supported.
+ * Multiple @lend tags now supported.
+ * Added support for the @constructs tag, used inside a @lends block.
+ * Added support for the @constant tag.
+ * Fixed bug that prevented the use of [] as a default value.
+ * Added support for the @field tag.
+ * Added support for the @public tag (applied to inner functions).
+ * @namespace tag can now be applied to functions, not just object literals.
+ * Added support for the -s command line option to suppress source code output.
+ * Added new unit test framework.
+ * Underscored symbols are now treated as if they have a @private tag by default.
+ * Improved support for anonymous constructors.
+ * Added support for the nocode meta tag.
+
\ No newline at end of file
diff --git a/html/RentForCamp/node_modules/JSV/jsdoc-toolkit/conf/sample.conf b/html/RentForCamp/node_modules/JSV/jsdoc-toolkit/conf/sample.conf
new file mode 100644
index 0000000..ad0f08e
--- /dev/null
+++ b/html/RentForCamp/node_modules/JSV/jsdoc-toolkit/conf/sample.conf
@@ -0,0 +1,31 @@
+/*
+ This is an example of one way you could set up a configuration file to more
+ conveniently define some commandline options. You might like to do this if
+ you frequently reuse the same options. Note that you don't need to define
+ every option in this file, you can combine a configuration file with
+ additional options on the commandline if your wish.
+
+ You would include this configuration file by running JsDoc Toolkit like so:
+ java -jar jsrun.jar app/run.js -c=conf/sample.conf
+
+*/
+
+{
+ // source files to use
+ _: ['app/test/jsdoc_test.js'],
+
+ // document all functions, even uncommented ones
+ a: true,
+
+ // including those marked @private
+ p: true,
+
+ // some extra variables I want to include
+ D: {generatedBy: "Michael Mathews", copyright: "2008"},
+
+ // use this directory as the output directory
+ d: "docs",
+
+ // use this template
+ t: "templates/jsdoc"
+}
\ No newline at end of file
diff --git a/html/RentForCamp/node_modules/JSV/jsdoc-toolkit/java/build.xml b/html/RentForCamp/node_modules/JSV/jsdoc-toolkit/java/build.xml
new file mode 100644
index 0000000..bb845ce
--- /dev/null
+++ b/html/RentForCamp/node_modules/JSV/jsdoc-toolkit/java/build.xml
@@ -0,0 +1,36 @@
+↩ {+new Link().toFile("index.html").withText("Class Index")+}
+↩ {+new Link().toFile("files.html").withText("File Index")+}
diff --git a/html/RentForCamp/node_modules/JSV/jsdoc-toolkit/templates/bluelabel/allfiles.tmpl b/html/RentForCamp/node_modules/JSV/jsdoc-toolkit/templates/bluelabel/allfiles.tmpl new file mode 100644 index 0000000..530c932 --- /dev/null +++ b/html/RentForCamp/node_modules/JSV/jsdoc-toolkit/templates/bluelabel/allfiles.tmpl @@ -0,0 +1,72 @@ + + + + + {! Link.base = ""; /* all generated links will be relative to this */ !} + ++ Version + {+ data.version +}. +
+Extends + {+ + data.augments + .sort() + .map( + function($) { return new Link().toSymbol($); } + ) + .join(", ") + +}. +
++ {+resolveLinks(data.classDesc)+} +
+ ++ Defined in: {+new Link().toSrc(data.srcFile)+}. +
+| Constructor Attributes | +Constructor Name and Description | +
|---|---|
| {! + if (data.isPrivate) output += "<private> "; + if (data.isInner) output += "<inner> "; + !} + + | +
+
+ {+ new Link().toSymbol(data.alias).inner('constructor')+}
+ {+resolveLinks(summarize(data.desc))+} + |
+
| Field Attributes | +Field Name and Description | +
|---|---|
| {! + if (member.isPrivate) output += "<private> "; + if (member.isInner) output += "<inner> "; + if (member.isStatic) output += "<static> "; + if (member.isConstant) output += "<constant> "; + !} + + | +
+
+
+ {+resolveLinks(summarize(member.desc))+} + |
+
| Method Attributes | +Method Name and Description | +
|---|---|
| {! + if (member.isPrivate) output += "<private> "; + if (member.isInner) output += "<inner> "; + if (member.isStatic) output += "<static> "; + !} + + | +
+ {+resolveLinks(summarize(member.desc))+} + |
+
| Event Attributes | +Event Name and Description | +
|---|---|
| {! + if (member.isPrivate) output += "<private> "; + if (member.isInner) output += "<inner> "; + if (member.isStatic) output += "<static> "; + !} + + | +
+ {+resolveLinks(summarize(member.desc))+} + |
+
+ {+resolveLinks(data.desc)+}
+
Author: {+data.author+}.
{+example+}
+ + {+resolveLinks(member.desc)+} +
++ Defined in: {+new Link().toSrc(member.srcFile)+}. +
+{+example+}
+ + {+resolveLinks(member.desc)+} +
++ Defined in: {+new Link().toSrc(member.srcFile)+}. +
+{+example+}
+ + {+resolveLinks(member.desc)+} +
++ Defined in: {+new Link().toSrc(member.srcFile)+}. +
+{+example+}
+ + {+resolveLinks(data.classDesc)+} +
+ + +| Constructor Attributes | +Constructor Name and Description | +
|---|---|
| {! + if (data.isPrivate) output += "<private> "; + if (data.isInner) output += "<inner> "; + !} | +
+
+ {+ new Link().toSymbol(data.alias).inner('constructor')+}
+ {+resolveLinks(summarize(data.desc))+}
+ |
+
| Field Attributes | +Field Name and Description | +
|---|---|
| {! + if (member.isPrivate) output += "<private> "; + if (member.isInner) output += "<inner> "; + if (member.isStatic) output += "<static> "; + if (member.isConstant) output += "<constant> "; + !} | +
+
+
+ {+resolveLinks(summarize(member.desc))+}
+ |
+
| Method Attributes | +Method Name and Description | +
|---|---|
| {! + if (member.isPrivate) output += "<private> "; + if (member.isInner) output += "<inner> "; + if (member.isStatic) output += "<static> "; + !} | +
+ {+resolveLinks(summarize(member.desc))+}
+ |
+
| Event Attributes | +Event Name and Description | +
|---|---|
| {! + if (member.isPrivate) output += "<private> "; + if (member.isInner) output += "<inner> "; + if (member.isStatic) output += "<static> "; + !} | +
+ {+resolveLinks(summarize(member.desc))+}
+ |
+
{+example+}
+ {+example+}
+ {+example+}
+ {+example+}
+ {+resolveLinks(summarize(thisClass.classDesc))+}
+
+
Version
+ {+ data.version +}.
+
Extends
+ {+
+ data.augments
+ .sort()
+ .map(
+ function($) { return new Link().toSymbol($); }
+ )
+ .join(", ")
+ +}.
+
Defined in: {+new Link().toSrc(data.srcFile)+}.
+
| Constructor Attributes | +Constructor Name and Description | +
|---|---|
| {! + if (data.isPrivate) output += "<private> "; + if (data.isInner) output += "<inner> "; + !} | +
+
+ {+ new Link().toSymbol(data.alias).inner('constructor')+}
+ {+resolveLinks(summarize(data.desc))+}
+ |
+
| Field Attributes | +Field Name and Description | +
|---|---|
| {! + if (member.isPrivate) output += "<private> "; + if (member.isInner) output += "<inner> "; + if (member.isStatic) output += "<static> "; + if (member.isConstant) output += "<constant> "; + !} | +
+
+
+ {+resolveLinks(summarize(member.desc))+}
+ |
+
| Method Attributes | +Method Name and Description | +
|---|---|
| {! + if (member.isPrivate) output += "<private> "; + if (member.isInner) output += "<inner> "; + if (member.isStatic) output += "<static> "; + !} | +
+ {+resolveLinks(summarize(member.desc))+}
+ |
+
| Utility Method Attributes | +Utility Method Name and Description | +
|---|---|
| {! + if (member.isPrivate) output += "<private> "; + if (member.isInner) output += "<inner> "; + if (member.isStatic) output += "<static> "; + !} | +
+ {+resolveLinks(summarize(member.desc))+}
+ |
+
{+example+}
+ {+example+}
+ {+example+}
+ {+example+}
+ + * The key of each item in the table is the URI of the instance that was validated. + * The value of this key is an array of strings of URIs of the schema that validated it. + *
+ * + * @name Report.prototype.validated + * @type Object + * @see Report#registerValidation + * @see Report#isValidatedBy + */ + this.validated = {}; + + /** + * If the report is generated by {@link Environment#validate}, this field is the generated instance. + * + * @name Report.prototype.instance + * @type JSONInstance + * @see Environment#validate + */ + + /** + * If the report is generated by {@link Environment#validate}, this field is the generated schema. + * + * @name Report.prototype.schema + * @type JSONSchema + * @see Environment#validate + */ + + /** + * If the report is generated by {@link Environment#validate}, this field is the schema's schema. + * This value is the same as callingschema.getSchema().
+ *
+ * @name Report.prototype.schemaSchema
+ * @type JSONSchema
+ * @see Environment#validate
+ * @see JSONSchema#getSchema
+ */
+ }
+
+ /**
+ * Adds a {@link ValidationError} object to the errors field.
+ *
+ * @param {JSONInstance|String} instance The instance (or instance URI) that is invalid
+ * @param {JSONSchema|String} schema The schema (or schema URI) that was validating the instance
+ * @param {String} attr The attribute that failed to validated
+ * @param {String} message A user-friendly message on why the schema attribute failed to validate the instance
+ * @param {Any} details The value of the schema attribute
+ */
+
+ Report.prototype.addError = function (instance, schema, attr, message, details) {
+ this.errors.push({
+ uri : instance instanceof JSONInstance ? instance.getURI() : instance,
+ schemaUri : schema instanceof JSONInstance ? schema.getURI() : schema,
+ attribute : attr,
+ message : message,
+ details : stripInstances(details)
+ });
+ };
+
+ /**
+ * Registers that the provided instance URI has been validated by the provided schema URI.
+ * This is recorded in the validated field.
+ *
+ * @param {String} uri The URI of the instance that was validated
+ * @param {String} schemaUri The URI of the schema that validated the instance
+ */
+
+ Report.prototype.registerValidation = function (uri, schemaUri) {
+ if (!this.validated[uri]) {
+ this.validated[uri] = [ schemaUri ];
+ } else {
+ this.validated[uri].push(schemaUri);
+ }
+ };
+
+ /**
+ * Returns if an instance with the provided URI has been validated by the schema with the provided URI.
+ *
+ * @param {String} uri The URI of the instance
+ * @param {String} schemaUri The URI of a schema
+ * @returns {Boolean} If the instance has been validated by the schema.
+ */
+
+ Report.prototype.isValidatedBy = function (uri, schemaUri) {
+ return !!this.validated[uri] && searchArray(this.validated[uri], schemaUri) !== -1;
+ };
+
+ /**
+ * A wrapper class for binding an Environment, URI and helper methods to an instance.
+ * This class is most commonly instantiated with {@link Environment#createInstance}.
+ *
+ * @name JSONInstance
+ * @class
+ * @param {Environment} env The environment this instance belongs to
+ * @param {JSONInstance|Any} json The value of the instance
+ * @param {String} [uri] The URI of the instance. If undefined, the URI will be a randomly generated UUID.
+ * @param {String} [fd] The fragment delimiter for properties. If undefined, uses the environment default.
+ */
+
+ function JSONInstance(env, json, uri, fd) {
+ if (json instanceof JSONInstance) {
+ if (typeof fd !== "string") {
+ fd = json._fd;
+ }
+ if (typeof uri !== "string") {
+ uri = json._uri;
+ }
+ json = json._value;
+ }
+
+ if (typeof uri !== "string") {
+ uri = "urn:uuid:" + randomUUID() + "#";
+ } else if (uri.indexOf(":") === -1) {
+ uri = formatURI(URI.resolve("urn:uuid:" + randomUUID() + "#", uri));
+ }
+
+ this._env = env;
+ this._value = json;
+ this._uri = uri;
+ this._fd = fd || this._env._options["defaultFragmentDelimiter"];
+ }
+
+ /**
+ * Returns the environment the instance is bound to.
+ *
+ * @returns {Environment} The environment of the instance
+ */
+
+ JSONInstance.prototype.getEnvironment = function () {
+ return this._env;
+ };
+
+ /**
+ * Returns the name of the type of the instance.
+ *
+ * @returns {String} The name of the type of the instance
+ */
+
+ JSONInstance.prototype.getType = function () {
+ return typeOf(this._value);
+ };
+
+ /**
+ * Returns the JSON value of the instance.
+ *
+ * @returns {Any} The actual JavaScript value of the instance
+ */
+
+ JSONInstance.prototype.getValue = function () {
+ return this._value;
+ };
+
+ /**
+ * Returns the URI of the instance.
+ *
+ * @returns {String} The URI of the instance
+ */
+
+ JSONInstance.prototype.getURI = function () {
+ return this._uri;
+ };
+
+ /**
+ * Returns a resolved URI of a provided relative URI against the URI of the instance.
+ *
+ * @param {String} uri The relative URI to resolve
+ * @returns {String} The resolved URI
+ */
+
+ JSONInstance.prototype.resolveURI = function (uri) {
+ return formatURI(URI.resolve(this._uri, uri));
+ };
+
+ /**
+ * Returns an array of the names of all the properties.
+ *
+ * @returns {Array} An array of strings which are the names of all the properties
+ */
+
+ JSONInstance.prototype.getPropertyNames = function () {
+ return keys(this._value);
+ };
+
+ /**
+ * Returns a {@link JSONInstance} of the value of the provided property name.
+ *
+ * @param {String} key The name of the property to fetch
+ * @returns {JSONInstance} The instance of the property value
+ */
+
+ JSONInstance.prototype.getProperty = function (key) {
+ var value = this._value ? this._value[key] : undefined;
+ if (value instanceof JSONInstance) {
+ return value;
+ }
+ //else
+ return new JSONInstance(this._env, value, this._uri + this._fd + escapeURIComponent(key), this._fd);
+ };
+
+ /**
+ * Returns all the property instances of the target instance.
+ * + * If the target instance is an Object, then the method will return a hash table of {@link JSONInstance}s of all the properties. + * If the target instance is an Array, then the method will return an array of {@link JSONInstance}s of all the items. + *
+ * + * @returns {Object|Array|undefined} The list of instances for all the properties + */ + + JSONInstance.prototype.getProperties = function () { + var type = typeOf(this._value), + self = this; + + if (type === "object") { + return mapObject(this._value, function (value, key) { + if (value instanceof JSONInstance) { + return value; + } + return new JSONInstance(self._env, value, self._uri + self._fd + escapeURIComponent(key), self._fd); + }); + } else if (type === "array") { + return mapArray(this._value, function (value, key) { + if (value instanceof JSONInstance) { + return value; + } + return new JSONInstance(self._env, value, self._uri + self._fd + escapeURIComponent(key), self._fd); + }); + } + }; + + /** + * Returns the JSON value of the provided property name. + * This method is a faster version of callinginstance.getProperty(key).getValue().
+ *
+ * @param {String} key The name of the property
+ * @returns {Any} The JavaScript value of the instance
+ * @see JSONInstance#getProperty
+ * @see JSONInstance#getValue
+ */
+
+ JSONInstance.prototype.getValueOfProperty = function (key) {
+ if (this._value) {
+ if (this._value[key] instanceof JSONInstance) {
+ return this._value[key]._value;
+ }
+ return this._value[key];
+ }
+ };
+
+ /**
+ * Return if the provided value is the same as the value of the instance.
+ *
+ * @param {JSONInstance|Any} instance The value to compare
+ * @returns {Boolean} If both the instance and the value match
+ */
+
+ JSONInstance.prototype.equals = function (instance) {
+ if (instance instanceof JSONInstance) {
+ return this._value === instance._value;
+ }
+ //else
+ return this._value === instance;
+ };
+
+ /**
+ * Warning: Not a generic clone function
+ * Produces a JSV acceptable clone
+ */
+
+ function clone(obj, deep) {
+ var newObj, x;
+
+ if (obj instanceof JSONInstance) {
+ obj = obj.getValue();
+ }
+
+ switch (typeOf(obj)) {
+ case "object":
+ if (deep) {
+ newObj = {};
+ for (x in obj) {
+ if (obj[x] !== O[x]) {
+ newObj[x] = clone(obj[x], deep);
+ }
+ }
+ return newObj;
+ } else {
+ return createObject(obj);
+ }
+ break;
+ case "array":
+ if (deep) {
+ newObj = new Array(obj.length);
+ x = obj.length;
+ while (--x >= 0) {
+ newObj[x] = clone(obj[x], deep);
+ }
+ return newObj;
+ } else {
+ return Array.prototype.slice.call(obj);
+ }
+ break;
+ default:
+ return obj;
+ }
+ }
+
+ /**
+ * This class binds a {@link JSONInstance} with a {@link JSONSchema} to provided context aware methods.
+ *
+ * @name JSONSchema
+ * @class
+ * @param {Environment} env The environment this schema belongs to
+ * @param {JSONInstance|Any} json The value of the schema
+ * @param {String} [uri] The URI of the schema. If undefined, the URI will be a randomly generated UUID.
+ * @param {JSONSchema|Boolean} [schema] The schema to bind to the instance. If undefined, the environment's default schema will be used. If true, the instance's schema will be itself.
+ * @extends JSONInstance
+ */
+
+ function JSONSchema(env, json, uri, schema) {
+ var fr;
+ JSONInstance.call(this, env, json, uri);
+
+ if (schema === true) {
+ this._schema = this;
+ } else if (json instanceof JSONSchema && !(schema instanceof JSONSchema)) {
+ this._schema = json._schema; //TODO: Make sure cross environments don't mess everything up
+ } else {
+ this._schema = schema instanceof JSONSchema ? schema : this._env.getDefaultSchema() || this._env.createEmptySchema();
+ }
+
+ //determine fragment delimiter from schema
+ fr = this._schema.getValueOfProperty("fragmentResolution");
+ if (fr === "dot-delimited") {
+ this._fd = ".";
+ } else if (fr === "slash-delimited") {
+ this._fd = "/";
+ }
+
+ return this.rebuild(); //this works even when called with "new"
+ }
+
+ JSONSchema.prototype = createObject(JSONInstance.prototype);
+
+ /**
+ * Returns the schema of the schema.
+ *
+ * @returns {JSONSchema} The schema of the schema
+ */
+
+ JSONSchema.prototype.getSchema = function () {
+ var uri = this._refs && this._refs["describedby"],
+ newSchema;
+
+ if (uri) {
+ newSchema = uri && this._env.findSchema(uri);
+
+ if (newSchema) {
+ if (!newSchema.equals(this._schema)) {
+ this._schema = newSchema;
+ this.rebuild(); //if the schema has changed, the context has changed - so everything must be rebuilt
+ }
+ } else if (this._env._options["enforceReferences"]) {
+ throw new InitializationError(this, this._schema, "{describedby}", "Unknown schema reference", uri);
+ }
+ }
+
+ return this._schema;
+ };
+
+ /**
+ * Returns the value of the provided attribute name.
+ * + * This method is different from {@link JSONInstance#getProperty} as the named property + * is converted using a parser defined by the schema's schema before being returned. This + * makes the return value of this method attribute dependent. + *
+ * + * @param {String} key The name of the attribute + * @param {Any} [arg] Some attribute parsers accept special arguments for returning resolved values. This is attribute dependent. + * @returns {JSONSchema|Any} The value of the attribute + */ + + JSONSchema.prototype.getAttribute = function (key, arg) { + var schemaProperty, parser, property, result, + schema = this.getSchema(); //we do this here to make sure the "describedby" reference has not changed, and that the attribute cache is up-to-date + + if (!arg && this._attributes && this._attributes.hasOwnProperty(key)) { + return this._attributes[key]; + } + + schemaProperty = schema.getProperty("properties").getProperty(key); + parser = schemaProperty.getValueOfProperty("parser"); + property = this.getProperty(key); + if (typeof parser === "function") { + result = parser(property, schemaProperty, arg); + if (!arg && this._attributes) { + this._attributes[key] = result; + } + return result; + } + //else + return property.getValue(); + }; + + /** + * Returns all the attributes of the schema. + * + * @returns {Object} A map of all parsed attribute values + */ + + JSONSchema.prototype.getAttributes = function () { + var properties, schemaProperties, key, schemaProperty, parser, + schema = this.getSchema(); //we do this here to make sure the "describedby" reference has not changed, and that the attribute cache is up-to-date + + if (!this._attributes && this.getType() === "object") { + properties = this.getProperties(); + schemaProperties = schema.getProperty("properties"); + this._attributes = {}; + for (key in properties) { + if (properties[key] !== O[key]) { + schemaProperty = schemaProperties && schemaProperties.getProperty(key); + parser = schemaProperty && schemaProperty.getValueOfProperty("parser"); + if (typeof parser === "function") { + this._attributes[key] = parser(properties[key], schemaProperty); + } else { + this._attributes[key] = properties[key].getValue(); + } + } + } + } + + return clone(this._attributes, false); + }; + + /** + * Convenience method for retrieving a link or link object from a schema. + * This method is the same as callingschema.getAttribute("links", [rel, instance])[0];.
+ *
+ * @param {String} rel The link relationship
+ * @param {JSONInstance} [instance] The instance to resolve any URIs from
+ * @returns {String|Object|undefined} If instance is provided, a string containing the resolve URI of the link is returned.
+ * If instance is not provided, a link object is returned with details of the link.
+ * If no link with the provided relationship exists, undefined is returned.
+ * @see JSONSchema#getAttribute
+ */
+
+ JSONSchema.prototype.getLink = function (rel, instance) {
+ var schemaLinks = this.getAttribute("links", [rel, instance]);
+ if (schemaLinks && schemaLinks.length && schemaLinks[schemaLinks.length - 1]) {
+ return schemaLinks[schemaLinks.length - 1];
+ }
+ };
+
+ /**
+ * Validates the provided instance against the target schema and returns a {@link Report}.
+ *
+ * @param {JSONInstance|Any} instance The instance to validate; may be a {@link JSONInstance} or any JavaScript value
+ * @param {Report} [report] A {@link Report} to concatenate the result of the validation to. If undefined, a new {@link Report} is created.
+ * @param {JSONInstance} [parent] The parent/containing instance of the provided instance
+ * @param {JSONSchema} [parentSchema] The schema of the parent/containing instance
+ * @param {String} [name] The name of the parent object's property that references the instance
+ * @returns {Report} The result of the validation
+ */
+
+ JSONSchema.prototype.validate = function (instance, report, parent, parentSchema, name) {
+ var schemaSchema = this.getSchema(),
+ validator = schemaSchema.getValueOfProperty("validator");
+
+ if (!(instance instanceof JSONInstance)) {
+ instance = this.getEnvironment().createInstance(instance);
+ }
+
+ if (!(report instanceof Report)) {
+ report = new Report();
+ }
+
+ if (this._env._options["validateReferences"] && this._refs) {
+ if (this._refs["describedby"] && !this._env.findSchema(this._refs["describedby"])) {
+ report.addError(this, this._schema, "{describedby}", "Unknown schema reference", this._refs["describedby"]);
+ }
+ if (this._refs["full"] && !this._env.findSchema(this._refs["full"])) {
+ report.addError(this, this._schema, "{full}", "Unknown schema reference", this._refs["full"]);
+ }
+ }
+
+ if (typeof validator === "function" && !report.isValidatedBy(instance.getURI(), this.getURI())) {
+ report.registerValidation(instance.getURI(), this.getURI());
+ validator(instance, this, schemaSchema, report, parent, parentSchema, name);
+ }
+
+ return report;
+ };
+
+ /** @inner */
+ function createFullLookupWrapper(func) {
+ return /** @inner */ function fullLookupWrapper() {
+ var scope = this,
+ stack = [],
+ uri = scope._refs && scope._refs["full"],
+ schema;
+
+ while (uri) {
+ schema = scope._env.findSchema(uri);
+ if (schema) {
+ if (schema._value === scope._value) {
+ break;
+ }
+ scope = schema;
+ stack.push(uri);
+ uri = scope._refs && scope._refs["full"];
+ if (stack.indexOf(uri) > -1) {
+ break; //stop infinite loop
+ }
+ } else if (scope._env._options["enforceReferences"]) {
+ throw new InitializationError(scope, scope._schema, "{full}", "Unknown schema reference", uri);
+ } else {
+ uri = null;
+ }
+ }
+ return func.apply(scope, arguments);
+ };
+ }
+
+ /**
+ * Wraps all JSONInstance methods with a function that resolves the "full" reference.
+ *
+ * @inner
+ */
+
+ (function () {
+ var key;
+ for (key in JSONSchema.prototype) {
+ if (JSONSchema.prototype[key] !== O[key] && typeOf(JSONSchema.prototype[key]) === "function") {
+ JSONSchema.prototype[key] = createFullLookupWrapper(JSONSchema.prototype[key]);
+ }
+ }
+ }());
+
+ /**
+ * Reinitializes/re-registers/rebuilds the schema.
+ * fulldescribedbyundefined, the environment's default schema will be used. If true, the instance's schema will be itself.
+ * @param {String} [uri] The URI of the schema. If undefined, the URI will be a randomly generated UUID.
+ * @returns {JSONSchema} A new {@link JSONSchema} from the provided data
+ * @throws {InitializationError} If a schema that is not registered with the environment is referenced
+ */
+
+ Environment.prototype.createSchema = function (data, schema, uri) {
+ uri = formatURI(uri);
+
+ if (data instanceof JSONSchema && (!uri || data._uri === uri) && (!schema || data.getSchema().equals(schema))) {
+ return data;
+ }
+
+ return new JSONSchema(this, data, uri, schema);
+ };
+
+ /**
+ * Creates an empty schema.
+ *
+ * @returns {JSONSchema} The empty schema, who's schema is itself.
+ */
+
+ Environment.prototype.createEmptySchema = function () {
+ return this._schemas["urn:jsv:empty-schema#"];
+ };
+
+ /**
+ * Returns the schema registered with the provided URI.
+ *
+ * @param {String} uri The absolute URI of the required schema
+ * @returns {JSONSchema|undefined} The request schema, or undefined if not found
+ */
+
+ Environment.prototype.findSchema = function (uri) {
+ return this._schemas[formatURI(uri)];
+ };
+
+ /**
+ * Sets the specified environment option to the specified value.
+ *
+ * @param {String} name The name of the environment option to set
+ * @param {Any} value The new value of the environment option
+ */
+
+ Environment.prototype.setOption = function (name, value) {
+ this._options[name] = value;
+ };
+
+ /**
+ * Returns the specified environment option.
+ *
+ * @param {String} name The name of the environment option to set
+ * @returns {Any} The value of the environment option
+ */
+
+ Environment.prototype.getOption = function (name) {
+ return this._options[name];
+ };
+
+ /**
+ * Sets the default fragment delimiter of the environment.
+ *
+ * @deprecated Use {@link Environment#setOption} with option "defaultFragmentDelimiter"
+ * @param {String} fd The fragment delimiter character
+ */
+
+ Environment.prototype.setDefaultFragmentDelimiter = function (fd) {
+ if (typeof fd === "string" && fd.length > 0) {
+ this._options["defaultFragmentDelimiter"] = fd;
+ }
+ };
+
+ /**
+ * Returns the default fragment delimiter of the environment.
+ *
+ * @deprecated Use {@link Environment#getOption} with option "defaultFragmentDelimiter"
+ * @returns {String} The fragment delimiter character
+ */
+
+ Environment.prototype.getDefaultFragmentDelimiter = function () {
+ return this._options["defaultFragmentDelimiter"];
+ };
+
+ /**
+ * Sets the URI of the default schema for the environment.
+ *
+ * @deprecated Use {@link Environment#setOption} with option "defaultSchemaURI"
+ * @param {String} uri The default schema URI
+ */
+
+ Environment.prototype.setDefaultSchemaURI = function (uri) {
+ if (typeof uri === "string") {
+ this._options["defaultSchemaURI"] = formatURI(uri);
+ }
+ };
+
+ /**
+ * Returns the default schema of the environment.
+ *
+ * @returns {JSONSchema} The default schema
+ */
+
+ Environment.prototype.getDefaultSchema = function () {
+ return this.findSchema(this._options["defaultSchemaURI"]);
+ };
+
+ /**
+ * Validates both the provided schema and the provided instance, and returns a {@link Report}.
+ * If the schema fails to validate, the instance will not be validated.
+ *
+ * @param {JSONInstance|Any} instanceJSON The {@link JSONInstance} or JavaScript value to validate.
+ * @param {JSONSchema|Any} schemaJSON The {@link JSONSchema} or JavaScript value to use in the validation. This will also be validated againt the schema's schema.
+ * @returns {Report} The result of the validation
+ */
+
+ Environment.prototype.validate = function (instanceJSON, schemaJSON) {
+ var instance,
+ schema,
+ schemaSchema,
+ report = new Report();
+
+ try {
+ instance = this.createInstance(instanceJSON);
+ report.instance = instance;
+ } catch (e) {
+ report.addError(e.uri, e.schemaUri, e.attribute, e.message, e.details);
+ }
+
+ try {
+ schema = this.createSchema(schemaJSON);
+ report.schema = schema;
+
+ schemaSchema = schema.getSchema();
+ report.schemaSchema = schemaSchema;
+ } catch (f) {
+ report.addError(f.uri, f.schemaUri, f.attribute, f.message, f.details);
+ }
+
+ if (schemaSchema) {
+ schemaSchema.validate(schema, report);
+ }
+
+ if (report.errors.length) {
+ return report;
+ }
+
+ return schema.validate(instance, report);
+ };
+
+ /**
+ * @private
+ */
+
+ Environment.prototype._checkForInvalidInstances = function (stackSize, schemaURI) {
+ var result = [],
+ stack = [
+ [schemaURI, this._schemas[schemaURI]]
+ ],
+ counter = 0,
+ item, uri, instance, properties, key;
+
+ while (counter++ < stackSize && stack.length) {
+ item = stack.shift();
+ uri = item[0];
+ instance = item[1];
+
+ if (instance instanceof JSONSchema) {
+ if (this._schemas[instance._uri] !== instance) {
+ result.push("Instance " + uri + " does not match " + instance._uri);
+ } else {
+ //schema = instance.getSchema();
+ //stack.push([uri + "/{schema}", schema]);
+
+ properties = instance.getAttributes();
+ for (key in properties) {
+ if (properties[key] !== O[key]) {
+ stack.push([uri + "/" + escapeURIComponent(key), properties[key]]);
+ }
+ }
+ }
+ } else if (typeOf(instance) === "object") {
+ properties = instance;
+ for (key in properties) {
+ if (properties.hasOwnProperty(key)) {
+ stack.push([uri + "/" + escapeURIComponent(key), properties[key]]);
+ }
+ }
+ } else if (typeOf(instance) === "array") {
+ properties = instance;
+ for (key = 0; key < properties.length; ++key) {
+ stack.push([uri + "/" + escapeURIComponent(key), properties[key]]);
+ }
+ }
+ }
+
+ return result.length ? result : counter;
+ };
+
+ /**
+ * A globaly accessible object that provides the ability to create and manage {@link Environments},
+ * as well as providing utility methods.
+ *
+ * @namespace
+ */
+
+ JSV = {
+ _environments : {},
+ _defaultEnvironmentID : "",
+
+ /**
+ * Returns if the provide value is an instance of {@link JSONInstance}.
+ *
+ * @param o The value to test
+ * @returns {Boolean} If the provide value is an instance of {@link JSONInstance}
+ */
+
+ isJSONInstance : function (o) {
+ return o instanceof JSONInstance;
+ },
+
+ /**
+ * Returns if the provide value is an instance of {@link JSONSchema}.
+ *
+ * @param o The value to test
+ * @returns {Boolean} If the provide value is an instance of {@link JSONSchema}
+ */
+
+ isJSONSchema : function (o) {
+ return o instanceof JSONSchema;
+ },
+
+ /**
+ * Creates and returns a new {@link Environment} that is a clone of the environment registered with the provided ID.
+ * If no environment ID is provided, the default environment is cloned.
+ *
+ * @param {String} [id] The ID of the environment to clone. If undefined, the default environment ID is used.
+ * @returns {Environment} A newly cloned {@link Environment}
+ * @throws {Error} If there is no environment registered with the provided ID
+ */
+
+ createEnvironment : function (id) {
+ id = id || this._defaultEnvironmentID;
+
+ if (!this._environments[id]) {
+ throw new Error("Unknown Environment ID");
+ }
+ //else
+ return this._environments[id].clone();
+ },
+
+ Environment : Environment,
+
+ /**
+ * Registers the provided {@link Environment} with the provided ID.
+ *
+ * @param {String} id The ID of the environment
+ * @param {Environment} env The environment to register
+ */
+
+ registerEnvironment : function (id, env) {
+ id = id || (env || 0)._id;
+ if (id && !this._environments[id] && env instanceof Environment) {
+ env._id = id;
+ this._environments[id] = env;
+ }
+ },
+
+ /**
+ * Sets which registered ID is the default environment.
+ *
+ * @param {String} id The ID of the registered environment that is default
+ * @throws {Error} If there is no registered environment with the provided ID
+ */
+
+ setDefaultEnvironmentID : function (id) {
+ if (typeof id === "string") {
+ if (!this._environments[id]) {
+ throw new Error("Unknown Environment ID");
+ }
+
+ this._defaultEnvironmentID = id;
+ }
+ },
+
+ /**
+ * Returns the ID of the default environment.
+ *
+ * @returns {String} The ID of the default environment
+ */
+
+ getDefaultEnvironmentID : function () {
+ return this._defaultEnvironmentID;
+ },
+
+ //
+ // Utility Functions
+ //
+
+ /**
+ * Returns the name of the type of the provided value.
+ *
+ * @event //utility
+ * @param {Any} o The value to determine the type of
+ * @returns {String} The name of the type of the value
+ */
+ typeOf : typeOf,
+
+ /**
+ * Return a new object that inherits all of the properties of the provided object.
+ *
+ * @event //utility
+ * @param {Object} proto The prototype of the new object
+ * @returns {Object} A new object that inherits all of the properties of the provided object
+ */
+ createObject : createObject,
+
+ /**
+ * Returns a new object with each property transformed by the iterator.
+ *
+ * @event //utility
+ * @param {Object} obj The object to transform
+ * @param {Function} iterator A function that returns the new value of the provided property
+ * @param {Object} [scope] The value of this in the iterator
+ * @returns {Object} A new object with each property transformed
+ */
+ mapObject : mapObject,
+
+ /**
+ * Returns a new array with each item transformed by the iterator.
+ *
+ * @event //utility
+ * @param {Array} arr The array to transform
+ * @param {Function} iterator A function that returns the new value of the provided item
+ * @param {Object} scope The value of this in the iterator
+ * @returns {Array} A new array with each item transformed
+ */
+ mapArray : mapArray,
+
+ /**
+ * Returns a new array that only contains the items allowed by the iterator.
+ *
+ * @event //utility
+ * @param {Array} arr The array to filter
+ * @param {Function} iterator The function that returns true if the provided property should be added to the array
+ * @param {Object} scope The value of this within the iterator
+ * @returns {Array} A new array that contains the items allowed by the iterator
+ */
+ filterArray : filterArray,
+
+ /**
+ * Returns the first index in the array that the provided item is located at.
+ *
+ * @event //utility
+ * @param {Array} arr The array to search
+ * @param {Any} o The item being searched for
+ * @returns {Number} The index of the item in the array, or -1 if not found
+ */
+ searchArray : searchArray,
+
+ /**
+ * Returns an array representation of a value.
+ *
+ * This method will create a new instance of the target, and then mixin the properties of the target.
+ * If deep is true, then each property will be cloned before mixin.
+ *
Warning: This is not a generic clone function, as it will only properly clone objects and arrays.
+ * + * @event //utility + * @param {Any} o The value to clone + * @param {Boolean} [deep=false] If each property should be recursively cloned + * @returns A cloned copy of the provided value + */ + clone : clone, + + /** + * Generates a pseudo-random UUID. + * + * @event //utility + * @returns {String} A new universally unique ID + */ + randomUUID : randomUUID, + + /** + * Properly escapes a URI component for embedding into a URI string. + * + * @event //utility + * @param {String} str The URI component to escape + * @returns {String} The escaped URI component + */ + escapeURIComponent : escapeURIComponent, + + /** + * Returns a URI that is formated for JSV. Currently, this only ensures that the URI ends with a hash tag (#).
+ *
+ * @event //utility
+ * @param {String} uri The URI to format
+ * @returns {String} The URI formatted for JSV
+ */
+ formatURI : formatURI,
+
+ /**
+ * Merges two schemas/instance together.
+ *
+ * @event //utility
+ * @param {JSONSchema|Any} base The old value to merge
+ * @param {JSONSchema|Any} extra The new value to merge
+ * @param {Boolean} extension If the merge is a JSON Schema extension
+ * @return {Any} The modified base value
+ */
+
+ inherits : inherits,
+
+ /**
+ * @private
+ * @event //utility
+ */
+
+ InitializationError : InitializationError
+ };
+
+ this.JSV = JSV; //set global object
+ exports.JSV = JSV; //export to CommonJS
+
+ require("./environments"); //load default environments
+
+}());
\ No newline at end of file
diff --git a/html/RentForCamp/node_modules/JSV/lib/uri/schemes/urn.js b/html/RentForCamp/node_modules/JSV/lib/uri/schemes/urn.js
new file mode 100644
index 0000000..98ab88a
--- /dev/null
+++ b/html/RentForCamp/node_modules/JSV/lib/uri/schemes/urn.js
@@ -0,0 +1,86 @@
+(function () {
+ var URI_NS = require("../uri"),
+ URI = URI_NS.URI,
+ pctEncChar = URI_NS.pctEncChar,
+ NID$ = "(?:[0-9A-Za-z][0-9A-Za-z\\-]{1,31})",
+ PCT_ENCODED$ = "(?:\\%[0-9A-Fa-f]{2})",
+ TRANS$$ = "[0-9A-Za-z\\(\\)\\+\\,\\-\\.\\:\\=\\@\\;\\$\\_\\!\\*\\'\\/\\?\\#]",
+ NSS$ = "(?:(?:" + PCT_ENCODED$ + "|" + TRANS$$ + ")+)",
+ URN_SCHEME = new RegExp("^urn\\:(" + NID$ + ")$"),
+ URN_PATH = new RegExp("^(" + NID$ + ")\\:(" + NSS$ + ")$"),
+ URN_PARSE = /^([^\:]+)\:(.*)/,
+ URN_EXCLUDED = /[\x00-\x20\\\"\&\<\>\[\]\^\`\{\|\}\~\x7F-\xFF]/g,
+ UUID = /^[0-9A-Fa-f]{8}(?:\-[0-9A-Fa-f]{4}){3}\-[0-9A-Fa-f]{12}$/;
+
+ //RFC 2141
+ URI.SCHEMES["urn"] = {
+ parse : function (components, options) {
+ var matches = components.path.match(URN_PATH),
+ scheme, schemeHandler;
+
+ if (!matches) {
+ if (!options.tolerant) {
+ components.errors.push("URN is not strictly valid.");
+ }
+
+ matches = components.path.match(URN_PARSE);
+ }
+
+ if (matches) {
+ scheme = "urn:" + matches[1].toLowerCase();
+ schemeHandler = URI.SCHEMES[scheme];
+
+ //in order to serialize properly,
+ //every URN must have a serializer that calls the URN serializer
+ if (!schemeHandler) {
+ schemeHandler = URI.SCHEMES[scheme] = {};
+ }
+ if (!schemeHandler.serialize) {
+ schemeHandler.serialize = URI.SCHEMES["urn"].serialize;
+ }
+
+ components.scheme = scheme;
+ components.path = matches[2];
+
+ if (schemeHandler.parse) {
+ schemeHandler.parse(components, options);
+ }
+ } else {
+ components.errors.push("URN can not be parsed.");
+ }
+
+ return components;
+ },
+
+ serialize : function (components, options) {
+ var scheme = components.scheme || options.scheme,
+ matches;
+
+ if (scheme && scheme !== "urn") {
+ var matches = scheme.match(URN_SCHEME);
+
+ if (!matches) {
+ matches = ["urn:" + scheme, scheme];
+ }
+
+ components.scheme = "urn";
+ components.path = matches[1] + ":" + (components.path ? components.path.replace(URN_EXCLUDED, pctEncChar) : "");
+ }
+
+ return components;
+ }
+ };
+
+ //RFC 4122
+ URI.SCHEMES["urn:uuid"] = {
+ serialize : function (components, options) {
+ //ensure UUID is valid
+ if (!options.tolerant && (!components.path || !components.path.match(UUID))) {
+ //invalid UUIDs can not have this scheme
+ components.scheme = undefined;
+ }
+
+ return URI.SCHEMES["urn"].serialize(components, options);
+ }
+ };
+}());
\ No newline at end of file
diff --git a/html/RentForCamp/node_modules/JSV/lib/uri/uri.js b/html/RentForCamp/node_modules/JSV/lib/uri/uri.js
new file mode 100644
index 0000000..37ea1f3
--- /dev/null
+++ b/html/RentForCamp/node_modules/JSV/lib/uri/uri.js
@@ -0,0 +1,710 @@
+/**
+ * URI.js
+ *
+ * @fileoverview An RFC 3986 compliant, scheme extendable URI parsing/validating/resolving library for JavaScript.
+ * @author Gary Court
+ * @version 1.3
+ * @see http://github.com/garycourt/uri-js
+ * @license URI.js v1.3 (c) 2010 Gary Court. License: http://github.com/garycourt/uri-js
+ */
+
+/**
+ * Copyright 2010 Gary Court. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are
+ * permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY GARY COURT ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GARY COURT OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation are those of the
+ * authors and should not be interpreted as representing official policies, either expressed
+ * or implied, of Gary Court.
+ */
+
+/*jslint white: true, sub: true, onevar: true, undef: true, eqeqeq: true, newcap: true, immed: true, indent: 4 */
+/*global exports:true, require:true */
+
+if (typeof exports === "undefined") {
+ exports = {};
+}
+if (typeof require !== "function") {
+ require = function (id) {
+ return exports;
+ };
+}
+(function () {
+ var
+ /**
+ * @param {...string} sets
+ * @return {string}
+ */
+ mergeSet = function (sets) {
+ var set = arguments[0],
+ x = 1,
+ nextSet = arguments[x];
+
+ while (nextSet) {
+ set = set.slice(0, -1) + nextSet.slice(1);
+ nextSet = arguments[++x];
+ }
+
+ return set;
+ },
+
+ /**
+ * @param {string} str
+ * @return {string}
+ */
+ subexp = function (str) {
+ return "(?:" + str + ")";
+ },
+
+ ALPHA$$ = "[A-Za-z]",
+ CR$ = "[\\x0D]",
+ DIGIT$$ = "[0-9]",
+ DQUOTE$$ = "[\\x22]",
+ HEXDIG$$ = mergeSet(DIGIT$$, "[A-Fa-f]"), //case-insensitive
+ LF$$ = "[\\x0A]",
+ SP$$ = "[\\x20]",
+ PCT_ENCODED$ = subexp("%" + HEXDIG$$ + HEXDIG$$),
+ GEN_DELIMS$$ = "[\\:\\/\\?\\#\\[\\]\\@]",
+ SUB_DELIMS$$ = "[\\!\\$\\&\\'\\(\\)\\*\\+\\,\\;\\=]",
+ RESERVED$$ = mergeSet(GEN_DELIMS$$, SUB_DELIMS$$),
+ UNRESERVED$$ = mergeSet(ALPHA$$, DIGIT$$, "[\\-\\.\\_\\~]"),
+ SCHEME$ = subexp(ALPHA$$ + mergeSet(ALPHA$$, DIGIT$$, "[\\+\\-\\.]") + "*"),
+ USERINFO$ = subexp(subexp(PCT_ENCODED$ + "|" + mergeSet(UNRESERVED$$, SUB_DELIMS$$, "[\\:]")) + "*"),
+ DEC_OCTET$ = subexp(subexp("25[0-5]") + "|" + subexp("2[0-4]" + DIGIT$$) + "|" + subexp("1" + DIGIT$$ + DIGIT$$) + "|" + subexp("[1-9]" + DIGIT$$) + "|" + DIGIT$$),
+ IPV4ADDRESS$ = subexp(DEC_OCTET$ + "\\." + DEC_OCTET$ + "\\." + DEC_OCTET$ + "\\." + DEC_OCTET$),
+ H16$ = subexp(HEXDIG$$ + "{1,4}"),
+ LS32$ = subexp(subexp(H16$ + "\\:" + H16$) + "|" + IPV4ADDRESS$),
+ IPV6ADDRESS$ = subexp(mergeSet(UNRESERVED$$, SUB_DELIMS$$, "[\\:]") + "+"), //FIXME
+ IPVFUTURE$ = subexp("v" + HEXDIG$$ + "+\\." + mergeSet(UNRESERVED$$, SUB_DELIMS$$, "[\\:]") + "+"),
+ IP_LITERAL$ = subexp("\\[" + subexp(IPV6ADDRESS$ + "|" + IPVFUTURE$) + "\\]"),
+ REG_NAME$ = subexp(subexp(PCT_ENCODED$ + "|" + mergeSet(UNRESERVED$$, SUB_DELIMS$$)) + "*"),
+ HOST$ = subexp(IP_LITERAL$ + "|" + IPV4ADDRESS$ + "|" + REG_NAME$),
+ PORT$ = subexp(DIGIT$$ + "*"),
+ AUTHORITY$ = subexp(subexp(USERINFO$ + "@") + "?" + HOST$ + subexp("\\:" + PORT$) + "?"),
+ PCHAR$ = subexp(PCT_ENCODED$ + "|" + mergeSet(UNRESERVED$$, SUB_DELIMS$$, "[\\:\\@]")),
+ SEGMENT$ = subexp(PCHAR$ + "*"),
+ SEGMENT_NZ$ = subexp(PCHAR$ + "+"),
+ SEGMENT_NZ_NC$ = subexp(subexp(PCT_ENCODED$ + "|" + mergeSet(UNRESERVED$$, SUB_DELIMS$$, "[\\@]")) + "+"),
+ PATH_ABEMPTY$ = subexp(subexp("\\/" + SEGMENT$) + "*"),
+ PATH_ABSOLUTE$ = subexp("\\/" + subexp(SEGMENT_NZ$ + PATH_ABEMPTY$) + "?"), //simplified
+ PATH_NOSCHEME$ = subexp(SEGMENT_NZ_NC$ + PATH_ABEMPTY$), //simplified
+ PATH_ROOTLESS$ = subexp(SEGMENT_NZ$ + PATH_ABEMPTY$), //simplified
+ PATH_EMPTY$ = subexp(""), //simplified
+ PATH$ = subexp(PATH_ABEMPTY$ + "|" + PATH_ABSOLUTE$ + "|" + PATH_NOSCHEME$ + "|" + PATH_ROOTLESS$ + "|" + PATH_EMPTY$),
+ QUERY$ = subexp(subexp(PCHAR$ + "|[\\/\\?]") + "*"),
+ FRAGMENT$ = subexp(subexp(PCHAR$ + "|[\\/\\?]") + "*"),
+ HIER_PART$ = subexp(subexp("\\/\\/" + AUTHORITY$ + PATH_ABEMPTY$) + "|" + PATH_ABSOLUTE$ + "|" + PATH_ROOTLESS$ + "|" + PATH_EMPTY$),
+ URI$ = subexp(SCHEME$ + "\\:" + HIER_PART$ + subexp("\\?" + QUERY$) + "?" + subexp("\\#" + FRAGMENT$) + "?"),
+ RELATIVE_PART$ = subexp(subexp("\\/\\/" + AUTHORITY$ + PATH_ABEMPTY$) + "|" + PATH_ABSOLUTE$ + "|" + PATH_NOSCHEME$ + "|" + PATH_EMPTY$),
+ RELATIVE_REF$ = subexp(RELATIVE_PART$ + subexp("\\?" + QUERY$) + "?" + subexp("\\#" + FRAGMENT$) + "?"),
+ URI_REFERENCE$ = subexp(URI$ + "|" + RELATIVE_REF$),
+ ABSOLUTE_URI$ = subexp(SCHEME$ + "\\:" + HIER_PART$ + subexp("\\?" + QUERY$) + "?"),
+
+ URI_REF = new RegExp("^" + subexp("(" + URI$ + ")|(" + RELATIVE_REF$ + ")") + "$"),
+ GENERIC_REF = new RegExp("^(" + SCHEME$ + ")\\:" + subexp(subexp("\\/\\/(" + subexp("(" + USERINFO$ + ")@") + "?(" + HOST$ + ")" + subexp("\\:(" + PORT$ + ")") + "?)") + "?(" + PATH_ABEMPTY$ + "|" + PATH_ABSOLUTE$ + "|" + PATH_ROOTLESS$ + "|" + PATH_EMPTY$ + ")") + subexp("\\?(" + QUERY$ + ")") + "?" + subexp("\\#(" + FRAGMENT$ + ")") + "?$"),
+ RELATIVE_REF = new RegExp("^(){0}" + subexp(subexp("\\/\\/(" + subexp("(" + USERINFO$ + ")@") + "?(" + HOST$ + ")" + subexp("\\:(" + PORT$ + ")") + "?)") + "?(" + PATH_ABEMPTY$ + "|" + PATH_ABSOLUTE$ + "|" + PATH_NOSCHEME$ + "|" + PATH_EMPTY$ + ")") + subexp("\\?(" + QUERY$ + ")") + "?" + subexp("\\#(" + FRAGMENT$ + ")") + "?$"),
+ ABSOLUTE_REF = new RegExp("^(" + SCHEME$ + ")\\:" + subexp(subexp("\\/\\/(" + subexp("(" + USERINFO$ + ")@") + "?(" + HOST$ + ")" + subexp("\\:(" + PORT$ + ")") + "?)") + "?(" + PATH_ABEMPTY$ + "|" + PATH_ABSOLUTE$ + "|" + PATH_ROOTLESS$ + "|" + PATH_EMPTY$ + ")") + subexp("\\?(" + QUERY$ + ")") + "?$"),
+ SAMEDOC_REF = new RegExp("^" + subexp("\\#(" + FRAGMENT$ + ")") + "?$"),
+ AUTHORITY = new RegExp("^" + subexp("(" + USERINFO$ + ")@") + "?(" + HOST$ + ")" + subexp("\\:(" + PORT$ + ")") + "?$"),
+
+ NOT_SCHEME = new RegExp(mergeSet("[^]", ALPHA$$, DIGIT$$, "[\\+\\-\\.]"), "g"),
+ NOT_USERINFO = new RegExp(mergeSet("[^\\%\\:]", UNRESERVED$$, SUB_DELIMS$$), "g"),
+ NOT_HOST = new RegExp(mergeSet("[^\\%]", UNRESERVED$$, SUB_DELIMS$$), "g"),
+ NOT_PATH = new RegExp(mergeSet("[^\\%\\/\\:\\@]", UNRESERVED$$, SUB_DELIMS$$), "g"),
+ NOT_PATH_NOSCHEME = new RegExp(mergeSet("[^\\%\\/\\@]", UNRESERVED$$, SUB_DELIMS$$), "g"),
+ NOT_QUERY = new RegExp(mergeSet("[^\\%]", UNRESERVED$$, SUB_DELIMS$$, "[\\:\\@\\/\\?]"), "g"),
+ NOT_FRAGMENT = NOT_QUERY,
+ ESCAPE = new RegExp(mergeSet("[^]", UNRESERVED$$, SUB_DELIMS$$), "g"),
+ UNRESERVED = new RegExp(UNRESERVED$$, "g"),
+ OTHER_CHARS = new RegExp(mergeSet("[^\\%]", UNRESERVED$$, RESERVED$$), "g"),
+ PCT_ENCODEDS = new RegExp(PCT_ENCODED$ + "+", "g"),
+ URI_PARSE = /^(?:([^:\/?#]+):)?(?:\/\/((?:([^\/?#@]*)@)?([^\/?#:]*)(?:\:(\d*))?))?([^?#]*)(?:\?([^#]*))?(?:#(.*))?/i,
+ RDS1 = /^\.\.?\//,
+ RDS2 = /^\/\.(\/|$)/,
+ RDS3 = /^\/\.\.(\/|$)/,
+ RDS4 = /^\.\.?$/,
+ RDS5 = /^\/?.*?(?=\/|$)/,
+ NO_MATCH_IS_UNDEFINED = ("").match(/(){0}/)[1] === undefined,
+
+ /**
+ * @param {string} chr
+ * @return {string}
+ */
+ pctEncChar = function (chr) {
+ var c = chr.charCodeAt(0);
+
+ if (c < 128) {
+ return "%" + c.toString(16).toUpperCase();
+ }
+ else if ((c > 127) && (c < 2048)) {
+ return "%" + ((c >> 6) | 192).toString(16).toUpperCase() + "%" + ((c & 63) | 128).toString(16).toUpperCase();
+ }
+ else {
+ return "%" + ((c >> 12) | 224).toString(16).toUpperCase() + "%" + (((c >> 6) & 63) | 128).toString(16).toUpperCase() + "%" + ((c & 63) | 128).toString(16).toUpperCase();
+ }
+ },
+
+ /**
+ * @param {string} str
+ * @return {string}
+ */
+ pctDecUnreserved = function (str) {
+ var newStr = "",
+ i = 0,
+ c, s;
+
+ while (i < str.length) {
+ c = parseInt(str.substr(i + 1, 2), 16);
+
+ if (c < 128) {
+ s = String.fromCharCode(c);
+ if (s.match(UNRESERVED)) {
+ newStr += s;
+ } else {
+ newStr += str.substr(i, 3);
+ }
+ i += 3;
+ }
+ else if ((c > 191) && (c < 224)) {
+ newStr += str.substr(i, 6);
+ i += 6;
+ }
+ else {
+ newStr += str.substr(i, 9);
+ i += 9;
+ }
+ }
+
+ return newStr;
+ },
+
+ /**
+ * @param {string} str
+ * @return {string}
+ */
+ pctDecChars = function (str) {
+ var newStr = "",
+ i = 0,
+ c, c2, c3;
+
+ while (i < str.length) {
+ c = parseInt(str.substr(i + 1, 2), 16);
+
+ if (c < 128) {
+ newStr += String.fromCharCode(c);
+ i += 3;
+ }
+ else if ((c > 191) && (c < 224)) {
+ c2 = parseInt(str.substr(i + 4, 2), 16);
+ newStr += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
+ i += 6;
+ }
+ else {
+ c2 = parseInt(str.substr(i + 4, 2), 16);
+ c3 = parseInt(str.substr(i + 7, 2), 16);
+ newStr += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
+ i += 9;
+ }
+ }
+
+ return newStr;
+ },
+
+ /**
+ * @return {string}
+ */
+ typeOf = function (o) {
+ return o === undefined ? "undefined" : (o === null ? "null" : Object.prototype.toString.call(o).split(" ").pop().split("]").shift().toLowerCase());
+ },
+
+ /**
+ * @constructor
+ * @implements URIComponents
+ */
+ Components = function () {
+ this.errors = [];
+ },
+
+ /** @namespace */
+ URI = exports;
+
+ /**
+ * Components
+ */
+
+ Components.prototype = {
+ /**
+ * @type String
+ */
+
+ scheme : undefined,
+
+ /**
+ * @type String
+ */
+
+ authority : undefined,
+
+ /**
+ * @type String
+ */
+
+ userinfo : undefined,
+
+ /**
+ * @type String
+ */
+
+ host : undefined,
+
+ /**
+ * @type number
+ */
+
+ port : undefined,
+
+ /**
+ * @type string
+ */
+
+ path : undefined,
+
+ /**
+ * @type string
+ */
+
+ query : undefined,
+
+ /**
+ * @type string
+ */
+
+ fragment : undefined,
+
+ /**
+ * @type string
+ * @values "uri", "absolute", "relative", "same-document"
+ */
+
+ reference : undefined,
+
+ /**
+ * @type Array
+ */
+
+ errors : undefined
+ };
+
+ /**
+ * URI
+ */
+
+ /**
+ * @namespace
+ */
+
+ URI.SCHEMES = {};
+
+ /**
+ * @param {string} uriString
+ * @param {Options} [options]
+ * @returns {URIComponents}
+ */
+
+ URI.parse = function (uriString, options) {
+ var matches,
+ components = new Components(),
+ schemeHandler;
+
+ uriString = uriString ? uriString.toString() : "";
+ options = options || {};
+
+ if (options.reference === "suffix") {
+ uriString = (options.scheme ? options.scheme + ":" : "") + "//" + uriString;
+ }
+
+ matches = uriString.match(URI_REF);
+
+ if (matches) {
+ if (matches[1]) {
+ //generic URI
+ matches = uriString.match(GENERIC_REF);
+ } else {
+ //relative URI
+ matches = uriString.match(RELATIVE_REF);
+ }
+ }
+
+ if (!matches) {
+ if (!options.tolerant) {
+ components.errors.push("URI is not strictly valid.");
+ }
+ matches = uriString.match(URI_PARSE);
+ }
+
+ if (matches) {
+ if (NO_MATCH_IS_UNDEFINED) {
+ //store each component
+ components.scheme = matches[1];
+ components.authority = matches[2];
+ components.userinfo = matches[3];
+ components.host = matches[4];
+ components.port = parseInt(matches[5], 10);
+ components.path = matches[6] || "";
+ components.query = matches[7];
+ components.fragment = matches[8];
+
+ //fix port number
+ if (isNaN(components.port)) {
+ components.port = matches[5];
+ }
+ } else { //IE FIX for improper RegExp matching
+ //store each component
+ components.scheme = matches[1] || undefined;
+ components.authority = (uriString.indexOf("//") !== -1 ? matches[2] : undefined);
+ components.userinfo = (uriString.indexOf("@") !== -1 ? matches[3] : undefined);
+ components.host = (uriString.indexOf("//") !== -1 ? matches[4] : undefined);
+ components.port = parseInt(matches[5], 10);
+ components.path = matches[6] || "";
+ components.query = (uriString.indexOf("?") !== -1 ? matches[7] : undefined);
+ components.fragment = (uriString.indexOf("#") !== -1 ? matches[8] : undefined);
+
+ //fix port number
+ if (isNaN(components.port)) {
+ components.port = (uriString.match(/\/\/.*\:(?:\/|\?|\#|$)/) ? matches[4] : undefined);
+ }
+ }
+
+ //determine reference type
+ if (!components.scheme && !components.authority && !components.path && !components.query) {
+ components.reference = "same-document";
+ } else if (!components.scheme) {
+ components.reference = "relative";
+ } else if (!components.fragment) {
+ components.reference = "absolute";
+ } else {
+ components.reference = "uri";
+ }
+
+ //check for reference errors
+ if (options.reference && options.reference !== "suffix" && options.reference !== components.reference) {
+ components.errors.push("URI is not a " + options.reference + " reference.");
+ }
+
+ //check if a handler for the scheme exists
+ schemeHandler = URI.SCHEMES[(components.scheme || options.scheme || "").toLowerCase()];
+ if (schemeHandler && schemeHandler.parse) {
+ //perform extra parsing
+ schemeHandler.parse(components, options);
+ }
+ } else {
+ components.errors.push("URI can not be parsed.");
+ }
+
+ return components;
+ };
+
+ /**
+ * @private
+ * @param {URIComponents} components
+ * @returns {string|undefined}
+ */
+
+ URI._recomposeAuthority = function (components) {
+ var uriTokens = [];
+
+ if (components.userinfo !== undefined || components.host !== undefined || typeof components.port === "number") {
+ if (components.userinfo !== undefined) {
+ uriTokens.push(components.userinfo.toString().replace(NOT_USERINFO, pctEncChar));
+ uriTokens.push("@");
+ }
+ if (components.host !== undefined) {
+ uriTokens.push(components.host.toString().toLowerCase().replace(NOT_HOST, pctEncChar));
+ }
+ if (typeof components.port === "number") {
+ uriTokens.push(":");
+ uriTokens.push(components.port.toString(10));
+ }
+ }
+
+ return uriTokens.length ? uriTokens.join("") : undefined;
+ };
+
+ /**
+ * @param {string} input
+ * @returns {string}
+ */
+
+ URI.removeDotSegments = function (input) {
+ var output = [], s;
+
+ while (input.length) {
+ if (input.match(RDS1)) {
+ input = input.replace(RDS1, "");
+ } else if (input.match(RDS2)) {
+ input = input.replace(RDS2, "/");
+ } else if (input.match(RDS3)) {
+ input = input.replace(RDS3, "/");
+ output.pop();
+ } else if (input === "." || input === "..") {
+ input = "";
+ } else {
+ s = input.match(RDS5)[0];
+ input = input.slice(s.length);
+ output.push(s);
+ }
+ }
+
+ return output.join("");
+ };
+
+ /**
+ * @param {URIComponents} components
+ * @param {Options} [options]
+ * @returns {string}
+ */
+
+ URI.serialize = function (components, options) {
+ var uriTokens = [],
+ schemeHandler,
+ s;
+ options = options || {};
+
+ //check if a handler for the scheme exists
+ schemeHandler = URI.SCHEMES[components.scheme || options.scheme];
+ if (schemeHandler && schemeHandler.serialize) {
+ //perform extra serialization
+ schemeHandler.serialize(components, options);
+ }
+
+ if (options.reference !== "suffix" && components.scheme) {
+ uriTokens.push(components.scheme.toString().toLowerCase().replace(NOT_SCHEME, ""));
+ uriTokens.push(":");
+ }
+
+ components.authority = URI._recomposeAuthority(components);
+ if (components.authority !== undefined) {
+ if (options.reference !== "suffix") {
+ uriTokens.push("//");
+ }
+
+ uriTokens.push(components.authority);
+
+ if (components.path && components.path.charAt(0) !== "/") {
+ uriTokens.push("/");
+ }
+ }
+
+ if (components.path) {
+ s = URI.removeDotSegments(components.path.toString().replace(/%2E/ig, "."));
+
+ if (components.scheme) {
+ s = s.replace(NOT_PATH, pctEncChar);
+ } else {
+ s = s.replace(NOT_PATH_NOSCHEME, pctEncChar);
+ }
+
+ if (components.authority === undefined) {
+ s = s.replace(/^\/\//, "/%2F"); //don't allow the path to start with "//"
+ }
+ uriTokens.push(s);
+ }
+
+ if (components.query) {
+ uriTokens.push("?");
+ uriTokens.push(components.query.toString().replace(NOT_QUERY, pctEncChar));
+ }
+
+ if (components.fragment) {
+ uriTokens.push("#");
+ uriTokens.push(components.fragment.toString().replace(NOT_FRAGMENT, pctEncChar));
+ }
+
+ return uriTokens
+ .join('') //merge tokens into a string
+ .replace(PCT_ENCODEDS, pctDecUnreserved) //undecode unreserved characters
+ //.replace(OTHER_CHARS, pctEncChar) //replace non-URI characters
+ .replace(/%[0-9A-Fa-f]{2}/g, function (str) { //uppercase percent encoded characters
+ return str.toUpperCase();
+ })
+ ;
+ };
+
+ /**
+ * @param {URIComponents} base
+ * @param {URIComponents} relative
+ * @param {Options} [options]
+ * @param {boolean} [skipNormalization]
+ * @returns {URIComponents}
+ */
+
+ URI.resolveComponents = function (base, relative, options, skipNormalization) {
+ var target = new Components();
+
+ if (!skipNormalization) {
+ base = URI.parse(URI.serialize(base, options), options); //normalize base components
+ relative = URI.parse(URI.serialize(relative, options), options); //normalize relative components
+ }
+ options = options || {};
+
+ if (!options.tolerant && relative.scheme) {
+ target.scheme = relative.scheme;
+ target.authority = relative.authority;
+ target.userinfo = relative.userinfo;
+ target.host = relative.host;
+ target.port = relative.port;
+ target.path = URI.removeDotSegments(relative.path);
+ target.query = relative.query;
+ } else {
+ if (relative.authority !== undefined) {
+ target.authority = relative.authority;
+ target.userinfo = relative.userinfo;
+ target.host = relative.host;
+ target.port = relative.port;
+ target.path = URI.removeDotSegments(relative.path);
+ target.query = relative.query;
+ } else {
+ if (!relative.path) {
+ target.path = base.path;
+ if (relative.query !== undefined) {
+ target.query = relative.query;
+ } else {
+ target.query = base.query;
+ }
+ } else {
+ if (relative.path.charAt(0) === "/") {
+ target.path = URI.removeDotSegments(relative.path);
+ } else {
+ if (base.authority !== undefined && !base.path) {
+ target.path = "/" + relative.path;
+ } else if (!base.path) {
+ target.path = relative.path;
+ } else {
+ target.path = base.path.slice(0, base.path.lastIndexOf("/") + 1) + relative.path;
+ }
+ target.path = URI.removeDotSegments(target.path);
+ }
+ target.query = relative.query;
+ }
+ target.authority = base.authority;
+ target.userinfo = base.userinfo;
+ target.host = base.host;
+ target.port = base.port;
+ }
+ target.scheme = base.scheme;
+ }
+
+ target.fragment = relative.fragment;
+
+ return target;
+ };
+
+ /**
+ * @param {string} baseURI
+ * @param {string} relativeURI
+ * @param {Options} [options]
+ * @returns {string}
+ */
+
+ URI.resolve = function (baseURI, relativeURI, options) {
+ return URI.serialize(URI.resolveComponents(URI.parse(baseURI, options), URI.parse(relativeURI, options), options, true), options);
+ };
+
+ /**
+ * @param {string|URIComponents} uri
+ * @param {Options} options
+ * @returns {string|URIComponents}
+ */
+
+ URI.normalize = function (uri, options) {
+ if (typeof uri === "string") {
+ return URI.serialize(URI.parse(uri, options), options);
+ } else if (typeOf(uri) === "object") {
+ return URI.parse(URI.serialize(uri, options), options);
+ }
+
+ return uri;
+ };
+
+ /**
+ * @param {string|URIComponents} uriA
+ * @param {string|URIComponents} uriB
+ * @param {Options} options
+ */
+
+ URI.equal = function (uriA, uriB, options) {
+ if (typeof uriA === "string") {
+ uriA = URI.serialize(URI.parse(uriA, options), options);
+ } else if (typeOf(uriA) === "object") {
+ uriA = URI.serialize(uriA, options);
+ }
+
+ if (typeof uriB === "string") {
+ uriB = URI.serialize(URI.parse(uriB, options), options);
+ } else if (typeOf(uriB) === "object") {
+ uriB = URI.serialize(uriB, options);
+ }
+
+ return uriA === uriB;
+ };
+
+ /**
+ * @param {string} str
+ * @returns {string}
+ */
+
+ URI.escapeComponent = function (str) {
+ return str && str.toString().replace(ESCAPE, pctEncChar);
+ };
+
+ /**
+ * @param {string} str
+ * @returns {string}
+ */
+
+ URI.unescapeComponent = function (str) {
+ return str && str.toString().replace(PCT_ENCODEDS, pctDecChars);
+ };
+
+ //export API
+ exports.pctEncChar = pctEncChar;
+ exports.pctDecChars = pctDecChars;
+ exports.Components = Components;
+ exports.URI = URI;
+
+ //name-safe export API
+ exports["pctEncChar"] = pctEncChar;
+ exports["pctDecChars"] = pctDecChars;
+ exports["Components"] = Components;
+ exports["URI"] = {
+ "SCHEMES" : URI.SCHEMES,
+ "parse" : URI.parse,
+ "removeDotSegments" : URI.removeDotSegments,
+ "serialize" : URI.serialize,
+ "resolveComponents" : URI.resolveComponents,
+ "resolve" : URI.resolve,
+ "normalize" : URI.normalize,
+ "equal" : URI.equal,
+ "escapeComponent" : URI.escapeComponent,
+ "unescapeComponent" : URI.unescapeComponent
+ };
+
+}());
\ No newline at end of file
diff --git a/html/RentForCamp/node_modules/JSV/package.json b/html/RentForCamp/node_modules/JSV/package.json
new file mode 100644
index 0000000..841abf6
--- /dev/null
+++ b/html/RentForCamp/node_modules/JSV/package.json
@@ -0,0 +1,98 @@
+{
+ "_args": [
+ [
+ {
+ "raw": "JSV@^4.0.x",
+ "scope": null,
+ "escapedName": "JSV",
+ "name": "JSV",
+ "rawSpec": "^4.0.x",
+ "spec": ">=4.0.0 <5.0.0",
+ "type": "range"
+ },
+ "/Users/gerrit/Documents/dev/nodejs/rentfor.camp/html/RentForCamp/node_modules/jsonlint"
+ ]
+ ],
+ "_defaultsLoaded": true,
+ "_engineSupported": true,
+ "_from": "JSV@>=4.0.0 <5.0.0",
+ "_id": "JSV@4.0.2",
+ "_inCache": true,
+ "_location": "/JSV",
+ "_nodeVersion": "v0.6.6",
+ "_npmUser": {
+ "name": "garycourt",
+ "email": "gary.court@gmail.com"
+ },
+ "_npmVersion": "1.1.0-beta-4",
+ "_phantomChildren": {},
+ "_requested": {
+ "raw": "JSV@^4.0.x",
+ "scope": null,
+ "escapedName": "JSV",
+ "name": "JSV",
+ "rawSpec": "^4.0.x",
+ "spec": ">=4.0.0 <5.0.0",
+ "type": "range"
+ },
+ "_requiredBy": [
+ "/jsonlint"
+ ],
+ "_resolved": "https://registry.npmjs.org/JSV/-/JSV-4.0.2.tgz",
+ "_shasum": "d077f6825571f82132f9dffaed587b4029feff57",
+ "_shrinkwrap": null,
+ "_spec": "JSV@^4.0.x",
+ "_where": "/Users/gerrit/Documents/dev/nodejs/rentfor.camp/html/RentForCamp/node_modules/jsonlint",
+ "author": {
+ "name": "Gary Court",
+ "email": "gary.court@gmail.com"
+ },
+ "bugs": {
+ "url": "http://github.com/garycourt/JSV/issues",
+ "email": "gary.court@gmail.com"
+ },
+ "dependencies": {},
+ "description": "A JavaScript implementation of a extendable, fully compliant JSON Schema validator.",
+ "devDependencies": {},
+ "directories": {},
+ "dist": {
+ "shasum": "d077f6825571f82132f9dffaed587b4029feff57",
+ "tarball": "https://registry.npmjs.org/JSV/-/JSV-4.0.2.tgz"
+ },
+ "engines": {
+ "node": "*"
+ },
+ "homepage": "http://github.com/garycourt/JSV",
+ "keywords": [
+ "json",
+ "schema",
+ "validator"
+ ],
+ "licenses": [
+ {
+ "type": "FreeBSD",
+ "url": "http://github.com/garycourt/JSV/raw/master/jsv.js"
+ }
+ ],
+ "main": "lib/jsv.js",
+ "maintainers": [
+ {
+ "name": "garycourt",
+ "email": "gary.court@gmail.com"
+ }
+ ],
+ "name": "JSV",
+ "optionalDependencies": {},
+ "readme": "JSV: JSON Schema Validator\r\n==========================\r\n\r\nJSV is a JavaScript implementation of a extendable, fully compliant JSON Schema validator with the following features:\r\n\r\n*\tThe fastest extendable JSON validator available!\r\n*\tComplete implementation of all current JSON Schema draft revisions.\r\n*\tSupports creating individual environments (sandboxes) that validate using a particular schema specification.\r\n*\tProvides an intuitive API for creating new validating schema attributes, or whole new custom schema schemas.\r\n*\tSupports `self`, `full` and `describedby` hyper links.\r\n*\tValidates itself, and is bootstrapped from the JSON Schema schemas.\r\n*\tIncludes over 1100 unit tests for testing all parts of the specifications.\r\n*\tWorks in all ECMAScript 3 environments, including all web browsers and Node.js.\r\n*\tLicensed under the FreeBSD License, a very open license.\r\n\r\n## It's a what?\r\n\r\n**JSON** (an acronym for **JavaScript Object Notation**) is a lightweight data-interchange format. It is easy for humans to read and write. It is easy for machines to parse and generate. It is based on a subset of JavaScript/ECMA-262 3rd Edition. JSON is a text format that is completely language independent but uses conventions that are familiar to programmers of the C-family of languages. (C, C++, C#, Java, JavaScript, Perl, Python, ...) These properties make JSON an ideal data-interchange language. \\[[json.org](http://json.org)\\]\r\n\r\n**JSON Schema** is a JSON media type for defining the structure of JSON data. JSON Schema provides a contract for what JSON data is required for a given application and how to interact with it. JSON Schema is intended to define validation, documentation, hyperlink navigation, and interaction control of JSON data. \\[[draft-zyp-json-schema-02](http://tools.ietf.org/html/draft-zyp-json-schema-02)\\]\r\n\r\nA **JSON validator** is a program that takes JSON data and, with a provided schema, will ensure that the provided JSON is structured in the way defined by the schema. This ensures that if validation has passed, the JSON instance is guaranteed to be in the expected format. It will also provide an explanation on why a particular instance failed validation.\r\n\r\n## Example\r\n\r\nHere's an example on how to validate some JSON with JSV:\r\n\r\n\tvar JSV = require(\"./jsv\").JSV;\r\n\tvar json = {};\r\n\tvar schema = {\"type\" : \"object\"};\r\n\tvar env = JSV.createEnvironment();\r\n\tvar report = env.validate(json, schema);\r\n\t\r\n\tif (report.errors.length === 0) {\r\n\t\t//JSON is valid against the schema\r\n\t}\r\n\r\nAnother example; for the following test:\r\n\r\n\tenv.validate({ a : 1 }, { type : 'object', properties : { a : { type : 'string' }} });\r\n\r\nThe generated report would look like:\r\n\r\n\t{\r\n\t\terrors : [\r\n\t\t\t{\r\n\t\t\t\tmessage : \"Instance is not a required type\",\r\n\t\t\t\turi : \"urn:uuid:74b843b5-3aa4-44e9-b7bc-f555936fa823#/a\",\r\n\t\t\t\tschemaUri : \"urn:uuid:837fdefe-3bd4-4993-9a20-38a6a0624d5a#/properties/a\",\r\n\t\t\t\tattribute : \"type\",\r\n\t\t\t\tdetails : [\"string\"]\r\n\t\t\t}\r\n\t\t],\r\n\t\tvalidated : {\r\n\t\t\t\"urn:uuid:74b843b5-3aa4-44e9-b7bc-f555936fa823#\" : [\"urn:uuid:837fdefe-3bd4-4993-9a20-38a6a0624d5a#\"],\r\n\t\t\t\"urn:uuid:74b843b5-3aa4-44e9-b7bc-f555936fa823#/a\" : [\"urn:uuid:837fdefe-3bd4-4993-9a20-38a6a0624d5a#/properties/a\"],\r\n\t\t\t//...\r\n\t\t},\r\n\t\tinstance : [JSONInstance object],\r\n\t\tschema : [JSONSchema object],\r\n\t\tschemaSchema : [JSONSchema object]\r\n\t}\r\n\r\n## Environments & JSON Schema support\r\n\r\nThere is no one way to validate JSON, just like there is no one way to validate XML. Even the JSON Schema specification has gone through several revisions which are not 100% backwards compatible with each other. To solve the issue of using numerous schemas already written to older specifications, JSV provides customizable environments to validate your JSON within. \r\n\r\nWhen creating an environment, you can optionally specify how you want that environment to behave. For example, this allows you to specify which version of the JSON Schema you would like the environment to behave like. JSV already provides the following environments:\r\n\r\n*\t`json-schema-draft-03`\r\n\r\n\tA complete implementation of the [third revision](http://tools.ietf.org/html/draft-zyp-json-schema-03) of the JSON Schema specification. This is the same as the second revision, except:\r\n\t\r\n\t*\t\"optional\" has been replaced by \"required\"\r\n\t*\t\"requires\" has been replaced by \"dependencies\"\r\n\t*\t\"minimumCanEqual\"/\"maximumCanEqual\" has been replaced by \"exclusiveMinimum\"/\"exclusiveMaximum\"\r\n\t*\t\"self\"/\"full\"/\"describedby\" links have been moved to the core schema, and are provided by \"id\"/\"$ref\"/\"$schema\"\r\n\t*\tAdds the attributes \"patternSchema\" and \"additionalItems\"\r\n\t*\tDeprecates the attributes \"root\" and \"alternate\"\r\n\t*\tSchemas are now versioned under the URIs \"http://json-schema.org/draft-XX/\", where XX is the draft number\r\n\t\r\n\tIn addition to this, all schemas from the previous versions of the JSON Schema draft are included in this environment, and are backwards compatible (where possible) with it's previous version.\r\n\tThis backwards compatibility can be disabled with the environment option `strict` is set to `true`.\r\n\t\r\n\tThis is currently the default environment.\r\n\r\n*\t`json-schema-draft-02`\r\n\r\n\tA complete implementation of the [second revision](http://tools.ietf.org/html/draft-zyp-json-schema-02) of the JSON Schema specification. This is the same as the first revision, except adds:\r\n\t\r\n\t*\t\"targetSchema\" attribute\r\n\t*\tslash-delimited fragment identifiers, which is now the default behavior\r\n\t\r\n*\t`json-schema-draft-01`\r\n\r\n\tA complete implementation of the [first revision](http://tools.ietf.org/html/draft-zyp-json-schema-01) of the JSON Schema specification, which is exactly the same as the [original draft](http://tools.ietf.org/html/draft-zyp-json-schema-00).\r\n\t\r\n\tUsers with JSON Schemas written for JSV < v2.1 should use this environment for it's dot-delimited fragment identifiers.\r\n\r\nEnvironments can also be customized and registered for multiple reuse. (See the section on *Extending Environments* below)\r\n\r\n## Validation API\r\n\r\nThe following methods are used to validate JSON data:\r\n\r\n### JSV.createEnvironment(*environmentID?*) *->* *<Environment>*\r\n\r\n*\t*environmentID* *<String>* *(optional)* The ID of the environment to clone a new Environment from\r\n\r\nCreates an new environment that is a copy of the Environment registered with the provided `environmentID`. If no ID is provided, the latest registered JSON Schema is used as the template.\r\n\r\nSee the above section on *Environments* for the default available Environment IDs.\r\n\r\n### *<Environment>*.validate(*json*, *schema*) *->* *<Report>*\r\n\r\n*\t*json* *<Any|JSONInstance>* The JSON data to validate\r\n*\t*schema* *<Object|JSONInstance|JSONSchema>* The schema to validate the JSON with\r\n\r\nValidates both the schema and the JSON, and returns a report of the validation.\r\n\r\n### *<Report>*.errors *<Array>*\r\n\r\nAn array of error objects from the validation process; each object represents a restriction check that failed. If the array is empty, the validation passed.\r\n\r\nThe error objects have the following schema:\r\n\r\n\t{\r\n\t\t\"type\" : \"object\",\r\n\t\t\"properties\" : {\r\n\t\t\t\"message\" : {\r\n\t\t\t\t\"description\" : \"A user-friendly error message about what failed to validate.\",\r\n\t\t\t\t\"type\" : \"string\"\r\n\t\t\t},\r\n\t\t\t\"uri\" : {\r\n\t\t\t\t\"description\" : \"URI of the instance that failed to validate.\",\r\n\t\t\t\t\"type\" : \"string\",\r\n\t\t\t\t\"format\" : \"uri\"\r\n\t\t\t},\r\n\t\t\t\"schemaUri\" : {\r\n\t\t\t\t\"description\" : \"URI of the schema instance that reported the error.\",\r\n\t\t\t\t\"type\" : \"string\",\r\n\t\t\t\t\"format\" : \"uri\"\r\n\t\t\t},\r\n\t\t\t\"attribute\" : {\r\n\t\t\t\t\"description\" : \"The attribute of the schema instance that failed to validate.\",\r\n\t\t\t\t\"type\" : \"string\"\r\n\t\t\t},\r\n\t\t\t\"details\" : {\r\n\t\t\t\t\"description\" : \"The value of the schema attribute that failed to validate.\",\r\n\t\t\t\t\"type\" : \"any\"\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n## API Documentation\r\n\r\nThere are many more APIs available for JSV, too many to detail here. The complete API and documentation can be found in the `docs` directory.\r\n\r\n## Extending Environments\r\n\r\nJSV provides an API for extending available schemas, adding new attributes and validation to currently existing schemas, and creating whole new Environments with unique behaviors. \r\nIn fact, in the [eat-your-own-dog-food](http://en.wikipedia.org/wiki/Eating_your_own_dog_food) approach, all the default JSON Schema environments available are implemented using this API. \r\nDetails and instruction on this feature will be provided at a later date.\r\n\r\n## Installation\r\n\r\nThe preferred method of installation is to download the latest copy from GitHub:\r\n\r\n\tgit clone git://github.com/garycourt/JSV.git\r\n\r\nIf you are using JSV within Node.js, you can quickly install it using:\r\n\r\n\tnpm install JSV\r\n\r\nThen you can reference it within your application using:\r\n\r\n\tvar JSV = require(\"JSV\").JSV;\r\n\r\n## Unit Tests\r\n\r\nOpen `tests/index.html` and `tests/index3.html` in your web browser to run the unit tests.\r\n\r\nCurrently, the unit tests can not be run in Node.js.\r\n\r\n## License\r\n\r\n\tCopyright 2010 Gary Court. All rights reserved.\r\n\t\r\n\tRedistribution and use in source and binary forms, with or without modification, are\r\n\tpermitted provided that the following conditions are met:\r\n\t\r\n\t 1. Redistributions of source code must retain the above copyright notice, this list of\r\n\t conditions and the following disclaimer.\r\n\t\r\n\t 2. Redistributions in binary form must reproduce the above copyright notice, this list\r\n\t of conditions and the following disclaimer in the documentation and/or other materials\r\n\t provided with the distribution.\r\n\t\r\n\tTHIS SOFTWARE IS PROVIDED BY GARY COURT ``AS IS'' AND ANY EXPRESS OR IMPLIED\r\n\tWARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND\r\n\tFITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GARY COURT OR\r\n\tCONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\r\n\tCONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR\r\n\tSERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON\r\n\tANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING\r\n\tNEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF\r\n\tADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r\n\t\r\n\tThe views and conclusions contained in the software and documentation are those of the\r\n\tauthors and should not be interpreted as representing official policies, either expressed\r\n\tor implied, of Gary Court or the JSON Schema specification.",
+ "repositories": [
+ {
+ "type": "git",
+ "url": "git://github.com/garycourt/JSV.git"
+ }
+ ],
+ "repository": {
+ "type": "git",
+ "url": "git://github.com/garycourt/JSV.git"
+ },
+ "version": "4.0.2"
+}
diff --git a/html/RentForCamp/node_modules/JSV/schemas/json-schema-draft-01/empty-schema.json b/html/RentForCamp/node_modules/JSV/schemas/json-schema-draft-01/empty-schema.json
new file mode 100644
index 0000000..9e26dfe
--- /dev/null
+++ b/html/RentForCamp/node_modules/JSV/schemas/json-schema-draft-01/empty-schema.json
@@ -0,0 +1 @@
+{}
\ No newline at end of file
diff --git a/html/RentForCamp/node_modules/JSV/schemas/json-schema-draft-01/hyper-schema.json b/html/RentForCamp/node_modules/JSV/schemas/json-schema-draft-01/hyper-schema.json
new file mode 100644
index 0000000..b34e60d
--- /dev/null
+++ b/html/RentForCamp/node_modules/JSV/schemas/json-schema-draft-01/hyper-schema.json
@@ -0,0 +1,68 @@
+{
+ "$schema" : "http://json-schema.org/hyper-schema#",
+ "id" : "http://json-schema.org/hyper-schema#",
+
+ "properties" : {
+ "links" : {
+ "type" : "array",
+ "items" : {"$ref" : "http://json-schema.org/links#"},
+ "optional" : true
+ },
+
+ "fragmentResolution" : {
+ "type" : "string",
+ "optional" : true,
+ "default" : "dot-delimited"
+ },
+
+ "root" : {
+ "type" : "boolean",
+ "optional" : true,
+ "default" : false
+ },
+
+ "readonly" : {
+ "type" : "boolean",
+ "optional" : true,
+ "default" : false
+ },
+
+ "pathStart" : {
+ "type" : "string",
+ "optional" : true,
+ "format" : "uri"
+ },
+
+ "mediaType" : {
+ "type" : "string",
+ "optional" : true,
+ "format" : "media-type"
+ },
+
+ "alternate" : {
+ "type" : "array",
+ "items" : {"$ref" : "#"},
+ "optional" : true
+ }
+ },
+
+ "links" : [
+ {
+ "href" : "{$ref}",
+ "rel" : "full"
+ },
+
+ {
+ "href" : "{$schema}",
+ "rel" : "describedby"
+ },
+
+ {
+ "href" : "{id}",
+ "rel" : "self"
+ }
+ ],
+
+ "fragmentResolution" : "dot-delimited",
+ "extends" : {"$ref" : "http://json-schema.org/schema#"}
+}
\ No newline at end of file
diff --git a/html/RentForCamp/node_modules/JSV/schemas/json-schema-draft-01/json-ref.json b/html/RentForCamp/node_modules/JSV/schemas/json-schema-draft-01/json-ref.json
new file mode 100644
index 0000000..35e16a8
--- /dev/null
+++ b/html/RentForCamp/node_modules/JSV/schemas/json-schema-draft-01/json-ref.json
@@ -0,0 +1,26 @@
+{
+ "$schema" : "http://json-schema.org/hyper-schema#",
+ "id" : "http://json-schema.org/json-ref#",
+
+ "items" : {"$ref" : "#"},
+ "additionalProperties" : {"$ref" : "#"},
+
+ "links" : [
+ {
+ "href" : "{$ref}",
+ "rel" : "full"
+ },
+
+ {
+ "href" : "{$schema}",
+ "rel" : "describedby"
+ },
+
+ {
+ "href" : "{id}",
+ "rel" : "self"
+ }
+ ],
+
+ "fragmentResolution" : "dot-delimited"
+}
\ No newline at end of file
diff --git a/html/RentForCamp/node_modules/JSV/schemas/json-schema-draft-01/links.json b/html/RentForCamp/node_modules/JSV/schemas/json-schema-draft-01/links.json
new file mode 100644
index 0000000..f27bd77
--- /dev/null
+++ b/html/RentForCamp/node_modules/JSV/schemas/json-schema-draft-01/links.json
@@ -0,0 +1,33 @@
+{
+ "$schema" : "http://json-schema.org/hyper-schema#",
+ "id" : "http://json-schema.org/links#",
+ "type" : "object",
+
+ "properties" : {
+ "href" : {
+ "type" : "string"
+ },
+
+ "rel" : {
+ "type" : "string"
+ },
+
+ "method" : {
+ "type" : "string",
+ "default" : "GET",
+ "optional" : true
+ },
+
+ "enctype" : {
+ "type" : "string",
+ "requires" : "method",
+ "optional" : true
+ },
+
+ "properties" : {
+ "type" : "object",
+ "additionalProperties" : {"$ref" : "http://json-schema.org/hyper-schema#"},
+ "optional" : true
+ }
+ }
+}
\ No newline at end of file
diff --git a/html/RentForCamp/node_modules/JSV/schemas/json-schema-draft-01/schema.json b/html/RentForCamp/node_modules/JSV/schemas/json-schema-draft-01/schema.json
new file mode 100644
index 0000000..30375b4
--- /dev/null
+++ b/html/RentForCamp/node_modules/JSV/schemas/json-schema-draft-01/schema.json
@@ -0,0 +1,155 @@
+{
+ "$schema" : "http://json-schema.org/hyper-schema#",
+ "id" : "http://json-schema.org/schema#",
+ "type" : "object",
+
+ "properties" : {
+ "type" : {
+ "type" : ["string", "array"],
+ "items" : {
+ "type" : ["string", {"$ref" : "#"}]
+ },
+ "optional" : true,
+ "default" : "any"
+ },
+
+ "properties" : {
+ "type" : "object",
+ "additionalProperties" : {"$ref" : "#"},
+ "optional" : true,
+ "default" : {}
+ },
+
+ "items" : {
+ "type" : [{"$ref" : "#"}, "array"],
+ "items" : {"$ref" : "#"},
+ "optional" : true,
+ "default" : {}
+ },
+
+ "optional" : {
+ "type" : "boolean",
+ "optional" : true,
+ "default" : false
+ },
+
+ "additionalProperties" : {
+ "type" : [{"$ref" : "#"}, "boolean"],
+ "optional" : true,
+ "default" : {}
+ },
+
+ "requires" : {
+ "type" : ["string", {"$ref" : "#"}],
+ "optional" : true
+ },
+
+ "minimum" : {
+ "type" : "number",
+ "optional" : true
+ },
+
+ "maximum" : {
+ "type" : "number",
+ "optional" : true
+ },
+
+ "minimumCanEqual" : {
+ "type" : "boolean",
+ "optional" : true,
+ "requires" : "minimum",
+ "default" : true
+ },
+
+ "maximumCanEqual" : {
+ "type" : "boolean",
+ "optional" : true,
+ "requires" : "maximum",
+ "default" : true
+ },
+
+ "minItems" : {
+ "type" : "integer",
+ "optional" : true,
+ "minimum" : 0,
+ "default" : 0
+ },
+
+ "maxItems" : {
+ "type" : "integer",
+ "optional" : true,
+ "minimum" : 0
+ },
+
+ "pattern" : {
+ "type" : "string",
+ "optional" : true,
+ "format" : "regex"
+ },
+
+ "minLength" : {
+ "type" : "integer",
+ "optional" : true,
+ "minimum" : 0,
+ "default" : 0
+ },
+
+ "maxLength" : {
+ "type" : "integer",
+ "optional" : true
+ },
+
+ "enum" : {
+ "type" : "array",
+ "optional" : true,
+ "minItems" : 1
+ },
+
+ "title" : {
+ "type" : "string",
+ "optional" : true
+ },
+
+ "description" : {
+ "type" : "string",
+ "optional" : true
+ },
+
+ "format" : {
+ "type" : "string",
+ "optional" : true
+ },
+
+ "contentEncoding" : {
+ "type" : "string",
+ "optional" : true
+ },
+
+ "default" : {
+ "type" : "any",
+ "optional" : true
+ },
+
+ "maxDecimal" : {
+ "type" : "integer",
+ "optional" : true,
+ "minimum" : 0
+ },
+
+ "disallow" : {
+ "type" : ["string", "array"],
+ "items" : {"type" : "string"},
+ "optional" : true
+ },
+
+ "extends" : {
+ "type" : [{"$ref" : "#"}, "array"],
+ "items" : {"$ref" : "#"},
+ "optional" : true,
+ "default" : {}
+ }
+ },
+
+ "optional" : true,
+ "default" : {}
+}
\ No newline at end of file
diff --git a/html/RentForCamp/node_modules/JSV/schemas/json-schema-draft-02/empty-schema.json b/html/RentForCamp/node_modules/JSV/schemas/json-schema-draft-02/empty-schema.json
new file mode 100644
index 0000000..9e26dfe
--- /dev/null
+++ b/html/RentForCamp/node_modules/JSV/schemas/json-schema-draft-02/empty-schema.json
@@ -0,0 +1 @@
+{}
\ No newline at end of file
diff --git a/html/RentForCamp/node_modules/JSV/schemas/json-schema-draft-02/hyper-schema.json b/html/RentForCamp/node_modules/JSV/schemas/json-schema-draft-02/hyper-schema.json
new file mode 100644
index 0000000..3806247
--- /dev/null
+++ b/html/RentForCamp/node_modules/JSV/schemas/json-schema-draft-02/hyper-schema.json
@@ -0,0 +1,68 @@
+{
+ "$schema" : "http://json-schema.org/hyper-schema#",
+ "id" : "http://json-schema.org/hyper-schema#",
+
+ "properties" : {
+ "links" : {
+ "type" : "array",
+ "items" : {"$ref" : "http://json-schema.org/links#"},
+ "optional" : true
+ },
+
+ "fragmentResolution" : {
+ "type" : "string",
+ "optional" : true,
+ "default" : "slash-delimited"
+ },
+
+ "root" : {
+ "type" : "boolean",
+ "optional" : true,
+ "default" : false
+ },
+
+ "readonly" : {
+ "type" : "boolean",
+ "optional" : true,
+ "default" : false
+ },
+
+ "pathStart" : {
+ "type" : "string",
+ "optional" : true,
+ "format" : "uri"
+ },
+
+ "mediaType" : {
+ "type" : "string",
+ "optional" : true,
+ "format" : "media-type"
+ },
+
+ "alternate" : {
+ "type" : "array",
+ "items" : {"$ref" : "#"},
+ "optional" : true
+ }
+ },
+
+ "links" : [
+ {
+ "href" : "{$ref}",
+ "rel" : "full"
+ },
+
+ {
+ "href" : "{$schema}",
+ "rel" : "describedby"
+ },
+
+ {
+ "href" : "{id}",
+ "rel" : "self"
+ }
+ ],
+
+ "fragmentResolution" : "slash-delimited",
+ "extends" : {"$ref" : "http://json-schema.org/schema#"}
+}
\ No newline at end of file
diff --git a/html/RentForCamp/node_modules/JSV/schemas/json-schema-draft-02/json-ref.json b/html/RentForCamp/node_modules/JSV/schemas/json-schema-draft-02/json-ref.json
new file mode 100644
index 0000000..35e16a8
--- /dev/null
+++ b/html/RentForCamp/node_modules/JSV/schemas/json-schema-draft-02/json-ref.json
@@ -0,0 +1,26 @@
+{
+ "$schema" : "http://json-schema.org/hyper-schema#",
+ "id" : "http://json-schema.org/json-ref#",
+
+ "items" : {"$ref" : "#"},
+ "additionalProperties" : {"$ref" : "#"},
+
+ "links" : [
+ {
+ "href" : "{$ref}",
+ "rel" : "full"
+ },
+
+ {
+ "href" : "{$schema}",
+ "rel" : "describedby"
+ },
+
+ {
+ "href" : "{id}",
+ "rel" : "self"
+ }
+ ],
+
+ "fragmentResolution" : "dot-delimited"
+}
\ No newline at end of file
diff --git a/html/RentForCamp/node_modules/JSV/schemas/json-schema-draft-02/links.json b/html/RentForCamp/node_modules/JSV/schemas/json-schema-draft-02/links.json
new file mode 100644
index 0000000..1111280
--- /dev/null
+++ b/html/RentForCamp/node_modules/JSV/schemas/json-schema-draft-02/links.json
@@ -0,0 +1,35 @@
+{
+ "$schema" : "http://json-schema.org/hyper-schema#",
+ "id" : "http://json-schema.org/links#",
+ "type" : "object",
+
+ "properties" : {
+ "href" : {
+ "type" : "string"
+ },
+
+ "rel" : {
+ "type" : "string"
+ },
+
+ "targetSchema" : {"$ref" : "http://json-schema.org/hyper-schema#"},
+
+ "method" : {
+ "type" : "string",
+ "default" : "GET",
+ "optional" : true
+ },
+
+ "enctype" : {
+ "type" : "string",
+ "requires" : "method",
+ "optional" : true
+ },
+
+ "properties" : {
+ "type" : "object",
+ "additionalProperties" : {"$ref" : "http://json-schema.org/hyper-schema#"},
+ "optional" : true
+ }
+ }
+}
\ No newline at end of file
diff --git a/html/RentForCamp/node_modules/JSV/schemas/json-schema-draft-02/schema.json b/html/RentForCamp/node_modules/JSV/schemas/json-schema-draft-02/schema.json
new file mode 100644
index 0000000..1562493
--- /dev/null
+++ b/html/RentForCamp/node_modules/JSV/schemas/json-schema-draft-02/schema.json
@@ -0,0 +1,165 @@
+{
+ "$schema" : "http://json-schema.org/hyper-schema#",
+ "id" : "http://json-schema.org/schema#",
+ "type" : "object",
+
+ "properties" : {
+ "type" : {
+ "type" : ["string", "array"],
+ "items" : {
+ "type" : ["string", {"$ref" : "#"}]
+ },
+ "optional" : true,
+ "uniqueItems" : true,
+ "default" : "any"
+ },
+
+ "properties" : {
+ "type" : "object",
+ "additionalProperties" : {"$ref" : "#"},
+ "optional" : true,
+ "default" : {}
+ },
+
+ "items" : {
+ "type" : [{"$ref" : "#"}, "array"],
+ "items" : {"$ref" : "#"},
+ "optional" : true,
+ "default" : {}
+ },
+
+ "optional" : {
+ "type" : "boolean",
+ "optional" : true,
+ "default" : false
+ },
+
+ "additionalProperties" : {
+ "type" : [{"$ref" : "#"}, "boolean"],
+ "optional" : true,
+ "default" : {}
+ },
+
+ "requires" : {
+ "type" : ["string", {"$ref" : "#"}],
+ "optional" : true
+ },
+
+ "minimum" : {
+ "type" : "number",
+ "optional" : true
+ },
+
+ "maximum" : {
+ "type" : "number",
+ "optional" : true
+ },
+
+ "minimumCanEqual" : {
+ "type" : "boolean",
+ "optional" : true,
+ "requires" : "minimum",
+ "default" : true
+ },
+
+ "maximumCanEqual" : {
+ "type" : "boolean",
+ "optional" : true,
+ "requires" : "maximum",
+ "default" : true
+ },
+
+ "minItems" : {
+ "type" : "integer",
+ "optional" : true,
+ "minimum" : 0,
+ "default" : 0
+ },
+
+ "maxItems" : {
+ "type" : "integer",
+ "optional" : true,
+ "minimum" : 0
+ },
+
+ "uniqueItems" : {
+ "type" : "boolean",
+ "optional" : true,
+ "default" : false
+ },
+
+ "pattern" : {
+ "type" : "string",
+ "optional" : true,
+ "format" : "regex"
+ },
+
+ "minLength" : {
+ "type" : "integer",
+ "optional" : true,
+ "minimum" : 0,
+ "default" : 0
+ },
+
+ "maxLength" : {
+ "type" : "integer",
+ "optional" : true
+ },
+
+ "enum" : {
+ "type" : "array",
+ "optional" : true,
+ "minItems" : 1,
+ "uniqueItems" : true
+ },
+
+ "title" : {
+ "type" : "string",
+ "optional" : true
+ },
+
+ "description" : {
+ "type" : "string",
+ "optional" : true
+ },
+
+ "format" : {
+ "type" : "string",
+ "optional" : true
+ },
+
+ "contentEncoding" : {
+ "type" : "string",
+ "optional" : true
+ },
+
+ "default" : {
+ "type" : "any",
+ "optional" : true
+ },
+
+ "divisibleBy" : {
+ "type" : "number",
+ "minimum" : 0,
+ "minimumCanEqual" : false,
+ "optional" : true
+ },
+
+ "disallow" : {
+ "type" : ["string", "array"],
+ "items" : {"type" : "string"},
+ "optional" : true,
+ "uniqueItems" : true
+ },
+
+ "extends" : {
+ "type" : [{"$ref" : "#"}, "array"],
+ "items" : {"$ref" : "#"},
+ "optional" : true,
+ "default" : {}
+ }
+ },
+
+ "optional" : true,
+ "default" : {}
+}
\ No newline at end of file
diff --git a/html/RentForCamp/node_modules/JSV/schemas/json-schema-draft-03/hyper-schema.json b/html/RentForCamp/node_modules/JSV/schemas/json-schema-draft-03/hyper-schema.json
new file mode 100644
index 0000000..140963a
--- /dev/null
+++ b/html/RentForCamp/node_modules/JSV/schemas/json-schema-draft-03/hyper-schema.json
@@ -0,0 +1,60 @@
+{
+ "$schema" : "http://json-schema.org/draft-03/hyper-schema#",
+ "extends" : {"$ref" : "http://json-schema.org/draft-03/schema#"},
+ "id" : "http://json-schema.org/draft-03/hyper-schema#",
+
+ "properties" : {
+ "links" : {
+ "type" : "array",
+ "items" : {"$ref" : "http://json-schema.org/draft-03/links#"}
+ },
+
+ "fragmentResolution" : {
+ "type" : "string",
+ "default" : "slash-delimited"
+ },
+
+ "root" : {
+ "type" : "boolean",
+ "default" : false
+ },
+
+ "readonly" : {
+ "type" : "boolean",
+ "default" : false
+ },
+
+ "contentEncoding" : {
+ "type" : "string"
+ },
+
+ "pathStart" : {
+ "type" : "string",
+ "format" : "uri"
+ },
+
+ "mediaType" : {
+ "type" : "string",
+ "format" : "media-type"
+ }
+ },
+
+ "links" : [
+ {
+ "href" : "{id}",
+ "rel" : "self"
+ },
+
+ {
+ "href" : "{$ref}",
+ "rel" : "full"
+ },
+
+ {
+ "href" : "{$schema}",
+ "rel" : "describedby"
+ }
+ ],
+
+ "fragmentResolution" : "slash-delimited"
+}
\ No newline at end of file
diff --git a/html/RentForCamp/node_modules/JSV/schemas/json-schema-draft-03/json-ref.json b/html/RentForCamp/node_modules/JSV/schemas/json-schema-draft-03/json-ref.json
new file mode 100644
index 0000000..66e08f2
--- /dev/null
+++ b/html/RentForCamp/node_modules/JSV/schemas/json-schema-draft-03/json-ref.json
@@ -0,0 +1,26 @@
+{
+ "$schema" : "http://json-schema.org/draft-03/hyper-schema#",
+ "id" : "http://json-schema.org/draft-03/json-ref#",
+
+ "additionalItems" : {"$ref" : "#"},
+ "additionalProperties" : {"$ref" : "#"},
+
+ "links" : [
+ {
+ "href" : "{id}",
+ "rel" : "self"
+ },
+
+ {
+ "href" : "{$ref}",
+ "rel" : "full"
+ },
+
+ {
+ "href" : "{$schema}",
+ "rel" : "describedby"
+ }
+ ],
+
+ "fragmentResolution" : "dot-delimited"
+}
\ No newline at end of file
diff --git a/html/RentForCamp/node_modules/JSV/schemas/json-schema-draft-03/links.json b/html/RentForCamp/node_modules/JSV/schemas/json-schema-draft-03/links.json
new file mode 100644
index 0000000..704cc88
--- /dev/null
+++ b/html/RentForCamp/node_modules/JSV/schemas/json-schema-draft-03/links.json
@@ -0,0 +1,32 @@
+{
+ "$schema" : "http://json-schema.org/draft-03/hyper-schema#",
+ "id" : "http://json-schema.org/draft-03/links#",
+ "type" : "object",
+
+ "properties" : {
+ "href" : {
+ "type" : "string",
+ "required" : true,
+ "format" : "link-description-object-template"
+ },
+
+ "rel" : {
+ "type" : "string",
+ "required" : true
+ },
+
+ "targetSchema" : {"$ref" : "http://json-schema.org/draft-03/hyper-schema#"},
+
+ "method" : {
+ "type" : "string",
+ "default" : "GET"
+ },
+
+ "enctype" : {
+ "type" : "string",
+ "requires" : "method"
+ },
+
+ "schema" : {"$ref" : "http://json-schema.org/draft-03/hyper-schema#"}
+ }
+}
\ No newline at end of file
diff --git a/html/RentForCamp/node_modules/JSV/schemas/json-schema-draft-03/schema.json b/html/RentForCamp/node_modules/JSV/schemas/json-schema-draft-03/schema.json
new file mode 100644
index 0000000..e451d56
--- /dev/null
+++ b/html/RentForCamp/node_modules/JSV/schemas/json-schema-draft-03/schema.json
@@ -0,0 +1,173 @@
+{
+ "$schema" : "http://json-schema.org/draft-03/schema#",
+ "id" : "http://json-schema.org/draft-03/schema#",
+ "type" : "object",
+
+ "properties" : {
+ "type" : {
+ "type" : ["string", "array"],
+ "items" : {
+ "type" : ["string", {"$ref" : "#"}]
+ },
+ "uniqueItems" : true,
+ "default" : "any"
+ },
+
+ "properties" : {
+ "type" : "object",
+ "additionalProperties" : {"$ref" : "#"},
+ "default" : {}
+ },
+
+ "patternProperties" : {
+ "type" : "object",
+ "additionalProperties" : {"$ref" : "#"},
+ "default" : {}
+ },
+
+ "additionalProperties" : {
+ "type" : [{"$ref" : "#"}, "boolean"],
+ "default" : {}
+ },
+
+ "items" : {
+ "type" : [{"$ref" : "#"}, "array"],
+ "items" : {"$ref" : "#"},
+ "default" : {}
+ },
+
+ "additionalItems" : {
+ "type" : [{"$ref" : "#"}, "boolean"],
+ "default" : {}
+ },
+
+ "required" : {
+ "type" : "boolean",
+ "default" : false
+ },
+
+ "dependencies" : {
+ "type" : "object",
+ "additionalProperties" : {
+ "type" : ["string", "array", {"$ref" : "#"}],
+ "items" : {
+ "type" : "string"
+ }
+ },
+ "default" : {}
+ },
+
+ "minimum" : {
+ "type" : "number"
+ },
+
+ "maximum" : {
+ "type" : "number"
+ },
+
+ "exclusiveMinimum" : {
+ "type" : "boolean",
+ "default" : false
+ },
+
+ "exclusiveMaximum" : {
+ "type" : "boolean",
+ "default" : false
+ },
+
+ "minItems" : {
+ "type" : "integer",
+ "minimum" : 0,
+ "default" : 0
+ },
+
+ "maxItems" : {
+ "type" : "integer",
+ "minimum" : 0
+ },
+
+ "uniqueItems" : {
+ "type" : "boolean",
+ "default" : false
+ },
+
+ "pattern" : {
+ "type" : "string",
+ "format" : "regex"
+ },
+
+ "minLength" : {
+ "type" : "integer",
+ "minimum" : 0,
+ "default" : 0
+ },
+
+ "maxLength" : {
+ "type" : "integer"
+ },
+
+ "enum" : {
+ "type" : "array",
+ "minItems" : 1,
+ "uniqueItems" : true
+ },
+
+ "default" : {
+ "type" : "any"
+ },
+
+ "title" : {
+ "type" : "string"
+ },
+
+ "description" : {
+ "type" : "string"
+ },
+
+ "format" : {
+ "type" : "string"
+ },
+
+ "divisibleBy" : {
+ "type" : "number",
+ "minimum" : 0,
+ "exclusiveMinimum" : true
+ },
+
+ "disallow" : {
+ "type" : ["string", "array"],
+ "items" : {
+ "type" : ["string", {"$ref" : "#"}]
+ },
+ "uniqueItems" : true
+ },
+
+ "extends" : {
+ "type" : [{"$ref" : "#"}, "array"],
+ "items" : {"$ref" : "#"},
+ "default" : {}
+ },
+
+ "id" : {
+ "type" : "string",
+ "format" : "uri"
+ },
+
+ "$ref" : {
+ "type" : "string",
+ "format" : "uri"
+ },
+
+ "$schema" : {
+ "type" : "string",
+ "format" : "uri"
+ }
+ },
+
+ "dependencies" : {
+ "exclusiveMinimum" : "minimum",
+ "exclusiveMaximum" : "maximum"
+ },
+
+ "default" : {}
+}
\ No newline at end of file
diff --git a/html/RentForCamp/node_modules/JSV/tests/index.html b/html/RentForCamp/node_modules/JSV/tests/index.html
new file mode 100644
index 0000000..d216473
--- /dev/null
+++ b/html/RentForCamp/node_modules/JSV/tests/index.html
@@ -0,0 +1,21 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+ A JavaScript library for arbitrary-precision arithmetic.
+ + ++ See the README on GitHub for a + quick-start introduction. +
+
+ In all examples below, var and semicolons are not shown, and if a commented-out
+ value is in quotes it means toString has been called on the preceding expression.
+
BigNumber(value [, base]) ⇒ BigNumber
+ value0, ±Infinity and
+ NaN.
+ 15 significant digits are
+ considered invalid (if ERRORS is true) as calling
+ toString or valueOf on
+ such numbers may not result in the intended value.
+ console.log( 823456789123456.3 ); // 823456789123456.2+
'0xff', are valid, as are
+ string values with the octal and binary prefixs '0o' and '0b'.
+ String values in octal literal form without the prefix will be interpreted as
+ decimals, e.g. '011' is interpreted as 11, not 9.
+ 10 to 36, lower and/or upper case letters can be
+ used to represent values from 10 to 35.
+ a-z represents values from 10 to
+ 35, A-Z from 36 to 61, and
+ $ and _ represent 62 and 63 respectively
+ (this can be changed by editing the ALPHABET variable near the top of the
+ source file).
+ base2 to 64 inclusive
+ value.base is omitted, or is null or undefined, base
+ 10 is assumed.
+ Returns a new instance of a BigNumber object.
+
+ If a base is specified, the value is rounded according to
+ the current DECIMAL_PLACES and
+ ROUNDING_MODE configuration.
+
+ See Errors for the treatment of an invalid value or
+ base.
+
+x = new BigNumber(9) // '9'
+y = new BigNumber(x) // '9'
+
+// 'new' is optional if ERRORS is false
+BigNumber(435.345) // '435.345'
+
+new BigNumber('5032485723458348569331745.33434346346912144534543')
+new BigNumber('4.321e+4') // '43210'
+new BigNumber('-735.0918e-430') // '-7.350918e-428'
+new BigNumber(Infinity) // 'Infinity'
+new BigNumber(NaN) // 'NaN'
+new BigNumber('.5') // '0.5'
+new BigNumber('+2') // '2'
+new BigNumber(-10110100.1, 2) // '-180.5'
+new BigNumber(-0b10110100.1) // '-180.5'
+new BigNumber('123412421.234324', 5) // '607236.557696'
+new BigNumber('ff.8', 16) // '255.5'
+new BigNumber('0xff.8') // '255.5'
+
+ The following throws 'not a base 2 number' if
+ ERRORS is true, otherwise it returns a BigNumber with value
+ NaN.
+
new BigNumber(9, 2)+
+ The following throws 'number type has more than 15 significant digits' if
+ ERRORS is true, otherwise it returns a BigNumber with value
+ 96517860459076820.
+
new BigNumber(96517860459076817.4395)+
+ The following throws 'not a number' if ERRORS
+ is true, otherwise it returns a BigNumber with value NaN.
+
new BigNumber('blurgh')
+ + A value is only rounded by the constructor if a base is specified. +
+BigNumber.config({ DECIMAL_PLACES: 5 })
+new BigNumber(1.23456789) // '1.23456789'
+new BigNumber(1.23456789, 10) // '1.23457'
+
+
+
+ The static methods of a BigNumber constructor.
+ + + + +.another([obj]) ⇒ BigNumber constructor
+ obj: object
+ Returns a new independent BigNumber constructor with configuration as described by
+ obj (see config), or with the default
+ configuration if obj is null or undefined.
+
BigNumber.config({ DECIMAL_PLACES: 5 })
+BN = BigNumber.another({ DECIMAL_PLACES: 9 })
+
+x = new BigNumber(1)
+y = new BN(1)
+
+x.div(3) // 0.33333
+y.div(3) // 0.333333333
+
+// BN = BigNumber.another({ DECIMAL_PLACES: 9 }) is equivalent to:
+BN = BigNumber.another()
+BN.config({ DECIMAL_PLACES: 9 })
+
+
+
+ set([obj]) ⇒ object
+ obj: object: an object that contains some or all of the following
+ properties.
+
Configures the settings for this particular BigNumber constructor.
+Note: the configuration can also be supplied as an argument list, see below.
+DECIMAL_PLACES0 to 1e+9 inclusive20
+ BigNumber.config({ DECIMAL_PLACES: 5 })
+BigNumber.set({ DECIMAL_PLACES: 5 }) // equivalent
+BigNumber.config(5) // equivalent
+ ROUNDING_MODE0 to 8 inclusive4 (ROUND_HALF_UP)
+ round,
+ toExponential,
+ toFixed,
+ toFormat and
+ toPrecision.
+ BigNumber.config({ ROUNDING_MODE: 0 })
+BigNumber.config(null, BigNumber.ROUND_UP) // equivalent
+ EXPONENTIAL_AT0 to 1e+9 inclusive, or
+ -1e+9 to 0 inclusive, integer
+ 0 to 1e+9 inclusive ][-7, 20]
+ toString returns exponential notation.
+ [-7, 20].
+ BigNumber.config({ EXPONENTIAL_AT: 2 })
+new BigNumber(12.3) // '12.3' e is only 1
+new BigNumber(123) // '1.23e+2'
+new BigNumber(0.123) // '0.123' e is only -1
+new BigNumber(0.0123) // '1.23e-2'
+
+BigNumber.config({ EXPONENTIAL_AT: [-7, 20] })
+new BigNumber(123456789) // '123456789' e is only 8
+new BigNumber(0.000000123) // '1.23e-7'
+
+// Almost never return exponential notation:
+BigNumber.config({ EXPONENTIAL_AT: 1e+9 })
+
+// Always return exponential notation:
+BigNumber.config({ EXPONENTIAL_AT: 0 })
+ EXPONENTIAL_AT, the toFixed method
+ will always return a value in normal notation and the toExponential method
+ will always return a value in exponential form.
+ toString with a base argument, e.g. toString(10), will
+ also always return normal notation.
+ RANGE1 to 1e+9 inclusive, or
+ -1e+9 to -1 inclusive, integer
+ 1 to 1e+9 inclusive ][-1e+9, 1e+9]
+ Infinity and underflow to
+ zero occurs.
+ Infinity and those with a
+ negative exponent of greater magnitude become zero.
+ Infinity, use [-324, 308].
+ BigNumber.config({ RANGE: 500 })
+BigNumber.config().RANGE // [ -500, 500 ]
+new BigNumber('9.999e499') // '9.999e+499'
+new BigNumber('1e500') // 'Infinity'
+new BigNumber('1e-499') // '1e-499'
+new BigNumber('1e-500') // '0'
+
+BigNumber.config({ RANGE: [-3, 4] })
+new BigNumber(99999) // '99999' e is only 4
+new BigNumber(100000) // 'Infinity' e is 5
+new BigNumber(0.001) // '0.01' e is only -3
+new BigNumber(0.0001) // '0' e is -4
+ 9.999...e+1000000000.1e-1000000000.
+ ERRORStrue, false, 0 or
+ 1.true
+ ERRORS is false, no errors will be thrown.
+ BigNumber.config({ ERRORS: false })CRYPTOtrue, false, 0 or
+ 1.false
+ CRYPTO is set to true then the
+ random method will generate random digits using
+ crypto.getRandomValues in browsers that support it, or
+ crypto.randomBytes if using a version of Node.js that supports it.
+ CRYPTO to true will fail, and if ERRORS
+ is true an exception will be thrown.
+ CRYPTO is false then the source of randomness used will be
+ Math.random (which is assumed to generate at least 30 bits of
+ randomness).
+ random.BigNumber.config({ CRYPTO: true })
+BigNumber.config().CRYPTO // true
+BigNumber.random() // 0.54340758610486147524
+ MODULO_MODE0 to 9 inclusive1 (ROUND_DOWN)
+ a mod n.q = a / n, is calculated according to the
+ ROUNDING_MODE that corresponds to the chosen
+ MODULO_MODE.
+ r, is calculated as: r = a - n * q.| Property | Value | Description |
|---|---|---|
| ROUND_UP | 0 | ++ The remainder is positive if the dividend is negative, otherwise it is negative. + | +
| ROUND_DOWN | 1 | +
+ The remainder has the same sign as the dividend. + This uses 'truncating division' and matches the behaviour of JavaScript's + remainder operator %.
+ |
+
| ROUND_FLOOR | 3 | +
+ The remainder has the same sign as the divisor. + This matches Python's % operator.
+ |
+
| ROUND_HALF_EVEN | 6 | +The IEEE 754 remainder function. | +
| EUCLID | 9 | +
+ The remainder is always positive. Euclidian division: + q = sign(n) * floor(a / abs(n))
+ |
+
modulo.BigNumber.config({ MODULO_MODE: BigNumber.EUCLID })
+BigNumber.config({ MODULO_MODE: 9 }) // equivalent
+ POW_PRECISION0 to 1e+9 inclusive.0
+ 0, the number of signifcant digits will not be limited.toPower.BigNumber.config({ POW_PRECISION: 100 })FORMATFORMAT object configures the format of the string returned by the
+ toFormat method.
+ FORMAT object that are
+ recognised, and their default values.
+ FORMAT object will not be checked for validity. The existing
+ FORMAT object will simply be replaced by the object that is passed in.
+ Note that all the properties shown below do not have to be included.
+ toFormat for examples of usage.
+BigNumber.config({
+ FORMAT: {
+ // the decimal separator
+ decimalSeparator: '.',
+ // the grouping separator of the integer part
+ groupSeparator: ',',
+ // the primary grouping size of the integer part
+ groupSize: 3,
+ // the secondary grouping size of the integer part
+ secondaryGroupSize: 0,
+ // the grouping separator of the fraction part
+ fractionGroupSeparator: ' ',
+ // the grouping size of the fraction part
+ fractionGroupSize: 0
+ }
+});
+ Returns an object with the above properties and their current values.
+
+ If the value to be assigned to any of the above properties is null or
+ undefined it is ignored.
+
See Errors for the treatment of invalid values.
+
+BigNumber.config({
+ DECIMAL_PLACES: 40,
+ ROUNDING_MODE: BigNumber.ROUND_HALF_CEIL,
+ EXPONENTIAL_AT: [-10, 20],
+ RANGE: [-500, 500],
+ ERRORS: true,
+ CRYPTO: true,
+ MODULO_MODE: BigNumber.ROUND_FLOOR,
+ POW_PRECISION: 80,
+ FORMAT: {
+ groupSize: 3,
+ groupSeparator: ' ',
+ decimalSeparator: ','
+ }
+});
+
+// Alternatively but equivalently (excluding FORMAT):
+BigNumber.config( 40, 7, [-10, 20], 500, 1, 1, 3, 80 )
+
+obj = BigNumber.config();
+obj.ERRORS // true
+obj.RANGE // [-500, 500]
+
+
+
+ .max([arg1 [, arg2, ...]]) ⇒ BigNumber
+
+ arg1, arg2, ...: number|string|BigNumber
+ See BigNumber for further parameter details.
+
+ Returns a BigNumber whose value is the maximum of arg1,
+ arg2,... .
+
The argument to this method can also be an array of values.
+The return value is always exact and unrounded.
+x = new BigNumber('3257869345.0378653')
+BigNumber.max(4e9, x, '123456789.9') // '4000000000'
+
+arr = [12, '13', new BigNumber(14)]
+BigNumber.max(arr) // '14'
+
+
+
+ .min([arg1 [, arg2, ...]]) ⇒ BigNumber
+
+ arg1, arg2, ...: number|string|BigNumber
+ See BigNumber for further parameter details.
+
+ Returns a BigNumber whose value is the minimum of arg1,
+ arg2,... .
+
The argument to this method can also be an array of values.
+The return value is always exact and unrounded.
+x = new BigNumber('3257869345.0378653')
+BigNumber.min(4e9, x, '123456789.9') // '123456789.9'
+
+arr = [2, new BigNumber(-14), '-15.9999', -12]
+BigNumber.min(arr) // '-15.9999'
+
+
+
+ .random([dp]) ⇒ BigNumber
+ dp: number: integer, 0 to 1e+9 inclusive
+ Returns a new BigNumber with a pseudo-random value equal to or greater than 0 and
+ less than 1.
+
+ The return value will have dp decimal places (or less if trailing zeros are
+ produced).
+ If dp is omitted then the number of decimal places will default to the current
+ DECIMAL_PLACES setting.
+
+ Depending on the value of this BigNumber constructor's
+ CRYPTO setting and the support for the
+ crypto object in the host environment, the random digits of the return value are
+ generated by either Math.random (fastest), crypto.getRandomValues
+ (Web Cryptography API in recent browsers) or crypto.randomBytes (Node.js).
+
+ If CRYPTO is true, i.e. one of the
+ crypto methods is to be used, the value of a returned BigNumber should be
+ cryptographically-secure and statistically indistinguishable from a random value.
+
BigNumber.config({ DECIMAL_PLACES: 10 })
+BigNumber.random() // '0.4117936847'
+BigNumber.random(20) // '0.78193327636914089009'
+
+
+
+
+ The library's enumerated rounding modes are stored as properties of the constructor.
+ (They are not referenced internally by the library itself.)
+
+ Rounding modes 0 to 6 (inclusive) are the same as those of Java's
+ BigDecimal class.
+
| Property | +Value | +Description | +
|---|---|---|
| ROUND_UP | +0 | +Rounds away from zero | +
| ROUND_DOWN | +1 | +Rounds towards zero | +
| ROUND_CEIL | +2 | +Rounds towards Infinity |
+
| ROUND_FLOOR | +3 | +Rounds towards -Infinity |
+
| ROUND_HALF_UP | +4 | +
+ Rounds towards nearest neighbour. + If equidistant, rounds away from zero + |
+
| ROUND_HALF_DOWN | +5 | +
+ Rounds towards nearest neighbour. + If equidistant, rounds towards zero + |
+
| ROUND_HALF_EVEN | +6 | +
+ Rounds towards nearest neighbour. + If equidistant, rounds towards even neighbour + |
+
| ROUND_HALF_CEIL | +7 | +
+ Rounds towards nearest neighbour. + If equidistant, rounds towards Infinity
+ |
+
| ROUND_HALF_FLOOR | +8 | +
+ Rounds towards nearest neighbour. + If equidistant, rounds towards -Infinity
+ |
+
+BigNumber.config({ ROUNDING_MODE: BigNumber.ROUND_CEIL })
+BigNumber.config({ ROUNDING_MODE: 2 }) // equivalent
+
+
+ The methods inherited by a BigNumber instance from its constructor's prototype object.
+A BigNumber is immutable in the sense that it is not changed by its methods.
+
+ The treatment of ±0, ±Infinity and NaN is
+ consistent with how JavaScript treats these values.
+
+ Many method names have a shorter alias.
+ (Internally, the library always uses the shorter method names.)
+
.abs() ⇒ BigNumber+ Returns a BigNumber whose value is the absolute value, i.e. the magnitude, of the value of + this BigNumber. +
+The return value is always exact and unrounded.
++x = new BigNumber(-0.8) +y = x.absoluteValue() // '0.8' +z = y.abs() // '0.8'+ + + +
.ceil() ⇒ BigNumber
+ Returns a BigNumber whose value is the value of this BigNumber rounded to
+ a whole number in the direction of positive Infinity.
+
+x = new BigNumber(1.3) +x.ceil() // '2' +y = new BigNumber(-1.8) +y.ceil() // '-1'+ + + +
.cmp(n [, base]) ⇒ number
+ n: number|string|BigNumber
+ base: number
+ See BigNumber for further parameter details.
+
| Returns | |
|---|---|
1 |
+ If the value of this BigNumber is greater than the value of n |
+
-1 |
+ If the value of this BigNumber is less than the value of n |
+
0 |
+ If this BigNumber and n have the same value |
+
null |
+ If the value of either this BigNumber or n is NaN |
+
+x = new BigNumber(Infinity)
+y = new BigNumber(5)
+x.comparedTo(y) // 1
+x.comparedTo(x.minus(1)) // 0
+y.cmp(NaN) // null
+y.cmp('110', 2) // -1
+
+
+
+ .dp() ⇒ number
+ Return the number of decimal places of the value of this BigNumber, or null if
+ the value of this BigNumber is ±Infinity or NaN.
+
+x = new BigNumber(123.45)
+x.decimalPlaces() // 2
+y = new BigNumber('9.9e-101')
+y.dp() // 102
+
+
+
+ .div(n [, base]) ⇒ BigNumber
+
+ n: number|string|BigNumber
+ base: number
+ See BigNumber for further parameter details.
+
+ Returns a BigNumber whose value is the value of this BigNumber divided by
+ n, rounded according to the current
+ DECIMAL_PLACES and
+ ROUNDING_MODE configuration.
+
+x = new BigNumber(355) +y = new BigNumber(113) +x.dividedBy(y) // '3.14159292035398230088' +x.div(5) // '71' +x.div(47, 16) // '5'+ + + +
.divToInt(n [, base]) ⇒
+ BigNumber
+
+ n: number|string|BigNumber
+ base: number
+ See BigNumber for further parameter details.
+
+ Return a BigNumber whose value is the integer part of dividing the value of this BigNumber by
+ n.
+
+x = new BigNumber(5)
+y = new BigNumber(3)
+x.dividedToIntegerBy(y) // '1'
+x.divToInt(0.7) // '7'
+x.divToInt('0.f', 16) // '5'
+
+
+
+ .eq(n [, base]) ⇒ boolean
+ n: number|string|BigNumber
+ base: number
+ See BigNumber for further parameter details.
+
+ Returns true if the value of this BigNumber equals the value of n,
+ otherwise returns false.
+ As with JavaScript, NaN does not equal NaN.
+
Note: This method uses the comparedTo method internally.
+0 === 1e-324 // true
+x = new BigNumber(0)
+x.equals('1e-324') // false
+BigNumber(-0).eq(x) // true ( -0 === 0 )
+BigNumber(255).eq('ff', 16) // true
+
+y = new BigNumber(NaN)
+y.equals(NaN) // false
+
+
+
+ .floor() ⇒ BigNumber
+ Returns a BigNumber whose value is the value of this BigNumber rounded to a whole number in
+ the direction of negative Infinity.
+
+x = new BigNumber(1.8) +x.floor() // '1' +y = new BigNumber(-1.3) +y.floor() // '-2'+ + + +
.gt(n [, base]) ⇒ boolean
+ n: number|string|BigNumber
+ base: number
+ See BigNumber for further parameter details.
+
+ Returns true if the value of this BigNumber is greater than the value of
+ n, otherwise returns false.
+
Note: This method uses the comparedTo method internally.
+0.1 > (0.3 - 0.2) // true +x = new BigNumber(0.1) +x.greaterThan(BigNumber(0.3).minus(0.2)) // false +BigNumber(0).gt(x) // false +BigNumber(11, 3).gt(11.1, 2) // true+ + + +
.gte(n [, base]) ⇒ boolean
+
+ n: number|string|BigNumber
+ base: number
+ See BigNumber for further parameter details.
+
+ Returns true if the value of this BigNumber is greater than or equal to the value
+ of n, otherwise returns false.
+
Note: This method uses the comparedTo method internally.
+(0.3 - 0.2) >= 0.1 // false
+x = new BigNumber(0.3).minus(0.2)
+x.greaterThanOrEqualTo(0.1) // true
+BigNumber(1).gte(x) // true
+BigNumber(10, 18).gte('i', 36) // true
+
+
+
+ .isFinite() ⇒ boolean
+ Returns true if the value of this BigNumber is a finite number, otherwise
+ returns false.
+
+ The only possible non-finite values of a BigNumber are NaN, Infinity
+ and -Infinity.
+
+x = new BigNumber(1) +x.isFinite() // true +y = new BigNumber(Infinity) +y.isFinite() // false+
+ Note: The native method isFinite() can be used if
+ n <= Number.MAX_VALUE.
+
.isInt() ⇒ boolean
+ Returns true if the value of this BigNumber is a whole number, otherwise returns
+ false.
+
+x = new BigNumber(1) +x.isInteger() // true +y = new BigNumber(123.456) +y.isInt() // false+ + + +
.isNaN() ⇒ boolean
+ Returns true if the value of this BigNumber is NaN, otherwise
+ returns false.
+
+x = new BigNumber(NaN)
+x.isNaN() // true
+y = new BigNumber('Infinity')
+y.isNaN() // false
+ Note: The native method isNaN() can also be used.
.isNeg() ⇒ boolean
+ Returns true if the value of this BigNumber is negative, otherwise returns
+ false.
+
+x = new BigNumber(-0) +x.isNegative() // true +y = new BigNumber(2) +y.isNeg() // false+
Note: n < 0 can be used if n <= -Number.MIN_VALUE.
.isZero() ⇒ boolean
+ Returns true if the value of this BigNumber is zero or minus zero, otherwise
+ returns false.
+
+x = new BigNumber(-0) +x.isZero() && x.isNeg() // true +y = new BigNumber(Infinity) +y.isZero() // false+
Note: n == 0 can be used if n >= Number.MIN_VALUE.
.lt(n [, base]) ⇒ boolean
+ n: number|string|BigNumber
+ base: number
+ See BigNumber for further parameter details.
+
+ Returns true if the value of this BigNumber is less than the value of
+ n, otherwise returns false.
+
Note: This method uses the comparedTo method internally.
+(0.3 - 0.2) < 0.1 // true +x = new BigNumber(0.3).minus(0.2) +x.lessThan(0.1) // false +BigNumber(0).lt(x) // true +BigNumber(11.1, 2).lt(11, 3) // true+ + + +
.lte(n [, base]) ⇒ boolean
+
+ n: number|string|BigNumber
+ base: number
+ See BigNumber for further parameter details.
+
+ Returns true if the value of this BigNumber is less than or equal to the value of
+ n, otherwise returns false.
+
Note: This method uses the comparedTo method internally.
+0.1 <= (0.3 - 0.2) // false
+x = new BigNumber(0.1)
+x.lessThanOrEqualTo(BigNumber(0.3).minus(0.2)) // true
+BigNumber(-1).lte(x) // true
+BigNumber(10, 18).lte('i', 36) // true
+
+
+
+ .minus(n [, base]) ⇒ BigNumber
+
+ n: number|string|BigNumber
+ base: number
+ See BigNumber for further parameter details.
+
Returns a BigNumber whose value is the value of this BigNumber minus n.
The return value is always exact and unrounded.
++0.3 - 0.1 // 0.19999999999999998 +x = new BigNumber(0.3) +x.minus(0.1) // '0.2' +x.minus(0.6, 20) // '0'+ + + +
.mod(n [, base]) ⇒ BigNumber
+ n: number|string|BigNumber
+ base: number
+ See BigNumber for further parameter details.
+
+ Returns a BigNumber whose value is the value of this BigNumber modulo n, i.e.
+ the integer remainder of dividing this BigNumber by n.
+
+ The value returned, and in particular its sign, is dependent on the value of the
+ MODULO_MODE setting of this BigNumber constructor.
+ If it is 1 (default value), the result will have the same sign as this BigNumber,
+ and it will match that of Javascript's % operator (within the limits of double
+ precision) and BigDecimal's remainder method.
+
The return value is always exact and unrounded.
+
+ See MODULO_MODE for a description of the other
+ modulo modes.
+
+1 % 0.9 // 0.09999999999999998
+x = new BigNumber(1)
+x.modulo(0.9) // '0.1'
+y = new BigNumber(33)
+y.mod('a', 33) // '3'
+
+
+
+ .neg() ⇒ BigNumber
+ Returns a BigNumber whose value is the value of this BigNumber negated, i.e. multiplied by
+ -1.
+
+x = new BigNumber(1.8) +x.negated() // '-1.8' +y = new BigNumber(-1.3) +y.neg() // '1.3'+ + + +
.plus(n [, base]) ⇒ BigNumber
+ n: number|string|BigNumber
+ base: number
+ See BigNumber for further parameter details.
+
Returns a BigNumber whose value is the value of this BigNumber plus n.
The return value is always exact and unrounded.
+
+0.1 + 0.2 // 0.30000000000000004
+x = new BigNumber(0.1)
+y = x.plus(0.2) // '0.3'
+BigNumber(0.7).plus(x).plus(y) // '1'
+x.plus('0.1', 8) // '0.225'
+
+
+
+ .sd([z]) ⇒ number
+ z: boolean|number: true, false, 0
+ or 1
+
Returns the number of significant digits of the value of this BigNumber.
+
+ If z is true or 1 then any trailing zeros of the
+ integer part of a number are counted as significant digits, otherwise they are not.
+
+x = new BigNumber(1.234) +x.precision() // 4 +y = new BigNumber(987000) +y.sd() // 3 +y.sd(true) // 6+ + + +
.round([dp [, rm]]) ⇒ BigNumber
+ dp: number: integer, 0 to 1e+9 inclusive
+ rm: number: integer, 0 to 8 inclusive
+
+ Returns a BigNumber whose value is the value of this BigNumber rounded by rounding mode
+ rm to a maximum of dp decimal places.
+
+ if dp is omitted, or is null or undefined, the
+ return value is n rounded to a whole number.
+ if rm is omitted, or is null or undefined,
+ ROUNDING_MODE is used.
+
+ See Errors for the treatment of other non-integer or out of range
+ dp or rm values.
+
+x = 1234.56 +Math.round(x) // 1235 + +y = new BigNumber(x) +y.round() // '1235' +y.round(1) // '1234.6' +y.round(2) // '1234.56' +y.round(10) // '1234.56' +y.round(0, 1) // '1234' +y.round(0, 6) // '1235' +y.round(1, 1) // '1234.5' +y.round(1, BigNumber.ROUND_HALF_EVEN) // '1234.6' +y // '1234.56'+ + + +
.shift(n) ⇒ BigNumber
+ n: number: integer,
+ -9007199254740991 to 9007199254740991 inclusive
+
+ Returns a BigNumber whose value is the value of this BigNumber shifted n places.
+
+ The shift is of the decimal point, i.e. of powers of ten, and is to the left if n
+ is negative or to the right if n is positive.
+
The return value is always exact and unrounded.
++x = new BigNumber(1.23) +x.shift(3) // '1230' +x.shift(-3) // '0.00123'+ + + +
.sqrt() ⇒ BigNumber
+ Returns a BigNumber whose value is the square root of the value of this BigNumber,
+ rounded according to the current
+ DECIMAL_PLACES and
+ ROUNDING_MODE configuration.
+
+ The return value will be correctly rounded, i.e. rounded as if the result was first calculated + to an infinite number of correct digits before rounding. +
++x = new BigNumber(16) +x.squareRoot() // '4' +y = new BigNumber(3) +y.sqrt() // '1.73205080756887729353'+ + + +
.times(n [, base]) ⇒ BigNumber
+ n: number|string|BigNumber
+ base: number
+ See BigNumber for further parameter details.
+
Returns a BigNumber whose value is the value of this BigNumber times n.
The return value is always exact and unrounded.
+
+0.6 * 3 // 1.7999999999999998
+x = new BigNumber(0.6)
+y = x.times(3) // '1.8'
+BigNumber('7e+500').times(y) // '1.26e+501'
+x.times('-a', 16) // '-6'
+
+
+
+ .toDigits([sd [, rm]]) ⇒ BigNumber
+
+ sd: number: integer, 1 to 1e+9 inclusive.
+ rm: number: integer, 0 to 8 inclusive.
+
+ Returns a BigNumber whose value is the value of this BigNumber rounded to sd
+ significant digits using rounding mode rm.
+
+ If sd is omitted or is null or undefined, the return
+ value will not be rounded.
+ If rm is omitted or is null or undefined,
+ ROUNDING_MODE will be used.
+
+ See Errors for the treatment of other non-integer or out of range
+ sd or rm values.
+
+BigNumber.config({ precision: 5, rounding: 4 })
+x = new BigNumber(9876.54321)
+
+x.toDigits() // '9876.5'
+x.toDigits(6) // '9876.54'
+x.toDigits(6, BigNumber.ROUND_UP) // '9876.55'
+x.toDigits(2) // '9900'
+x.toDigits(2, 1) // '9800'
+x // '9876.54321'
+
+
+
+ .toExponential([dp [, rm]]) ⇒ string
+
+ dp: number: integer, 0 to 1e+9 inclusive
+ rm: number: integer, 0 to 8 inclusive
+
+ Returns a string representing the value of this BigNumber in exponential notation rounded
+ using rounding mode rm to dp decimal places, i.e with one digit
+ before the decimal point and dp digits after it.
+
+ If the value of this BigNumber in exponential notation has fewer than dp fraction
+ digits, the return value will be appended with zeros accordingly.
+
+ If dp is omitted, or is null or undefined, the number
+ of digits after the decimal point defaults to the minimum number of digits necessary to
+ represent the value exactly.
+ If rm is omitted or is null or undefined,
+ ROUNDING_MODE is used.
+
+ See Errors for the treatment of other non-integer or out of range
+ dp or rm values.
+
+x = 45.6 +y = new BigNumber(x) +x.toExponential() // '4.56e+1' +y.toExponential() // '4.56e+1' +x.toExponential(0) // '5e+1' +y.toExponential(0) // '5e+1' +x.toExponential(1) // '4.6e+1' +y.toExponential(1) // '4.6e+1' +y.toExponential(1, 1) // '4.5e+1' (ROUND_DOWN) +x.toExponential(3) // '4.560e+1' +y.toExponential(3) // '4.560e+1'+ + + +
.toFixed([dp [, rm]]) ⇒ string
+
+ dp: number: integer, 0 to 1e+9 inclusive
+ rm: number: integer, 0 to 8 inclusive
+
+ Returns a string representing the value of this BigNumber in normal (fixed-point) notation
+ rounded to dp decimal places using rounding mode rm.
+
+ If the value of this BigNumber in normal notation has fewer than dp fraction
+ digits, the return value will be appended with zeros accordingly.
+
+ Unlike Number.prototype.toFixed, which returns exponential notation if a number
+ is greater or equal to 1021, this method will always return normal
+ notation.
+
+ If dp is omitted or is null or undefined, the return
+ value will be unrounded and in normal notation. This is also unlike
+ Number.prototype.toFixed, which returns the value to zero decimal places.
+ It is useful when fixed-point notation is required and the current
+ EXPONENTIAL_AT setting causes
+ toString to return exponential notation.
+ If rm is omitted or is null or undefined,
+ ROUNDING_MODE is used.
+
+ See Errors for the treatment of other non-integer or out of range
+ dp or rm values.
+
+x = 3.456 +y = new BigNumber(x) +x.toFixed() // '3' +y.toFixed() // '3.456' +y.toFixed(0) // '3' +x.toFixed(2) // '3.46' +y.toFixed(2) // '3.46' +y.toFixed(2, 1) // '3.45' (ROUND_DOWN) +x.toFixed(5) // '3.45600' +y.toFixed(5) // '3.45600'+ + + +
.toFormat([dp [, rm]]) ⇒ string
+
+ dp: number: integer, 0 to 1e+9 inclusive
+ rm: number: integer, 0 to 8 inclusive
+
+
+ Returns a string representing the value of this BigNumber in normal (fixed-point) notation
+ rounded to dp decimal places using rounding mode rm, and formatted
+ according to the properties of the FORMAT object.
+
+ See the examples below for the properties of the
+ FORMAT object, their types and their usage.
+
+ If dp is omitted or is null or undefined, then the
+ return value is not rounded to a fixed number of decimal places.
+ If rm is omitted or is null or undefined,
+ ROUNDING_MODE is used.
+
+ See Errors for the treatment of other non-integer or out of range
+ dp or rm values.
+
+format = {
+ decimalSeparator: '.',
+ groupSeparator: ',',
+ groupSize: 3,
+ secondaryGroupSize: 0,
+ fractionGroupSeparator: ' ',
+ fractionGroupSize: 0
+}
+BigNumber.config({ FORMAT: format })
+
+x = new BigNumber('123456789.123456789')
+x.toFormat() // '123,456,789.123456789'
+x.toFormat(1) // '123,456,789.1'
+
+// If a reference to the object assigned to FORMAT has been retained,
+// the format properties can be changed directly
+format.groupSeparator = ' '
+format.fractionGroupSize = 5
+x.toFormat() // '123 456 789.12345 6789'
+
+BigNumber.config({
+ FORMAT: {
+ decimalSeparator: ',',
+ groupSeparator: '.',
+ groupSize: 3,
+ secondaryGroupSize: 2
+ }
+})
+
+x.toFormat(6) // '12.34.56.789,123'
+
+
+
+ .toFraction([max]) ⇒ [string, string]
+
+ max: number|string|BigNumber: integer >= 1 and <
+ Infinity
+
+ Returns a string array representing the value of this BigNumber as a simple fraction with an
+ integer numerator and an integer denominator. The denominator will be a positive non-zero
+ value less than or equal to max.
+
+ If a maximum denominator, max, is not specified, or is null or
+ undefined, the denominator will be the lowest value necessary to represent the
+ number exactly.
+
+ See Errors for the treatment of other non-integer or out of range
+ max values.
+
+x = new BigNumber(1.75)
+x.toFraction() // '7, 4'
+
+pi = new BigNumber('3.14159265358')
+pi.toFraction() // '157079632679,50000000000'
+pi.toFraction(100000) // '312689, 99532'
+pi.toFraction(10000) // '355, 113'
+pi.toFraction(100) // '311, 99'
+pi.toFraction(10) // '22, 7'
+pi.toFraction(1) // '3, 1'
+
+
+
+ .toJSON() ⇒ stringAs valueOf.
+x = new BigNumber('177.7e+457')
+y = new BigNumber(235.4325)
+z = new BigNumber('0.0098074')
+
+// Serialize an array of three BigNumbers
+str = JSON.stringify( [x, y, z] )
+// "["1.777e+459","235.4325","0.0098074"]"
+
+// Return an array of three BigNumbers
+JSON.parse(str, function (key, val) {
+ return key === '' ? val : new BigNumber(val)
+})
+
+
+
+ .toNumber() ⇒ numberReturns the value of this BigNumber as a JavaScript number primitive.
++ Type coercion with, for example, the unary plus operator will also work, except that a + BigNumber with the value minus zero will be converted to positive zero. +
+
+x = new BigNumber(456.789)
+x.toNumber() // 456.789
++x // 456.789
+
+y = new BigNumber('45987349857634085409857349856430985')
+y.toNumber() // 4.598734985763409e+34
+
+z = new BigNumber(-0)
+1 / +z // Infinity
+1 / z.toNumber() // -Infinity
+
+
+
+ .pow(n [, m]) ⇒ BigNumber
+ n: number: integer,
+ -9007199254740991 to 9007199254740991 inclusive
+ m: number|string|BigNumber
+
+ Returns a BigNumber whose value is the value of this BigNumber raised to the power
+ n, and optionally modulo a modulus m.
+
+ If n is negative the result is rounded according to the current
+ DECIMAL_PLACES and
+ ROUNDING_MODE configuration.
+
+ If n is not an integer or is out of range:
+
+ If ERRORS is true a BigNumber Error is thrown,
+ else if n is greater than 9007199254740991, it is interpreted as
+ Infinity;
+ else if n is less than -9007199254740991, it is interpreted as
+ -Infinity;
+ else if n is otherwise a number, it is truncated to an integer;
+ else it is interpreted as NaN.
+
+ As the number of digits of the result of the power operation can grow so large so quickly,
+ e.g. 123.45610000 has over 50000 digits, the number of significant
+ digits calculated is limited to the value of the
+ POW_PRECISION setting (unless a modulus
+ m is specified).
+
+ By default POW_PRECISION is set to 0.
+ This means that an unlimited number of significant digits will be calculated, and that the
+ method's performance will decrease dramatically for larger exponents.
+
+ Negative exponents will be calculated to the number of decimal places specified by
+ DECIMAL_PLACES (but not to more than
+ POW_PRECISION significant digits).
+
+ If m is specified and the value of m, n and this
+ BigNumber are positive integers, then a fast modular exponentiation algorithm is used,
+ otherwise if any of the values is not a positive integer the operation will simply be
+ performed as x.toPower(n).modulo(m) with a
+ POW_PRECISION of 0.
+
+Math.pow(0.7, 2) // 0.48999999999999994 +x = new BigNumber(0.7) +x.toPower(2) // '0.49' +BigNumber(3).pow(-2) // '0.11111111111111111111'+ + + +
.toPrecision([sd [, rm]]) ⇒ string
+
+ sd: number: integer, 1 to 1e+9 inclusive
+ rm: number: integer, 0 to 8 inclusive
+
+ Returns a string representing the value of this BigNumber rounded to sd
+ significant digits using rounding mode rm.
+
+ If sd is less than the number of digits necessary to represent the integer part
+ of the value in normal (fixed-point) notation, then exponential notation is used.
+
+ If sd is omitted, or is null or undefined, then the
+ return value is the same as n.toString().
+ If rm is omitted or is null or undefined,
+ ROUNDING_MODE is used.
+
+ See Errors for the treatment of other non-integer or out of range
+ sd or rm values.
+
+x = 45.6 +y = new BigNumber(x) +x.toPrecision() // '45.6' +y.toPrecision() // '45.6' +x.toPrecision(1) // '5e+1' +y.toPrecision(1) // '5e+1' +y.toPrecision(2, 0) // '4.6e+1' (ROUND_UP) +y.toPrecision(2, 1) // '4.5e+1' (ROUND_DOWN) +x.toPrecision(5) // '45.600' +y.toPrecision(5) // '45.600'+ + + +
.toString([base]) ⇒ stringbase: number: integer, 2 to 64 inclusive
+ Returns a string representing the value of this BigNumber in the specified base, or base
+ 10 if base is omitted or is null or
+ undefined.
+
+ For bases above 10, values from 10 to 35 are
+ represented by a-z (as with Number.prototype.toString),
+ 36 to 61 by A-Z, and 62 and
+ 63 by $ and _ respectively.
+
+ If a base is specified the value is rounded according to the current
+ DECIMAL_PLACES
+ and ROUNDING_MODE configuration.
+
+ If a base is not specified, and this BigNumber has a positive
+ exponent that is equal to or greater than the positive component of the
+ current EXPONENTIAL_AT setting,
+ or a negative exponent equal to or less than the negative component of the
+ setting, then exponential notation is returned.
+
If base is null or undefined it is ignored.
+ See Errors for the treatment of other non-integer or out of range
+ base values.
+
+x = new BigNumber(750000)
+x.toString() // '750000'
+BigNumber.config({ EXPONENTIAL_AT: 5 })
+x.toString() // '7.5e+5'
+
+y = new BigNumber(362.875)
+y.toString(2) // '101101010.111'
+y.toString(9) // '442.77777777777777777778'
+y.toString(32) // 'ba.s'
+
+BigNumber.config({ DECIMAL_PLACES: 4 });
+z = new BigNumber('1.23456789')
+z.toString() // '1.23456789'
+z.toString(10) // '1.2346'
+
+
+
+ .trunc() ⇒ BigNumber+ Returns a BigNumber whose value is the value of this BigNumber truncated to a whole number. +
++x = new BigNumber(123.456) +x.truncated() // '123' +y = new BigNumber(-12.3) +y.trunc() // '-12'+ + + +
.valueOf() ⇒ string
+ As toString, but does not accept a base argument and includes the minus sign
+ for negative zero.
+
+x = new BigNumber('-0')
+x.toString() // '0'
+x.valueOf() // '-0'
+y = new BigNumber('1.777e+457')
+y.valueOf() // '1.777e+457'
+
+
+
+ The properties of a BigNumber instance:
+| Property | +Description | +Type | +Value | +
|---|---|---|---|
| c | +coefficient* | +number[] |
+ Array of base 1e14 numbers |
+
| e | +exponent | +number | +Integer, -1000000000 to 1000000000 inclusive |
+
| s | +sign | +number | +-1 or 1 |
+
| isBigNumber | +type identifier | +boolean | +true |
+
*significand
+
+ The value of any of the c, e and s properties may also
+ be null.
+
+ From v2.0.0 of this library, the value of the coefficient of a BigNumber is stored in a
+ normalised base 100000000000000 floating point format, as opposed to the base
+ 10 format used in v1.x.x
+
+ This change means the properties of a BigNumber are now best considered to be read-only. + Previously it was acceptable to change the exponent of a BigNumber by writing to its exponent + property directly, but this is no longer recommended as the number of digits in the first + element of the coefficient array is dependent on the exponent, so the coefficient would also + need to be altered. +
++ Note that, as with JavaScript numbers, the original exponent and fractional trailing zeros are + not necessarily preserved. +
+x = new BigNumber(0.123) // '0.123'
+x.toExponential() // '1.23e-1'
+x.c // '1,2,3'
+x.e // -1
+x.s // 1
+
+y = new Number(-123.4567000e+2) // '-12345.67'
+y.toExponential() // '-1.234567e+4'
+z = new BigNumber('-123.4567000e+2') // '-12345.67'
+z.toExponential() // '-1.234567e+4'
+z.c // '1,2,3,4,5,6,7'
+z.e // 4
+z.s // -1
+ Checking if a value is a BigNumber instance:
++x = new BigNumber(3) +x instanceof BigNumber // true +x.isBigNumber // true + +BN = BigNumber.another(); + +y = new BN(3) +y instanceof BigNumber // false +y.isBigNumber // true+ + + + +
+ The table below shows how ±0, NaN and
+ ±Infinity are stored.
+
| + | c | +e | +s | +
|---|---|---|---|
| ±0 | +[0] |
+ 0 |
+ ±1 |
+
| NaN | +null |
+ null |
+ null |
+
| ±Infinity | +null |
+ null |
+ ±1 |
+
+x = new Number(-0) // 0 +1 / x == -Infinity // true + +y = new BigNumber(-0) // '0' +y.c // '0' ( [0].toString() ) +y.e // 0 +y.s // -1+ + + +
+ The errors that are thrown are generic Error objects with name
+ BigNumber Error.
+
+ The table below shows the errors that may be thrown if ERRORS is
+ true, and the action taken if ERRORS is false.
+
| Method(s) | +ERRORS: true Throw BigNumber Error |
+ ERRORS: false Action on invalid argument |
+
|---|---|---|
+
+ BigNumber |
+ number type has more than 15 significant digits |
+ Accept. | +
| not a base... number | +Substitute NaN. |
+ |
| base not an integer | +Truncate to integer. Ignore if not a number. |
+ |
| base out of range | +Ignore. | +|
| not a number* | +Substitute NaN. |
+ |
another |
+ not an object | +Ignore. | +
config |
+ DECIMAL_PLACES not an integer |
+ Truncate to integer. Ignore if not a number. |
+
DECIMAL_PLACES out of range |
+ Ignore. | +|
ROUNDING_MODE not an integer |
+ Truncate to integer. Ignore if not a number. |
+ |
ROUNDING_MODE out of range |
+ Ignore. | +|
EXPONENTIAL_AT not an integeror not [integer, integer] |
+ Truncate to integer(s). Ignore if not number(s). |
+ |
EXPONENTIAL_AT out of rangeor not [negative, positive] |
+ Ignore. | +|
RANGE not an integeror not [integer, integer] |
+ Truncate to integer(s). Ignore if not number(s). |
+ |
RANGE cannot be zero |
+ Ignore. | +|
RANGE out of rangeor not [negative, positive] |
+ Ignore. | +|
ERRORS not a booleanor binary digit |
+ Ignore. | +|
CRYPTO not a booleanor binary digit |
+ Ignore. | +|
CRYPTO crypto unavailable |
+ Ignore. | +|
MODULO_MODE not an integer |
+ Truncate to integer. Ignore if not a number. |
+ |
MODULO_MODE out of range |
+ Ignore. | +|
POW_PRECISION not an integer |
+ Truncate to integer. Ignore if not a number. |
+ |
POW_PRECISION out of range |
+ Ignore. | +|
FORMAT not an object |
+ Ignore. | +|
precision |
+ argument not a boolean or binary digit |
+ Ignore. | +
round |
+ decimal places not an integer | +Truncate to integer. Ignore if not a number. |
+
| decimal places out of range | +Ignore. | +|
| rounding mode not an integer | +Truncate to integer. Ignore if not a number. |
+ |
| rounding mode out of range | +Ignore. | +|
shift |
+ argument not an integer | +Truncate to integer. Ignore if not a number. |
+
| argument out of range | +Substitute ±Infinity.
+ | |
+ toExponential+ toFixed+ toFormat
+ |
+ decimal places not an integer | +Truncate to integer. Ignore if not a number. |
+
| decimal places out of range | +Ignore. | +|
| rounding mode not an integer | +Truncate to integer. Ignore if not a number. |
+ |
| rounding mode out of range | +Ignore. | +|
toFraction |
+ max denominator not an integer | +Truncate to integer. Ignore if not a number. |
+
| max denominator out of range | +Ignore. | +|
+ toDigits+ toPrecision
+ |
+ precision not an integer | +Truncate to integer. Ignore if not a number. |
+
| precision out of range | +Ignore. | +|
| rounding mode not an integer | +Truncate to integer. Ignore if not a number. |
+ |
| rounding mode out of range | +Ignore. | +|
toPower |
+ exponent not an integer | +Truncate to integer. Substitute NaN if not a number. |
+
| exponent out of range | +Substitute ±Infinity.
+ |
+ |
toString |
+ base not an integer | +Truncate to integer. Ignore if not a number. |
+
| base out of range | +Ignore. | +
*No error is thrown if the value is NaN or 'NaN'.
+ The message of a BigNumber Error will also contain the name of the method from which + the error originated. +
+To determine if an exception is a BigNumber Error:
+
+try {
+ // ...
+} catch (e) {
+ if ( e instanceof Error && e.name == 'BigNumber Error' ) {
+ // ...
+ }
+}
+
+
+
+ + Some arbitrary-precision libraries retain trailing fractional zeros as they can indicate the + precision of a value. This can be useful but the results of arithmetic operations can be + misleading. +
+
+x = new BigDecimal("1.0")
+y = new BigDecimal("1.1000")
+z = x.add(y) // 2.1000
+
+x = new BigDecimal("1.20")
+y = new BigDecimal("3.45000")
+z = x.multiply(y) // 4.1400000
+ + To specify the precision of a value is to specify that the value lies + within a certain range. +
+
+ In the first example, x has a value of 1.0. The trailing zero shows
+ the precision of the value, implying that it is in the range 0.95 to
+ 1.05. Similarly, the precision indicated by the trailing zeros of y
+ indicates that the value is in the range 1.09995 to 1.10005.
+
+ If we add the two lowest values in the ranges we have, 0.95 + 1.09995 = 2.04995,
+ and if we add the two highest values we have, 1.05 + 1.10005 = 2.15005, so the
+ range of the result of the addition implied by the precision of its operands is
+ 2.04995 to 2.15005.
+
+ The result given by BigDecimal of 2.1000 however, indicates that the value is in
+ the range 2.09995 to 2.10005 and therefore the precision implied by
+ its trailing zeros may be misleading.
+
+ In the second example, the true range is 4.122744 to 4.157256 yet
+ the BigDecimal answer of 4.1400000 indicates a range of 4.13999995
+ to 4.14000005. Again, the precision implied by the trailing zeros may be
+ misleading.
+
+ This library, like binary floating point and most calculators, does not retain trailing
+ fractional zeros. Instead, the toExponential, toFixed and
+ toPrecision methods enable trailing zeros to be added if and when required.
+
+
+> Terminal string styling done right
+
+[](http://travis-ci.org/sindresorhus/chalk)
+
+[colors.js](https://github.com/Marak/colors.js) is currently the most popular string styling module, but it has serious deficiencies like extending String.prototype which causes all kinds of [problems](https://github.com/yeoman/yo/issues/68). Although there are other ones, they either do too much or not enough.
+
+**Chalk is a clean and focused alternative.**
+
+
+
+
+## Why
+
+- **Doesn't extend String.prototype**
+- Expressive API
+- Clean and focused
+- Auto-detects color support
+- Actively maintained
+- [Used by 150+ modules](https://npmjs.org/browse/depended/chalk)
+
+
+## Install
+
+Install with [npm](https://npmjs.org/package/chalk): `npm install --save chalk`
+
+
+## Example
+
+Chalk comes with an easy to use composable API where you just chain and nest the styles you want.
+
+```js
+var chalk = require('chalk');
+
+// style a string
+console.log( chalk.blue('Hello world!') );
+
+// combine styled and normal strings
+console.log( chalk.blue('Hello'), 'World' + chalk.red('!') );
+
+// compose multiple styles using the chainable API
+console.log( chalk.blue.bgRed.bold('Hello world!') );
+
+// nest styles
+console.log( chalk.red('Hello', chalk.underline.bgBlue('world') + '!') );
+
+// pass in multiple arguments
+console.log( chalk.blue('Hello', 'World!', 'Foo', 'bar', 'biz', 'baz') );
+```
+
+You can easily define your own themes.
+
+```js
+var chalk = require('chalk');
+var error = chalk.bold.red;
+console.log(error('Error!'));
+```
+
+
+## API
+
+### chalk.`
+
+
+ A pure JavaScript version of the service provided at jsonlint.com.
+ ++ + +
+