How to use clownface - 2 common examples

To help you get started, we’ve selected a few clownface examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github rdf2h / rdf2h / dist / rdf2h.js View on Github external
RDF2h.Renderee = function (rdf2h, graph, node, context) {
    if (!node) {
        throw "no node specficied!";
    }
    if (Object.prototype.toString.call(node) === '[object Array]') {
        throw "Renderee must be a single node";
    }
    this.rdf2h = rdf2h;
    this.graph = graph;
    this.node = node;
    this.context = context;
    var cf = clownface.Graph(graph);
    this.graphNode = cf.node(node);
};
github rdf2h / rdf2h / dist / rdf2h.js View on Github external
RDF2h.prototype.getRenderer = function (renderee) {
    var cf = clownface.Graph(this.matcherGraph);

    function matchPattern(cfTriplePattern) {
        function isThis(node) {
            return (node && (node.interfaceName === "NamedNode") &&
                    (node.toString() === "http://rdf2h.github.io/2015/rdf2h#this"));
        }
        var s = cfTriplePattern.out("http://rdf2h.github.io/2015/rdf2h#subject").nodes()[0];
        var p = cfTriplePattern.out("http://rdf2h.github.io/2015/rdf2h#predicate").nodes()[0];
        var o = cfTriplePattern.out("http://rdf2h.github.io/2015/rdf2h#object").nodes()[0];
        if (isThis(s)) {
            if (renderee.node.interfaceName === "Literal") {
                if (rdf.createNamedNode(RDF2h.resolveCurie("rdf:type")).equals(p)) {
                    return renderee.node.datatype.equals(o);
                }
            }
            return renderee.graphNode.out(p).nodes().some(function (e) {

clownface

Simple but powerful graph traversing library

MIT
Latest version published 7 months ago

Package Health Score

66 / 100
Full package analysis

Popular clownface functions