Namespace JSV
Defined in: jsv.js.
Constructor Attributes | Constructor Name and Description |
---|---|
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.
|
Namespace Detail
JSV
A globaly accessible object that provides the ability to create and manage Environments,
as well as providing utility methods.
Method Detail
<static>
{Environment}
JSV.createEnvironment(id)
Creates and returns a new Environment that is a clone of the environment registered with the provided ID.
If no environment ID is provided, the default environment is cloned.
- Parameters:
- {String} id Optional
- The ID of the environment to clone. If
undefined
, the default environment ID is used.
- Throws:
- {Error}
- If there is no environment registered with the provided ID
- Returns:
- {Environment} A newly cloned Environment
<static>
{String}
JSV.getDefaultEnvironmentID()
Returns the ID of the default environment.
- Returns:
- {String} The ID of the default environment
<static>
{Boolean}
JSV.isJSONInstance(o)
Returns if the provide value is an instance of JSONInstance.
- Parameters:
- o
- The value to test
- Returns:
- {Boolean} If the provide value is an instance of JSONInstance
<static>
{Boolean}
JSV.isJSONSchema(o)
Returns if the provide value is an instance of JSONSchema.
- Parameters:
- o
- The value to test
- Returns:
- {Boolean} If the provide value is an instance of JSONSchema
<static>
JSV.registerEnvironment(id, env)
Registers the provided Environment with the provided ID.
- Parameters:
- {String} id
- The ID of the environment
- {Environment} env
- The environment to register
<static>
JSV.setDefaultEnvironmentID(id)
Sets which registered ID is the default environment.
- Parameters:
- {String} id
- The ID of the registered environment that is default
- Throws:
- {Error}
- If there is no registered environment with the provided ID
Utility Method Detail
<static>
JSV.clone(o, deep)
Creates a copy of the target object.
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.
- Parameters:
- {Any} o
- The value to clone
- {Boolean} deep Optional, Default: false
- If each property should be recursively cloned
- Returns:
- A cloned copy of the provided value
<static>
{Object}
JSV.createObject(proto)
Return a new object that inherits all of the properties of the provided object.
- Parameters:
- {Object} proto
- The prototype of the new object
- Returns:
- {Object} A new object that inherits all of the properties of the provided object
<static>
{String}
JSV.escapeURIComponent(str)
Properly escapes a URI component for embedding into a URI string.
- Parameters:
- {String} str
- The URI component to escape
- Returns:
- {String} The escaped URI component
<static>
{Array}
JSV.filterArray(arr, iterator, scope)
Returns a new array that only contains the items allowed by the iterator.
- Parameters:
- {Array} arr
- The array to filter
- {Function} iterator
- The function that returns true if the provided property should be added to the array
- {Object} scope
- The value of
this
within the iterator
- Returns:
- {Array} A new array that contains the items allowed by the iterator
<static>
{String}
JSV.formatURI(uri)
Returns a URI that is formated for JSV. Currently, this only ensures that the URI ends with a hash tag (
#
).
- Parameters:
- {String} uri
- The URI to format
- Returns:
- {String} The URI formatted for JSV
<static>
{Any}
JSV.inherits(base, extra, extension)
Merges two schemas/instance together.
- Parameters:
- {JSONSchema|Any} base
- The old value to merge
- {JSONSchema|Any} extra
- The new value to merge
- {Boolean} extension
- If the merge is a JSON Schema extension
- Returns:
- {Any} The modified base value
<static>
{Array}
JSV.keys(o)
Returns an array of the names of all properties of an object.
- Parameters:
- {Object|Array} o
- The object in question
- Returns:
- {Array} The names of all properties
<static>
{Array}
JSV.mapArray(arr, iterator, scope)
Returns a new array with each item transformed by the iterator.
- Parameters:
- {Array} arr
- The array to transform
- {Function} iterator
- A function that returns the new value of the provided item
- {Object} scope
- The value of
this
in the iterator
- Returns:
- {Array} A new array with each item transformed
<static>
{Object}
JSV.mapObject(obj, iterator, scope)
Returns a new object with each property transformed by the iterator.
- Parameters:
- {Object} obj
- The object to transform
- {Function} iterator
- A function that returns the new value of the provided property
- {Object} scope Optional
- The value of
this
in the iterator
- Returns:
- {Object} A new object with each property transformed
<static>
{Array}
JSV.popFirst(arr, o)
Mutates the array by removing the first item that matches the provided value in the array.
- Parameters:
- {Array} arr
- The array to modify
- {Any} o
- The object to remove from the array
- Returns:
- {Array} The provided array for chaining
<static>
{Array}
JSV.pushUnique(arr, o)
Mutates the array by pushing the provided value onto the array only if it is not already there.
- Parameters:
- {Array} arr
- The array to modify
- {Any} o
- The object to add to the array if it is not already there
- Returns:
- {Array} The provided array for chaining
<static>
{String}
JSV.randomUUID()
Generates a pseudo-random UUID.
- Returns:
- {String} A new universally unique ID
<static>
{Number}
JSV.searchArray(arr, o)
Returns the first index in the array that the provided item is located at.
- Parameters:
- {Array} arr
- The array to search
- {Any} o
- The item being searched for
- Returns:
- {Number} The index of the item in the array, or
-1
if not found
<static>
{Array}
JSV.toArray(o)
Returns an array representation of a value.
- For array-like objects, the value will be casted as an Array type.
- If an array is provided, the function will simply return the same array.
- For a null or undefined value, the result will be an empty Array.
- For all other values, the value will be the first element in a new Array.
- Parameters:
- {Any} o
- The value to convert into an array
- Returns:
- {Array} The value as an array
<static>
{String}
JSV.typeOf(o)
Returns the name of the type of the provided value.
- Parameters:
- {Any} o
- The value to determine the type of
- Returns:
- {String} The name of the type of the value