siren-parser
Advanced tools
Comparing version 7.0.0 to 7.1.0
(function(f){var g;if(typeof window!=='undefined'){g=window}else if(typeof self!=='undefined'){g=self}g=g.D2L||(g.D2L={});g=g.Hypermedia||(g.Hypermedia={});g=g.Siren||(g.Siren={});g.Parse=f()})(function(){var define,module,exports;return (function(){function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s}return e})()({1:[function(require,module,exports){ | ||
"use strict";function Action(t){var e=this;return t instanceof Action?t:this instanceof Action?(assert("object"===(void 0===t?"undefined":_typeof(t)),"action must be an object, got "+JSON.stringify(t)),assert("string"==typeof t.name,"action.name must be a string, got "+JSON.stringify(t.name)),assert("string"==typeof t.href,"action.href must be a string, got "+JSON.stringify(t.href)),assert(void 0===t.class||Array.isArray(t.class),"action.class must be an array or undefined, got "+JSON.stringify(t.class)),assert(void 0===t.method||"string"==typeof t.method,"action.method must be a string or undefined, got "+JSON.stringify(t.method)),assert(void 0===t.title||"string"==typeof t.title,"action.title must be a string or undefined, got "+JSON.stringify(t.title)),assert(void 0===t.type||"string"==typeof t.type,"action.type must be a string or undefined, got "+JSON.stringify(t.type)),assert(void 0===t.fields||Array.isArray(t.fields),"action.fields must be an array or undefined, got "+JSON.stringify(t.fields)),this.name=t.name,this.href=t.href,t.class&&(this.class=t.class),this.method=t.method||"GET",t.title&&(this.title=t.title),this.type=t.type||"application/x-www-form-urlencoded",this._fieldsByName={},this._fieldsByClass={},this._fieldsByType={},void(t.fields&&(this.fields=[],t.fields.forEach(function(t){var i=new Field(t);e.fields.push(i),e._fieldsByName[t.name]=i,i.type&&(e._fieldsByType[i.type]=e._fieldsByType[i.type]||[],e._fieldsByType[i.type].push(i)),i.class&&i.class.forEach(function(t){e._fieldsByClass[t]=e._fieldsByClass[t]||[],e._fieldsByClass[t].push(i)})}),this.fields=t.fields))):new Action(t)}var _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},assert=require("./assert"),Field=require("./Field"),util=require("./util");Action.prototype.hasClass=function(t){return this.class instanceof Array&&util.contains(this.class,t)},Action.prototype.hasField=function(t){return this.hasFieldByName(t)},Action.prototype.hasFieldByName=function(t){return util.hasProperty(this._fieldsByName,t)},Action.prototype.hasFieldByClass=function(t){return util.hasProperty(this._fieldsByClass,t)},Action.prototype.hasFieldByType=function(t){return util.hasProperty(this._fieldsByType,t)},Action.prototype.getField=function(t){return this.getFieldByName(t)},Action.prototype.getFieldByName=function(t){return util.getMatchingValue(this._fieldsByName,t)},Action.prototype.getFieldByClass=function(t){var e=util.getMatchingValue(this._fieldsByClass,t);return e?e[0]:void 0},Action.prototype.getFieldsByClass=function(t){var e=util.getMatchingValue(this._fieldsByClass,t);return e?e.slice():[]},Action.prototype.getFieldByClasses=function(t){var e=util.getMatchingValuesByAll(this.fields,t,"class");return e&&e.length>0?e[0]:void 0},Action.prototype.getFieldsByClasses=function(t){var e=util.getMatchingValuesByAll(this.fields,t,"class");return e&&e.length>0?e.slice():[]},Action.prototype.getFieldByType=function(t){var e=util.getMatchingValue(this._fieldsByType,t);return e?e[0]:void 0},Action.prototype.getFieldsByType=function(t){var e=util.getMatchingValue(this._fieldsByType,t);return e?e.slice():[]},module.exports=Action; | ||
"use strict";function Action(t){var e=this;return t instanceof Action?t:this instanceof Action?(assert("object"===(void 0===t?"undefined":_typeof(t)),"action must be an object, got "+JSON.stringify(t)),assert("string"==typeof t.name,"action.name must be a string, got "+JSON.stringify(t.name)),assert("string"==typeof t.href,"action.href must be a string, got "+JSON.stringify(t.href)),assert(void 0===t.class||Array.isArray(t.class),"action.class must be an array or undefined, got "+JSON.stringify(t.class)),assert(void 0===t.method||"string"==typeof t.method,"action.method must be a string or undefined, got "+JSON.stringify(t.method)),assert(void 0===t.title||"string"==typeof t.title,"action.title must be a string or undefined, got "+JSON.stringify(t.title)),assert(void 0===t.type||"string"==typeof t.type,"action.type must be a string or undefined, got "+JSON.stringify(t.type)),assert(void 0===t.fields||Array.isArray(t.fields),"action.fields must be an array or undefined, got "+JSON.stringify(t.fields)),this.name=t.name,this.href=t.href,t.class&&(this.class=t.class),this.method=t.method||"GET",t.title&&(this.title=t.title),this.type=t.type||"application/x-www-form-urlencoded",this._fieldsByName={},this._fieldsByClass={},this._fieldsByType={},void(t.fields&&(this.fields=[],t.fields.forEach(function(t){var i=new Field(t);e.fields.push(i),e._fieldsByName[t.name]=i,i.type&&(e._fieldsByType[i.type]=e._fieldsByType[i.type]||[],e._fieldsByType[i.type].push(i)),i.class&&i.class.forEach(function(t){e._fieldsByClass[t]=e._fieldsByClass[t]||[],e._fieldsByClass[t].push(i)})})))):new Action(t)}var _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},assert=require("./assert"),Field=require("./Field"),util=require("./util");Action.prototype.toJSON=function(){return{name:this.name,href:this.href,class:this.class,method:this.method,title:this.title,type:this.type,fields:this.fields}},Action.prototype.hasClass=function(t){return this.class instanceof Array&&util.contains(this.class,t)},Action.prototype.hasField=function(t){return this.hasFieldByName(t)},Action.prototype.hasFieldByName=function(t){return util.hasProperty(this._fieldsByName,t)},Action.prototype.hasFieldByClass=function(t){return util.hasProperty(this._fieldsByClass,t)},Action.prototype.hasFieldByType=function(t){return util.hasProperty(this._fieldsByType,t)},Action.prototype.getField=function(t){return this.getFieldByName(t)},Action.prototype.getFieldByName=function(t){return util.getMatchingValue(this._fieldsByName,t)},Action.prototype.getFieldByClass=function(t){var e=util.getMatchingValue(this._fieldsByClass,t);return e?e[0]:void 0},Action.prototype.getFieldsByClass=function(t){var e=util.getMatchingValue(this._fieldsByClass,t);return e?e.slice():[]},Action.prototype.getFieldByClasses=function(t){var e=util.getMatchingValuesByAll(this.fields,t,"class");return e&&e.length>0?e[0]:void 0},Action.prototype.getFieldsByClasses=function(t){var e=util.getMatchingValuesByAll(this.fields,t,"class");return e&&e.length>0?e.slice():[]},Action.prototype.getFieldByType=function(t){var e=util.getMatchingValue(this._fieldsByType,t);return e?e[0]:void 0},Action.prototype.getFieldsByType=function(t){var e=util.getMatchingValue(this._fieldsByType,t);return e?e.slice():[]},module.exports=Action; | ||
},{"./Field":3,"./assert":5,"./util":6}],2:[function(require,module,exports){ | ||
"use strict";function Entity(t){var i=this;return(t=t||{})instanceof Entity?t:this instanceof Entity?("object"!==(void 0===t?"undefined":_typeof(t))&&(t=JSON.parse(t)),assert(void 0===t.rel||Array.isArray(t.rel),"entity.rel must be an array or undefined, got "+JSON.stringify(t.rel)),assert(void 0===t.title||"string"==typeof t.title,"entity.title must be a string or undefined, got "+JSON.stringify(t.title)),assert(void 0===t.type||"string"==typeof t.type,"entity.type must be a string or undefined, got "+JSON.stringify(t.type)),assert(void 0===t.properties||"object"===_typeof(t.properties),"entity.properties must be an object or undefined, got "+JSON.stringify(t.properties)),assert(void 0===t.class||Array.isArray(t.class),"entity.class must be an array or undefined, got "+JSON.stringify(t.class)),assert(void 0===t.actions||Array.isArray(t.actions),"entity.actions must be an array or undefined, got "+JSON.stringify(t.actions)),assert(void 0===t.links||Array.isArray(t.links),"entity.links must be an array or undefined, got "+JSON.stringify(t.links)),assert(void 0===t.entities||Array.isArray(t.entities),"entity.entities must be an array or undefined, got "+JSON.stringify(t.entities)),t.rel&&(this.rel=t.rel),t.title&&(this.title=t.title),t.type&&(this.type=t.type),t.properties&&(this.properties=t.properties),t.class&&(this.class=t.class),this._actionsByName={},this._actionsByClass={},this._actionsByMethod={},this._actionsByType={},t.actions&&(this.actions=[],t.actions.forEach(function(t){var e=new Action(t);i.actions.push(e),i._actionsByName[e.name]=e,e.method&&(i._actionsByMethod[e.method]=i._actionsByMethod[e.method]||[],i._actionsByMethod[e.method].push(e)),e.type&&(i._actionsByType[e.type]=i._actionsByType[e.type]||[],i._actionsByType[e.type].push(e)),e.class&&e.class.forEach(function(t){i._actionsByClass[t]=i._actionsByClass[t]||[],i._actionsByClass[t].push(e)})})),this._linksByRel={},this._linksByClass={},this._linksByType={},t.links&&(this.links=[],t.links.forEach(function(t){var e=new Link(t);i.links.push(e),e.rel.forEach(function(t){i._linksByRel[t]=i._linksByRel[t]||[],i._linksByRel[t].push(e)}),e.class&&e.class.forEach(function(t){i._linksByClass[t]=i._linksByClass[t]||[],i._linksByClass[t].push(e)}),e.type&&(i._linksByType[e.type]=i._linksByType[e.type]||[],i._linksByType[e.type].push(e))})),this._entitiesByRel={},this._entitiesByClass={},this._entitiesByType={},void(t.entities&&(this.entities=[],t.entities.forEach(function(t){assert(Array.isArray(t.rel),"sub-entities must have a rel array, got "+JSON.stringify(t.rel));var e=void 0;e="string"==typeof t.href?new Link(t):new Entity(t),i.entities.push(e),e.rel.forEach(function(t){i._entitiesByRel[t]=i._entitiesByRel[t]||[],i._entitiesByRel[t].push(e)}),e.class&&e.class.forEach(function(t){i._entitiesByClass[t]=i._entitiesByClass[t]||[],i._entitiesByClass[t].push(e)}),e.type&&(i._entitiesByType[e.type]=i._entitiesByType[e.type]||[],i._entitiesByType[e.type].push(e))})))):new Entity(t)}var _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},assert=require("./assert"),util=require("./util"),Action=require("./Action"),Link=require("./Link");Entity.prototype.hasAction=function(t){return this.hasActionByName(t)},Entity.prototype.hasActionByName=function(t){return util.hasProperty(this._actionsByName,t)},Entity.prototype.hasActionByClass=function(t){return util.hasProperty(this._actionsByClass,t)},Entity.prototype.hasActionByMethod=function(t){return util.hasProperty(this._actionsByMethod,t)},Entity.prototype.hasActionByType=function(t){return util.hasProperty(this._actionsByType,t)},Entity.prototype.hasClass=function(t){return this.class instanceof Array&&util.contains(this.class,t)},Entity.prototype.hasEntity=function(t){return this.hasSubEntityByRel(t)},Entity.prototype.hasEntityByRel=function(t){return this.hasSubEntityByRel(t)},Entity.prototype.hasSubEntityByRel=function(t){return util.hasProperty(this._entitiesByRel,t)},Entity.prototype.hasEntityByClass=function(t){return this.hasSubEntityByClass(t)},Entity.prototype.hasSubEntityByClass=function(t){return util.hasProperty(this._entitiesByClass,t)},Entity.prototype.hasEntityByType=function(t){return this.hasSubEntityByType(t)},Entity.prototype.hasSubEntityByType=function(t){return util.hasProperty(this._entitiesByType,t)},Entity.prototype.hasLink=function(t){return this.hasLinkByRel(t)},Entity.prototype.hasLinkByRel=function(t){return util.hasProperty(this._linksByRel,t)},Entity.prototype.hasLinkByClass=function(t){return util.hasProperty(this._linksByClass,t)},Entity.prototype.hasLinkByType=function(t){return util.hasProperty(this._linksByType,t)},Entity.prototype.hasProperty=function(t){return util.hasProperty(this,"properties")&&util.hasProperty(this.properties,t)},Entity.prototype.getAction=function(t){return this.getActionByName(t)},Entity.prototype.getActionByName=function(t){return util.getMatchingValue(this._actionsByName,t)},Entity.prototype.getActionByClass=function(t){var i=util.getMatchingValue(this._actionsByClass,t);return i?i[0]:void 0},Entity.prototype.getActionsByClass=function(t){var i=util.getMatchingValue(this._actionsByClass,t);return i?i.slice():[]},Entity.prototype.getActionByClasses=function(t){var i=util.getMatchingValuesByAll(this.actions,t,"class");return i&&i.length>0?i[0]:void 0},Entity.prototype.getActionsByClasses=function(t){var i=util.getMatchingValuesByAll(this.actions,t,"class");return i&&i.length>0?i.slice():[]},Entity.prototype.getActionByMethod=function(t){var i=util.getMatchingValue(this._actionsByMethod,t);return i?i[0]:void 0},Entity.prototype.getActionsByMethod=function(t){var i=util.getMatchingValue(this._actionsByMethod,t);return i?i.slice():[]},Entity.prototype.getActionByType=function(t){var i=util.getMatchingValue(this._actionsByType,t);return i?i[0]:void 0},Entity.prototype.getActionsByType=function(t){var i=util.getMatchingValue(this._actionsByType,t);return i?i.slice():[]},Entity.prototype.getLink=function(t){return this.getLinkByRel(t)},Entity.prototype.getLinks=function(t){return this.getLinksByRel(t)},Entity.prototype.getLinkByRel=function(t){var i=util.getMatchingValue(this._linksByRel,t);return i?i[0]:void 0},Entity.prototype.getLinksByRel=function(t){var i=util.getMatchingValue(this._linksByRel,t);return i?i.slice():[]},Entity.prototype.getLinkByRels=function(t){var i=util.getMatchingValuesByAll(this.links,t,"rel");return i&&i.length>0?i[0]:void 0},Entity.prototype.getLinksByRels=function(t){var i=util.getMatchingValuesByAll(this.links,t,"rel");return i&&i.length>0?i.slice():[]},Entity.prototype.getLinkByClass=function(t){var i=util.getMatchingValue(this._linksByClass,t);return i?i[0]:void 0},Entity.prototype.getLinksByClass=function(t){var i=util.getMatchingValue(this._linksByClass,t);return i?i.slice():[]},Entity.prototype.getLinkByClasses=function(t){var i=util.getMatchingValuesByAll(this.links,t,"class");return i&&i.length>0?i[0]:void 0},Entity.prototype.getLinksByClasses=function(t){var i=util.getMatchingValuesByAll(this.links,t,"class");return i&&i.length>0?i.slice():[]},Entity.prototype.getLinkByType=function(t){var i=util.getMatchingValue(this._linksByType,t);return i?i[0]:void 0},Entity.prototype.getLinksByType=function(t){var i=util.getMatchingValue(this._linksByType,t);return i?i.slice():[]},Entity.prototype.getSubEntity=function(t){return this.getSubEntityByRel(t)},Entity.prototype.getSubEntities=function(t){return this.getSubEntitiesByRel(t)},Entity.prototype.getSubEntityByRel=function(t){var i=util.getMatchingValue(this._entitiesByRel,t);return i?i[0]:void 0},Entity.prototype.getSubEntitiesByRel=function(t){var i=util.getMatchingValue(this._entitiesByRel,t);return i?i.slice():[]},Entity.prototype.getSubEntityByRels=function(t){var i=util.getMatchingValuesByAll(this.entities,t,"rel");return i&&i.length>0?i[0]:void 0},Entity.prototype.getSubEntitiesByRels=function(t){var i=util.getMatchingValuesByAll(this.entities,t,"rel");return i&&i.length>0?i.slice():[]},Entity.prototype.getSubEntityByClass=function(t){var i=util.getMatchingValue(this._entitiesByClass,t);return i?i[0]:void 0},Entity.prototype.getSubEntitiesByClass=function(t){var i=util.getMatchingValue(this._entitiesByClass,t);return i?i.slice():[]},Entity.prototype.getSubEntityByClasses=function(t){var i=util.getMatchingValuesByAll(this.entities,t,"class");return i&&i.length>0?i[0]:void 0},Entity.prototype.getSubEntitiesByClasses=function(t){var i=util.getMatchingValuesByAll(this.entities,t,"class");return i&&i.length>0?i.slice():[]},Entity.prototype.getSubEntityByType=function(t){var i=util.getMatchingValue(this._entitiesByType,t);return i?i[0]:void 0},Entity.prototype.getSubEntitiesByType=function(t){var i=util.getMatchingValue(this._entitiesByType,t);return i?i.slice():[]},module.exports=Entity; | ||
"use strict";function Entity(t){var i=this;return(t=t||{})instanceof Entity?t:this instanceof Entity?("object"!==(void 0===t?"undefined":_typeof(t))&&(t=JSON.parse(t)),assert(void 0===t.rel||Array.isArray(t.rel),"entity.rel must be an array or undefined, got "+JSON.stringify(t.rel)),assert(void 0===t.title||"string"==typeof t.title,"entity.title must be a string or undefined, got "+JSON.stringify(t.title)),assert(void 0===t.type||"string"==typeof t.type,"entity.type must be a string or undefined, got "+JSON.stringify(t.type)),assert(void 0===t.properties||"object"===_typeof(t.properties),"entity.properties must be an object or undefined, got "+JSON.stringify(t.properties)),assert(void 0===t.class||Array.isArray(t.class),"entity.class must be an array or undefined, got "+JSON.stringify(t.class)),assert(void 0===t.actions||Array.isArray(t.actions),"entity.actions must be an array or undefined, got "+JSON.stringify(t.actions)),assert(void 0===t.links||Array.isArray(t.links),"entity.links must be an array or undefined, got "+JSON.stringify(t.links)),assert(void 0===t.entities||Array.isArray(t.entities),"entity.entities must be an array or undefined, got "+JSON.stringify(t.entities)),t.rel&&(this.rel=t.rel),t.title&&(this.title=t.title),t.type&&(this.type=t.type),t.properties&&(this.properties=t.properties),t.class&&(this.class=t.class),this._actionsByName={},this._actionsByClass={},this._actionsByMethod={},this._actionsByType={},t.actions&&(this.actions=[],t.actions.forEach(function(t){var e=new Action(t);i.actions.push(e),i._actionsByName[e.name]=e,e.method&&(i._actionsByMethod[e.method]=i._actionsByMethod[e.method]||[],i._actionsByMethod[e.method].push(e)),e.type&&(i._actionsByType[e.type]=i._actionsByType[e.type]||[],i._actionsByType[e.type].push(e)),e.class&&e.class.forEach(function(t){i._actionsByClass[t]=i._actionsByClass[t]||[],i._actionsByClass[t].push(e)})})),this._linksByRel={},this._linksByClass={},this._linksByType={},t.links&&(this.links=[],t.links.forEach(function(t){var e=new Link(t);i.links.push(e),e.rel.forEach(function(t){i._linksByRel[t]=i._linksByRel[t]||[],i._linksByRel[t].push(e)}),e.class&&e.class.forEach(function(t){i._linksByClass[t]=i._linksByClass[t]||[],i._linksByClass[t].push(e)}),e.type&&(i._linksByType[e.type]=i._linksByType[e.type]||[],i._linksByType[e.type].push(e))})),this._entitiesByRel={},this._entitiesByClass={},this._entitiesByType={},void(t.entities&&(this.entities=[],t.entities.forEach(function(t){assert(Array.isArray(t.rel),"sub-entities must have a rel array, got "+JSON.stringify(t.rel));var e=void 0;e="string"==typeof t.href?new Link(t):new Entity(t),i.entities.push(e),e.rel.forEach(function(t){i._entitiesByRel[t]=i._entitiesByRel[t]||[],i._entitiesByRel[t].push(e)}),e.class&&e.class.forEach(function(t){i._entitiesByClass[t]=i._entitiesByClass[t]||[],i._entitiesByClass[t].push(e)}),e.type&&(i._entitiesByType[e.type]=i._entitiesByType[e.type]||[],i._entitiesByType[e.type].push(e))})))):new Entity(t)}var _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},assert=require("./assert"),util=require("./util"),Action=require("./Action"),Link=require("./Link");Entity.prototype.toJSON=function(){return{rel:this.rel,title:this.title,type:this.type,properties:this.properties,class:this.class,actions:this.actions,links:this.links,entities:this.entities}},Entity.prototype.hasAction=function(t){return this.hasActionByName(t)},Entity.prototype.hasActionByName=function(t){return util.hasProperty(this._actionsByName,t)},Entity.prototype.hasActionByClass=function(t){return util.hasProperty(this._actionsByClass,t)},Entity.prototype.hasActionByMethod=function(t){return util.hasProperty(this._actionsByMethod,t)},Entity.prototype.hasActionByType=function(t){return util.hasProperty(this._actionsByType,t)},Entity.prototype.hasClass=function(t){return this.class instanceof Array&&util.contains(this.class,t)},Entity.prototype.hasEntity=function(t){return this.hasSubEntityByRel(t)},Entity.prototype.hasEntityByRel=function(t){return this.hasSubEntityByRel(t)},Entity.prototype.hasSubEntityByRel=function(t){return util.hasProperty(this._entitiesByRel,t)},Entity.prototype.hasEntityByClass=function(t){return this.hasSubEntityByClass(t)},Entity.prototype.hasSubEntityByClass=function(t){return util.hasProperty(this._entitiesByClass,t)},Entity.prototype.hasEntityByType=function(t){return this.hasSubEntityByType(t)},Entity.prototype.hasSubEntityByType=function(t){return util.hasProperty(this._entitiesByType,t)},Entity.prototype.hasLink=function(t){return this.hasLinkByRel(t)},Entity.prototype.hasLinkByRel=function(t){return util.hasProperty(this._linksByRel,t)},Entity.prototype.hasLinkByClass=function(t){return util.hasProperty(this._linksByClass,t)},Entity.prototype.hasLinkByType=function(t){return util.hasProperty(this._linksByType,t)},Entity.prototype.hasProperty=function(t){return util.hasProperty(this,"properties")&&util.hasProperty(this.properties,t)},Entity.prototype.getAction=function(t){return this.getActionByName(t)},Entity.prototype.getActionByName=function(t){return util.getMatchingValue(this._actionsByName,t)},Entity.prototype.getActionByClass=function(t){var i=util.getMatchingValue(this._actionsByClass,t);return i?i[0]:void 0},Entity.prototype.getActionsByClass=function(t){var i=util.getMatchingValue(this._actionsByClass,t);return i?i.slice():[]},Entity.prototype.getActionByClasses=function(t){var i=util.getMatchingValuesByAll(this.actions,t,"class");return i&&i.length>0?i[0]:void 0},Entity.prototype.getActionsByClasses=function(t){var i=util.getMatchingValuesByAll(this.actions,t,"class");return i&&i.length>0?i.slice():[]},Entity.prototype.getActionByMethod=function(t){var i=util.getMatchingValue(this._actionsByMethod,t);return i?i[0]:void 0},Entity.prototype.getActionsByMethod=function(t){var i=util.getMatchingValue(this._actionsByMethod,t);return i?i.slice():[]},Entity.prototype.getActionByType=function(t){var i=util.getMatchingValue(this._actionsByType,t);return i?i[0]:void 0},Entity.prototype.getActionsByType=function(t){var i=util.getMatchingValue(this._actionsByType,t);return i?i.slice():[]},Entity.prototype.getLink=function(t){return this.getLinkByRel(t)},Entity.prototype.getLinks=function(t){return this.getLinksByRel(t)},Entity.prototype.getLinkByRel=function(t){var i=util.getMatchingValue(this._linksByRel,t);return i?i[0]:void 0},Entity.prototype.getLinksByRel=function(t){var i=util.getMatchingValue(this._linksByRel,t);return i?i.slice():[]},Entity.prototype.getLinkByRels=function(t){var i=util.getMatchingValuesByAll(this.links,t,"rel");return i&&i.length>0?i[0]:void 0},Entity.prototype.getLinksByRels=function(t){var i=util.getMatchingValuesByAll(this.links,t,"rel");return i&&i.length>0?i.slice():[]},Entity.prototype.getLinkByClass=function(t){var i=util.getMatchingValue(this._linksByClass,t);return i?i[0]:void 0},Entity.prototype.getLinksByClass=function(t){var i=util.getMatchingValue(this._linksByClass,t);return i?i.slice():[]},Entity.prototype.getLinkByClasses=function(t){var i=util.getMatchingValuesByAll(this.links,t,"class");return i&&i.length>0?i[0]:void 0},Entity.prototype.getLinksByClasses=function(t){var i=util.getMatchingValuesByAll(this.links,t,"class");return i&&i.length>0?i.slice():[]},Entity.prototype.getLinkByType=function(t){var i=util.getMatchingValue(this._linksByType,t);return i?i[0]:void 0},Entity.prototype.getLinksByType=function(t){var i=util.getMatchingValue(this._linksByType,t);return i?i.slice():[]},Entity.prototype.getSubEntity=function(t){return this.getSubEntityByRel(t)},Entity.prototype.getSubEntities=function(t){return this.getSubEntitiesByRel(t)},Entity.prototype.getSubEntityByRel=function(t){var i=util.getMatchingValue(this._entitiesByRel,t);return i?i[0]:void 0},Entity.prototype.getSubEntitiesByRel=function(t){var i=util.getMatchingValue(this._entitiesByRel,t);return i?i.slice():[]},Entity.prototype.getSubEntityByRels=function(t){var i=util.getMatchingValuesByAll(this.entities,t,"rel");return i&&i.length>0?i[0]:void 0},Entity.prototype.getSubEntitiesByRels=function(t){var i=util.getMatchingValuesByAll(this.entities,t,"rel");return i&&i.length>0?i.slice():[]},Entity.prototype.getSubEntityByClass=function(t){var i=util.getMatchingValue(this._entitiesByClass,t);return i?i[0]:void 0},Entity.prototype.getSubEntitiesByClass=function(t){var i=util.getMatchingValue(this._entitiesByClass,t);return i?i.slice():[]},Entity.prototype.getSubEntityByClasses=function(t){var i=util.getMatchingValuesByAll(this.entities,t,"class");return i&&i.length>0?i[0]:void 0},Entity.prototype.getSubEntitiesByClasses=function(t){var i=util.getMatchingValuesByAll(this.entities,t,"class");return i&&i.length>0?i.slice():[]},Entity.prototype.getSubEntityByType=function(t){var i=util.getMatchingValue(this._entitiesByType,t);return i?i[0]:void 0},Entity.prototype.getSubEntitiesByType=function(t){var i=util.getMatchingValue(this._entitiesByType,t);return i?i.slice():[]},module.exports=Entity; | ||
},{"./Action":1,"./Link":4,"./assert":5,"./util":6}],3:[function(require,module,exports){ | ||
"use strict";function Field(t){return t instanceof Field?t:this instanceof Field?(assert("object"===(void 0===t?"undefined":_typeof(t)),"field must be an object, got "+JSON.stringify(t)),assert("string"==typeof t.name,"field.name must be a string, got "+JSON.stringify(t.name)),assert(void 0===t.class||Array.isArray(t.class),"field.class must be an array or undefined, got "+JSON.stringify(t.class)),assert(void 0===t.type||"string"==typeof t.type&&VALID_TYPES.indexOf(t.type.toLowerCase())>-1,"field.type must be a valid field type string or undefined, got "+JSON.stringify(t.type)),assert(void 0===t.title||"string"==typeof t.title,"field.title must be a string or undefined, got "+JSON.stringify(t.title)),this.name=t.name,t.class&&(this.class=t.class),t.type&&(this.type=t.type),t.hasOwnProperty("value")&&(this.value=t.value),void(t.title&&(this.title=t.title))):new Field(t)}var _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},assert=require("./assert"),util=require("./util"),VALID_TYPES=["hidden","text","search","tel","url","email","password","datetime","date","month","week","time","datetime-local","number","range","color","checkbox","radio","file"];Field.prototype.hasClass=function(t){return this.class instanceof Array&&util.contains(this.class,t)},module.exports=Field; | ||
"use strict";function Field(t){return t instanceof Field?t:this instanceof Field?(assert("object"===(void 0===t?"undefined":_typeof(t)),"field must be an object, got "+JSON.stringify(t)),assert("string"==typeof t.name,"field.name must be a string, got "+JSON.stringify(t.name)),assert(void 0===t.class||Array.isArray(t.class),"field.class must be an array or undefined, got "+JSON.stringify(t.class)),assert(void 0===t.type||"string"==typeof t.type&&VALID_TYPES.indexOf(t.type.toLowerCase())>-1,"field.type must be a valid field type string or undefined, got "+JSON.stringify(t.type)),assert(void 0===t.title||"string"==typeof t.title,"field.title must be a string or undefined, got "+JSON.stringify(t.title)),this.name=t.name,t.class&&(this.class=t.class),t.type&&(this.type=t.type),t.hasOwnProperty("value")&&(this.value=t.value),void(t.title&&(this.title=t.title))):new Field(t)}var _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},assert=require("./assert"),util=require("./util"),VALID_TYPES=["hidden","text","search","tel","url","email","password","datetime","date","month","week","time","datetime-local","number","range","color","checkbox","radio","file"];Field.prototype.toJSON=function(){return{name:this.name,class:this.class,type:this.type,value:this.value,title:this.title}},Field.prototype.hasClass=function(t){return this.class instanceof Array&&util.contains(this.class,t)},module.exports=Field; | ||
},{"./assert":5,"./util":6}],4:[function(require,module,exports){ | ||
"use strict";function Link(t){return t instanceof Link?t:this instanceof Link?(assert("object"===(void 0===t?"undefined":_typeof(t)),"link must be an object, got "+JSON.stringify(t)),assert(Array.isArray(t.rel),"link.rel must be an array, got "+JSON.stringify(t.rel)),assert("string"==typeof t.href,"link.href must be a string, got "+JSON.stringify(t.href)),assert(void 0===t.class||Array.isArray(t.class),"link.class must be an array or undefined, got "+JSON.stringify(t.class)),assert(void 0===t.title||"string"==typeof t.title,"link.title must be a string or undefined, got "+JSON.stringify(t.title)),assert(void 0===t.type||"string"==typeof t.type,"link.type must be a string or undefined, got "+JSON.stringify(t.type)),this.rel=t.rel,this.href=t.href,t.class&&(this.class=t.class),t.title&&(this.title=t.title),void(t.type&&(this.type=t.type))):new Link(t)}var _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},assert=require("./assert"),util=require("./util");Link.prototype.hasClass=function(t){return this.class instanceof Array&&util.contains(this.class,t)},module.exports=Link; | ||
"use strict";function Link(t){return t instanceof Link?t:this instanceof Link?(assert("object"===(void 0===t?"undefined":_typeof(t)),"link must be an object, got "+JSON.stringify(t)),assert(Array.isArray(t.rel),"link.rel must be an array, got "+JSON.stringify(t.rel)),assert("string"==typeof t.href,"link.href must be a string, got "+JSON.stringify(t.href)),assert(void 0===t.class||Array.isArray(t.class),"link.class must be an array or undefined, got "+JSON.stringify(t.class)),assert(void 0===t.title||"string"==typeof t.title,"link.title must be a string or undefined, got "+JSON.stringify(t.title)),assert(void 0===t.type||"string"==typeof t.type,"link.type must be a string or undefined, got "+JSON.stringify(t.type)),this.rel=t.rel,this.href=t.href,t.class&&(this.class=t.class),t.title&&(this.title=t.title),void(t.type&&(this.type=t.type))):new Link(t)}var _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},assert=require("./assert"),util=require("./util");Link.prototype.toJSON=function(){return{rel:this.rel,href:this.href,class:this.class,title:this.title,type:this.type}},Link.prototype.hasClass=function(t){return this.class instanceof Array&&util.contains(this.class,t)},module.exports=Link; | ||
@@ -20,2 +20,2 @@ },{"./assert":5,"./util":6}],5:[function(require,module,exports){ | ||
},{}]},{},[2])(2) | ||
}); | ||
}); |
{ | ||
"name": "siren-parser", | ||
"version": "7.0.0", | ||
"version": "7.1.0", | ||
"description": "Pretty much the opposite of dominicbarnes/node-siren-writer", | ||
@@ -11,3 +11,3 @@ "main": "src/Entity.js", | ||
"test": "npm run lint && npm run test-no-style", | ||
"test-no-style": "export NODE_ENV=test; istanbul cover --source-map --dir ./coverage/unit --root src/ node_modules/.bin/_mocha -- --recursive ./test", | ||
"test-no-style": "cross-env NODE_ENV=test istanbul cover --source-map --dir ./coverage/unit --root src/ node_modules/mocha/bin/_mocha -- --recursive ./test", | ||
"posttest": "istanbul report text-summary lcov", | ||
@@ -45,2 +45,3 @@ "report-cov": "istanbul report lcovonly && coveralls < ./coverage/lcov.info", | ||
"coveralls": "^2.11.4", | ||
"cross-env": "^5.0.5", | ||
"deumdify": "^1.2.4", | ||
@@ -47,0 +48,0 @@ "eslint": "^3.18.0", |
@@ -69,7 +69,17 @@ 'use strict'; | ||
}); | ||
this.fields = action.fields; | ||
} | ||
} | ||
Action.prototype.toJSON = function() { | ||
return { | ||
name: this.name, | ||
href: this.href, | ||
class: this.class, | ||
method: this.method, | ||
title: this.title, | ||
type: this.type, | ||
fields: this.fields | ||
}; | ||
}; | ||
Action.prototype.hasClass = function(cls) { | ||
@@ -76,0 +86,0 @@ return this.class instanceof Array && util.contains(this.class, cls); |
@@ -159,2 +159,15 @@ 'use strict'; | ||
Entity.prototype.toJSON = function() { | ||
return { | ||
rel: this.rel, | ||
title: this.title, | ||
type: this.type, | ||
properties: this.properties, | ||
class: this.class, | ||
actions: this.actions, | ||
links: this.links, | ||
entities: this.entities | ||
}; | ||
}; | ||
Entity.prototype.hasAction = function(actionName) { | ||
@@ -161,0 +174,0 @@ return this.hasActionByName(actionName); |
@@ -66,2 +66,12 @@ 'use strict'; | ||
Field.prototype.toJSON = function() { | ||
return { | ||
name: this.name, | ||
class: this.class, | ||
type: this.type, | ||
value: this.value, | ||
title: this.title | ||
}; | ||
}; | ||
Field.prototype.hasClass = function(cls) { | ||
@@ -68,0 +78,0 @@ return this.class instanceof Array && util.contains(this.class, cls); |
@@ -41,2 +41,12 @@ 'use strict'; | ||
Link.prototype.toJSON = function() { | ||
return { | ||
rel: this.rel, | ||
href: this.href, | ||
class: this.class, | ||
title: this.title, | ||
type: this.type | ||
}; | ||
}; | ||
Link.prototype.hasClass = function(cls) { | ||
@@ -43,0 +53,0 @@ return this.class instanceof Array && util.contains(this.class, cls); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
76707
885
19