siren-parser
Advanced tools
Comparing version 6.1.0 to 6.2.1
{ | ||
"name": "siren-parser", | ||
"version": "6.1.0", | ||
"version": "6.2.1", | ||
"description": "Pretty much the opposite of dominicbarnes/node-siren-writer", | ||
@@ -5,0 +5,0 @@ "main": "src/Entity.js", |
@@ -9,18 +9,24 @@ # node-siren-parser | ||
There are two ways to use `node-siren-parser`'s functionality. You can install it from npm using | ||
There are two ways to use `node-siren-parser`'s functionality. | ||
```bash | ||
npm install siren-parser | ||
``` | ||
1. You can install it from npm using | ||
```bash | ||
npm install siren-parser | ||
``` | ||
and then `require` it as you would any other npm package. | ||
and then `require` it as you would any other npm package. Alternatively, the parser is browserified and stored on the Brightspace CDN for client-side usage, e.g. | ||
2. The parser is browserified and stored on the Brightspace CDN for client-side usage | ||
```html | ||
<script src="https://s.brightspace.com/lib/siren-parser/{version}/siren-parser.js"></script> | ||
<script> | ||
var parsedEntity = window.D2L.Hypermedia.Siren.Parse('{"class":["foo","bar"]}'); | ||
</script> | ||
``` | ||
An alternate bundle of the siren parser is available that is exposed as a property of the global object. | ||
```html | ||
<script src="https://s.brightspace.com/lib/siren-parser/{version}/siren-parser-global.js"></script> | ||
``` | ||
The client-side code will still use the `window.D2L.Hypermedia.Siren` object, but this addresses the risk of collisions with other modules on the page that are exposed by browserify's standalone UMD bundle. | ||
```html | ||
<script src="https://s.brightspace.com/lib/siren-parser/{version}/siren-parser.js"></script> | ||
<script> | ||
var parsedEntity = window.D2L.Hypermedia.Siren.Parse('{"class":["foo","bar"]}'); | ||
</script> | ||
``` | ||
## API | ||
@@ -127,9 +133,9 @@ | ||
* `hasActionByName(name)` (`hasAction(name)`) - returns true if any action on the entity has an action named `name` | ||
* `hasActionByName(name)` | ||
* `hasActionByClass(class)` | ||
* `hasClass(class)` | ||
* `hasEntityByRel(rel)` (`hasEntity(rel)`) | ||
* `hasEntityByClass(class)` | ||
* `hasEntityByType(type)` | ||
* `hasLinkByRel(rel)` (`hasLink(rel)`) | ||
* `hasSubEntityByRel(rel)` | ||
* `hasSubEntityByClass(class)` | ||
* `hasSubEntityByType(type)` | ||
* `hasLinkByRel(rel)` | ||
* `hasLinkByClass(class)` | ||
@@ -142,4 +148,4 @@ * `hasLinkByType(type)` | ||
resource.hasClass('inner'); // false | ||
resource.hasEntityByRel('child'); // true | ||
resource.hasEntityByType('child'); // false | ||
resource.hasSubEntityByRel('child'); // true | ||
resource.hasSubEntityByType('child'); // false | ||
resource.hasLinkByRel('crazy'); // true | ||
@@ -153,5 +159,5 @@ resource.hasProperty('three'); // false | ||
* `getActionByName(name)` (`getAction(name)`) - returns [Action](#action) or undefined | ||
* `getActionByName(name)` - returns [Action](#action) or undefined | ||
* `getActionByClass(class)` - returns [Action](#action) or undefined | ||
* `getLinkByRel(rel)` (`getLink(rel)`) - returns [Link](#link) or undefined | ||
* `getLinkByRel(rel)` - returns [Link](#link) or undefined | ||
* `getLinkByClass(class)` - returns [Link](#link) or undefined | ||
@@ -163,6 +169,6 @@ * `getLinkByType(type)` - returns [Link](#link) or undefined | ||
* `getActionsByClass(class)` - returns Array of [Actions](#action) (empty Array if none match) | ||
* `getLinksByRel(rel)` (`getLinks(rel)`) - returns Array of [Links](#link) (empty Array if none match) | ||
* `getLinksByRel(rel)` - returns Array of [Links](#link) (empty Array if none match) | ||
* `getLinksByClass(class)` - returns Array of [Links](#link) (empty Array if none match) | ||
* `getLinksByType(type)` - returns Array of [Links](#link) (empty Array if none match) | ||
* `getSubEntitiesByRel(rel)` (`getSubEntities(rel)`) - returns Array of [Entities](#entity) (empty Array if none match) | ||
* `getSubEntitiesByRel(rel)` - returns Array of [Entities](#entity) (empty Array if none match) | ||
* `getSubEntitiesByClass(class)` - returns Array of [Entities](#entity) (empty Array if none match) | ||
@@ -169,0 +175,0 @@ * `getSubEntitiesByType(type)` - returns Array of [Entities](#entity) (empty Array if none match) |
@@ -183,6 +183,10 @@ 'use strict'; | ||
Entity.prototype.hasEntity = function(entityRel) { | ||
return this.hasEntityByRel(entityRel); | ||
return this.hasSubEntityByRel(entityRel); | ||
}; | ||
Entity.prototype.hasEntityByRel = function(entityRel) { | ||
return this.hasSubEntityByRel(entityRel); | ||
}; | ||
Entity.prototype.hasSubEntityByRel = function(entityRel) { | ||
return util.hasProperty(this._entitiesByRel, entityRel); | ||
@@ -192,2 +196,6 @@ }; | ||
Entity.prototype.hasEntityByClass = function(entityClass) { | ||
return this.hasSubEntityByClass(entityClass); | ||
}; | ||
Entity.prototype.hasSubEntityByClass = function(entityClass) { | ||
return util.hasProperty(this._entitiesByClass, entityClass); | ||
@@ -197,2 +205,6 @@ }; | ||
Entity.prototype.hasEntityByType = function(entityType) { | ||
return this.hasSubEntityByType(entityType); | ||
}; | ||
Entity.prototype.hasSubEntityByType = function(entityType) { | ||
return util.hasProperty(this._entitiesByType, entityType); | ||
@@ -199,0 +211,0 @@ }; |
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
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
0
335
0
51482
14
703