semantic-network
Version:
A utility library for manipulating a list of links that form a semantic interface to a network of resources.
40 lines • 985 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.instanceOfUri = exports.instanceOfUriList = void 0;
/**
* A guard to detect whether the object is a {@link UriList}
*
* @param object
* @returns whether the object is an instance on the interface
*/
function instanceOfUriList(object) {
if (Array.isArray(object)) {
return object.every(instanceOfUri);
}
else {
return false;
}
}
exports.instanceOfUriList = instanceOfUriList;
/**
* A guard to detect whether the object is a {@link Uri}
*
* @param object
* @returns whether the object is an instance on the interface
*/
function instanceOfUri(object) {
if (typeof object === 'string') {
try {
new URL(object);
return true;
}
catch (error) {
return false;
}
}
else {
return false;
}
}
exports.instanceOfUri = instanceOfUri;
//# sourceMappingURL=instanceOfUriList.js.map