UNPKG

semantic-network

Version:

A utility library for manipulating a list of links that form a semantic interface to a network of resources.

22 lines 844 B
import { instanceOfLinkedRepresentation } from 'semantic-link'; import { instanceOfForm } from './instanceOfForm'; /** * A guard to detect whether the object is a {@link CollectionRepresentation<T extends LinkedRepresentation>}. * A linked representation must be an object with an array called 'links'. * * @see https://stackoverflow.com/questions/14425568/interface-type-check-with-typescript * @param object * @returns whether the object is an instance on the interface */ export function instanceOfCollection(object) { if (instanceOfLinkedRepresentation(object)) { if ('items' in object) { const anObject = object; if (Array.isArray(anObject.items)) { return !instanceOfForm(object); } } } return false; } //# sourceMappingURL=instanceOfCollection.js.map