rdf-object
Advanced tools
Comparing version 1.4.2 to 1.5.0
# Changelog | ||
All notable changes to this project will be documented in this file. | ||
<a name="v1.5.0"></a> | ||
## [v1.5.0](https://github.com/rubensworks/rdf-object.js/compare/v1.4.2...v1.5.0) - 2020-11-17 | ||
### Added | ||
* [Allow compacted string parameters in Resource#isA](https://github.com/rubensworks/rdf-object.js/commit/d63d9b63dcd9acaf0191d94ae3af77463c5abdf4) | ||
<a name="v1.4.2"></a> | ||
@@ -5,0 +11,0 @@ ## [v1.4.2](https://github.com/rubensworks/rdf-object.js/compare/v1.4.1...v1.4.2) - 2020-11-10 |
@@ -7,2 +7,3 @@ import { JsonLdContextNormalized } from 'jsonld-context-parser'; | ||
export declare class Resource { | ||
private readonly context; | ||
readonly term: RDF.Term; | ||
@@ -33,6 +34,6 @@ readonly predicates: Resource[]; | ||
* | ||
* @param {Term} type An RDF term. | ||
* @param {RDF.Term | string} type An RDF term or a compacted term string. | ||
* @return {boolean} If this resource is of the given type. | ||
*/ | ||
isA(type: RDF.Term): boolean; | ||
isA(type: RDF.Term | string): boolean; | ||
/** | ||
@@ -39,0 +40,0 @@ * Add a property to the given resource. |
@@ -13,6 +13,7 @@ "use strict"; | ||
constructor(args) { | ||
this.context = args.context || new jsonld_context_parser_1.JsonLdContextNormalized({}); | ||
this.term = args.term; | ||
this.predicates = []; | ||
this.propertiesUri = {}; | ||
this.properties = new Proxy(this.propertiesUri, new ShortcutPropertyHandler_1.ShortcutPropertyHandler(args.context || new jsonld_context_parser_1.JsonLdContextNormalized({}))); | ||
this.properties = new Proxy(this.propertiesUri, new ShortcutPropertyHandler_1.ShortcutPropertyHandler(this.context)); | ||
this.property = new Proxy(this.properties, new SingularPropertyHandler_1.SingularPropertyHandler()); | ||
@@ -42,6 +43,14 @@ } | ||
* | ||
* @param {Term} type An RDF term. | ||
* @param {RDF.Term | string} type An RDF term or a compacted term string. | ||
* @return {boolean} If this resource is of the given type. | ||
*/ | ||
isA(type) { | ||
// Consider strings compacted terms | ||
if (typeof type === 'string') { | ||
const typeExpanded = this.context.expandTerm(type, true); | ||
if (!typeExpanded) { | ||
return false; | ||
} | ||
type = rdf_string_1.stringToTerm(typeExpanded); | ||
} | ||
if (type.equals(this.term)) { | ||
@@ -48,0 +57,0 @@ return true; |
{ | ||
"name": "rdf-object", | ||
"version": "1.4.2", | ||
"version": "1.5.0", | ||
"description": "Loads RDF as JSON objects", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
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
40443
592