Constructor
new N3FileService()
- Source:
The constructor initializes our N3 parsers and sets the location for storing temporary files
Methods
(async) appendN3stringToFile(file, n3string) → {Promise}
- Source:
Adds an N3-string to existing file
Parameters:
Name | Type | Description |
---|---|---|
file |
String | Path to the file were appending to |
n3string |
String | N3-string to be added to the file |
Returns:
Promise that resolves when the I/O has finished
- Type
- Promise
(async) deleteContent(path) → {Promise}
- Source:
Deletes all content from a file
Parameters:
Name | Type | Description |
---|---|---|
path |
String | Path to the file |
Returns:
- Type
- Promise
(async) fileToQuads(file) → {Array}
- Source:
Convert contents of n3 file to an array of usable quad objects.
Parameters:
Name | Type | Description |
---|---|---|
file |
String | Name of the file we're trying to parse |
Returns:
- Array of Quads.
- Type
- Array
(async) fileToString(file) → {String}
- Source:
Reads the contents of a file
Parameters:
Name | Type | Description |
---|---|---|
file |
String | Name of the file we're trying to parse |
Returns:
- Contents of file
- Type
- String
isRDFFile(file) → {Boolean}
- Source:
Checks if file is an RDF file ('.ttl','.n3','.rdf').
Parameters:
Name | Type | Description |
---|---|---|
file |
String | Path to the file |
Returns:
- Returns true if the file is an RDF-file.
- Type
- Boolean
(async) newFile(path) → {Promise}
- Source:
Creates a new file or opens it if it already exists
!!File handle must be closed or it might leak
Uses NodeJS's fs.promises.open
.
Parameters:
Name | Type | Description |
---|---|---|
path |
String | Path to the file were trying to create |
Returns:
- Promise that resolves to the file handle of the file
- Type
- Promise
(async) prefixesFromFile(file) → {Object}
- Source:
Retrieves the prefixes from a file as json.
Parameters:
Name | Type | Description |
---|---|---|
file |
String | Name of the file to be read. |
Returns:
- Prefixes as key-value pairs
- Type
- Object
prefixesFromString(n3string) → {Object}
- Source:
Retrieves the prefixes from an n3 string, returns prefixes as json
Parameters:
Name | Type | Description |
---|---|---|
n3string |
String |
Returns:
- Prefixes as key-value pairs
- Type
- Object
prefixesFromStringAsString(n3string) → {String}
- Source:
Retrieve prefixes from n3string as string.
Parameters:
Name | Type | Description |
---|---|---|
n3string |
String |
Returns:
Single string containing all prefixes
- Type
- String
(async) quadsToString(quads, prefixes) → {String}
- Source:
Converts array of quad objects to an n3string
Parameters:
Name | Type | Description |
---|---|---|
quads |
Array | Quads to convert |
prefixes |
Object | Object containing all necessary prefixes as key-value pairs |
Returns:
- Equivalent N3-string of the input quads
- Type
- String
(async) quadsToTempFile(quads, prefixes) → {String}
- Source:
Generate a temporary file and write the specified quads to the file
!!Needs to be manually unlinked after use
Parameters:
Name | Type | Description |
---|---|---|
quads |
Array | Quads to be written |
prefixes |
Object | Object containing all necessary prefixes as key-value pairs |
Returns:
the filepath relative to the server root
- Type
- String
stringToJSONLD(n3string) → {String}
- Source:
Convert contents of n3 string to a JSONLD string
Parameters:
Name | Type | Description |
---|---|---|
n3string |
String |
Returns:
Equivalent JSONLD of the input
- Type
- String
stringToQuads(n3string)
- Source:
Convert contents of an N3-string to an array of usable quad objects.
Parameters:
Name | Type | Description |
---|---|---|
n3string |
String | N3-string to parse |
|
Array | Array of Quads |
(async) writeQuadsToFile(file, quads, prefixes) → {Promise}
- Source:
Writes an array of quads to an n3 file. This will overwrite the file losing any previous contents
Parameters:
Name | Type | Description |
---|---|---|
file |
String | Name of the file were writing to |
quads |
Array | List of Quads to be written |
prefixes |
Object | Object containing all necessary prefixes as key-value pairs |
Returns:
- Type
- Promise
(async) writeStringToFile(file, n3string) → {Promise}
- Source:
Writes an n3string to an n3 file. This will overwrite the file losing any previous contents
Parameters:
Name | Type | Description |
---|---|---|
file |
String | Name of the file were writing to |
n3string |
String | New contents of the file |
Returns:
- Type
- Promise