src/lib/Repositories/SolidLoaderRepository.js
/**
     * This method is in charge of returning the RDFjs source from the url.
     * @param {string} url: URL to inspect.
     * @returns {Promise}: promise that resolves with the RDFJSource.
     * Credits to https://github.com/pheyvaer/solid-chess
     */
This method is in charge of returning the RDFjs source from the url.
@param {string} url: URL to inspect.
@returns {Promise}: promise that resolves with the RDFJSource.
This method is in charge of returning the RDFjs source from the url . @param { string } url : URL to inspect . @returns { Promise } : promise that resolves with the RDFJSource .
_getRDFjsSourceFromUrl(url) {
        const deferred = Q.defer();
        this.fetch(url)
            .then(async (res) => {
                if (res.status === 404) {
                    deferred.reject(404);
                } else {
                    const body = await res.text();
                    const store = n3.Store();
                    const parser = n3.Parser({
                        baseIRI: res.url
                    });
                    parser.parse(body, (err, quad, prefixes) => {
                        if (err) {
                            deferred.reject();
                        } else if (quad) {
                            store.addQuad(quad);
                        } else {
                            const source = {
                                match: function(s, p, o, g) {
                                    return streamify(store.getQuads(s, p, o, g));
                                }
                            };
                            deferred.resolve(source);
                        }
                    });
                }
            });
        return deferred.promise;
    }
_getRDFjsSourceFromUrl ( url ) { const deferred = Q . defer ( ) ; this . fetch ( url ) . then ( async ( res ) => { if ( res . status === 404 ) { deferred . reject ( 404 ) ; } else { const body = await res . text ( ) ; const store = n3 . Store ( ) ; const parser = n3 . Parser ( { baseIRI : res . url } ) ; parser . parse ( body , ( err , quad , prefixes ) => { if ( err ) { deferred . reject ( ) ; } else if ( quad ) { store . addQuad ( quad ) ; } else { const source = { match : function ( s , p , o , g ) { return streamify ( store . getQuads ( s , p , o , g ) ) ; } } ; deferred . resolve ( source ) ; } } ) ; } } ) ; return deferred . promise ; }
This method is in charge of returning the RDFjs source from the url.
This method is in charge of returning the RDFjs source from the url .