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