Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
/*! @license MIT ©2014-2016 Ruben Verborgh, Ghent University - imec */
var N3 = require('n3'),
_ = require('lodash');
var genidMatcher = /^https?:\/\/[^\/]+\/\.well-known\/genid\/([^]+)$/;
/**
* Utility functions for working with URIs, triples, variables, and patterns.
* @exports RdfUtil
* @extends N3.Util
*/
var util = module.exports = new N3.Util({});
/* Methods for URIs */
/** Checks whether two URIs are equal after decoding, to make up for encoding differences. **/
util.decodedURIEquals = function (URIa, URIb) {
if (URIa === URIb) return true;
try { return decodeURI(URIa) === decodeURI(URIb); }
catch (error) { return false; }
};
/** Transforms a skolemized URI into a blank node. */
util.deskolemize = function (URI) {
return URI && URI.replace(genidMatcher, function (URI, id) {
return '_:' + id.replace(/\W/g, '_');
});
};
if (quad) {
const newQuad = {}
for (let [whichNode, n3NodeText] of iterObj(quad)) {
let nodeVal
if (N3.Util.isIRI(n3NodeText)) {
nodeVal = Node({ termType: 'NamedNode', value: n3NodeText })
} else if (N3.Util.isLiteral(n3NodeText)) {
const language = (N3.Util.getLiteralLanguage(n3NodeText))
const datatype = (N3.Util.getLiteralType(n3NodeText))
const metaData = {
language: language || null,
datatype: datatype !== STR_TYPE
? datatype
: null
}
nodeVal = Node({ termType: 'Literal', value: N3.Util.getLiteralValue(n3NodeText), ...metaData })
} else if (N3.Util.isBlank(n3NodeText)) {
nodeVal = Node({ termType: 'BlankNode', value: n3NodeText })
}
newQuad[whichNode] = nodeVal
}
if (graphName && !newQuad.graph) {
newQuad.graph = Node({ termType: 'NamedNode', value: graphName })
}
quads.push(Quad(newQuad))
} else {
resolve(Graph.fromQuads(quads))
}
})
})
import Reflux from 'reflux'
import _ from 'lodash'
import N3 from 'n3'
import HTTPAgent from 'lib/agents/http.js'
import Util from 'lib/util.js'
import {Parser, Writer} from 'lib/rdf.js'
import {DC, RDF, SIOC} from 'lib/namespaces.js'
let N3Util = N3.Util
let http = new HTTPAgent()
import CommentsActions from 'actions/comments'
let {load, create, remove} = CommentsActions
let comments = []
export default Reflux.createStore({
listenables: CommentsActions,
getInitialState() {
return {
loading: true,
items: []
}
parser.parse(text, function (error, quad) {
if (error) { reject(error) }
if (quad) {
const newQuad = {}
for (let [whichNode, n3NodeText] of iterObj(quad)) {
let nodeVal
if (N3.Util.isIRI(n3NodeText)) {
nodeVal = Node({ termType: 'NamedNode', value: n3NodeText })
} else if (N3.Util.isLiteral(n3NodeText)) {
const language = (N3.Util.getLiteralLanguage(n3NodeText))
const datatype = (N3.Util.getLiteralType(n3NodeText))
const metaData = {
language: language || null,
datatype: datatype !== STR_TYPE
? datatype
: null
}
nodeVal = Node({ termType: 'Literal', value: N3.Util.getLiteralValue(n3NodeText), ...metaData })
} else if (N3.Util.isBlank(n3NodeText)) {
nodeVal = Node({ termType: 'BlankNode', value: n3NodeText })
}
newQuad[whichNode] = nodeVal
}