-
Notifications
You must be signed in to change notification settings - Fork 2
/
browser.js
30 lines (27 loc) · 1.05 KB
/
browser.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import { parseToJSON } from "./src/parser.js";
import axios from "axios";
/**
* Parses an OWL file to a json tree of nodes
* @param {string} url The URL of the owl file in raw format e.g "https://raw.githubusercontent.com/edamontology/edamontology/main/releases/EDAM_1.25.owl"
* @param {function} onSuccess The callback function to be executed after the tree is ready e.g (tree) => {console.log(tree)}
* @param {function} onError The callback function to be executed in case of an error
*/
const jsonTreeFromURL = (url, onSuccess, onError) => {
axios
.get(url)
.then((resp) => {
parseToJSON(resp.data, onSuccess);
})
.catch((err) => {
onError(err);
});
};
/**
* Parses an OWL file to a json tree of nodes
* @param {string} text the string containing the OWL file content
* @param {function} onSuccess The callback function to be executed after the tree is ready e.g (tree) => {console.log(tree)}
*/
const jsonTreeFromString = (text, onSuccess) => {
parseToJSON(text, onSuccess);
};
export { jsonTreeFromURL, jsonTreeFromString };