Select Git revision
index.umd.js
index.umd.js 74.52 KiB
/*!
* json-schema-faker v0.5.0-rc21
* (c) Alvaro Cabrera <pateketrueke@gmail.com> (https://soypache.co)
* Released under the MIT License.
*/
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('json-schema-ref-parser'), require('jsonpath-plus')) :
typeof define === 'function' && define.amd ? define(['json-schema-ref-parser', 'jsonpath-plus'], factory) :
(global = global || self, global.JSONSchemaFaker = factory(global.$RefParser, global.jsonpathPlus));
}(this, function ($RefParser, jsonpathPlus) { 'use strict';
$RefParser = $RefParser && $RefParser.hasOwnProperty('default') ? $RefParser['default'] : $RefParser;
/**
* This class defines a registry for custom formats used within JSF.
*/
var Registry = function Registry() {
// empty by default
this.data = {};
};
/**
* Unregisters custom format(s)
* @param name
*/
Registry.prototype.unregister = function unregister (name) {
if (!name) {
this.data = {};
} else {
delete this.data[name];
}
};
/**
* Registers custom format
*/
Registry.prototype.register = function register (name, callback) {
this.data[name] = callback;
};
/**
* Register many formats at one shot
*/
Registry.prototype.registerMany = function registerMany (formats) {
var this$1 = this;
Object.keys(formats).forEach(function (name) {
this$1.data[name] = formats[name];
});
};
/**
* Returns element by registry key
*/
Registry.prototype.get = function get (name) {
var format = this.data[name];
return format;
};
/**
* Returns the whole registry content
*/
Registry.prototype.list = function list () {
return this.data;
};