(graph, base, contentType)
| 136 | * @return {string} |
| 137 | */ |
| 138 | export function serialize (graph, base, contentType) { |
| 139 | return new Promise((resolve, reject) => { |
| 140 | try { |
| 141 | // target, kb, base, contentType, callback |
| 142 | $rdf.serialize(null, graph, base, contentType, function (err, result) { |
| 143 | if (err) { |
| 144 | return reject(err) |
| 145 | } |
| 146 | if (result === undefined) { |
| 147 | return reject(new Error('Error serializing the graph to ' + |
| 148 | contentType)) |
| 149 | } |
| 150 | |
| 151 | resolve(result) |
| 152 | }) |
| 153 | } catch (err) { |
| 154 | reject(err) |
| 155 | } |
| 156 | }) |
| 157 | } |
| 158 | |
| 159 | /** |
| 160 | * Translates common RDF content types to `rdflib` parser names. |
no outgoing calls
no test coverage detected