Skip to main content

Custom Library

A new library of methods only available in the extension is now available. This library is only included in the extension and is not available for scripts run using ipa-core, or for backend scripts running as part of the Object Model API or Datasources services.

Accessing the Custom Library in a Script

The library is available on the libraries object passed to the script.

async exampleScript(input, libraries, ctx, callback) {
let customLib = libraries.custom
}

Custom Library Methods

ttl2jsonld

Converts a Turtle (ttl) string to linked JSON.

Example

This example script reads a Turtle file from disk and converts it to linked JSON.

const { IafLocalFile } = libraries.UiUtils
const { ttl2jsonld } = libraries.custom

// select .ttl file from disk
let ttlFile = await IafLocalFile.selectFiles({accept: 'ttl', multiple: false})

// read the file contents as a string
let loadedFile = await IafLocalFile.loadFiles(ttlFile)

// convert to jsonld
const jsonld = ttl2jsonld.parse(loadedFile[0])