UNPKG

semantic-network

Version:

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

26 lines 1.03 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.instanceOfCollection = void 0; var semantic_link_1 = require("semantic-link"); var instanceOfForm_1 = require("./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 */ function instanceOfCollection(object) { if ((0, semantic_link_1.instanceOfLinkedRepresentation)(object)) { if ('items' in object) { var anObject = object; if (Array.isArray(anObject.items)) { return !(0, instanceOfForm_1.instanceOfForm)(object); } } } return false; } exports.instanceOfCollection = instanceOfCollection; //# sourceMappingURL=instanceOfCollection.js.map