ChemPal Documentation - v1.6.0
    Preparing search index...
    • Read a node's @type as a string array. An item may declare several types at once (schema.org uses multiple inheritance — something can be both a Book and a Product), and @type may be absent, so this always returns an array.

      Parameters

      Returns string[]

      The declared types as strings; [] when @type is missing.

      typeList({ '@type': 'Product' });            // ['Product']
      typeList({ '@type': ['Book', 'Product'] }); // ['Book', 'Product']
      typeList({ name: 'untyped' }); // []
      export function typeList(node: JsonObject): string[] {
      return toArray(node['@type']).filter((t): t is string => typeof t === 'string');
      }