当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript Parser.parse方法代码示例

本文整理汇总了TypeScript中n3.Parser.parse方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Parser.parse方法的具体用法?TypeScript Parser.parse怎么用?TypeScript Parser.parse使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在n3.Parser的用法示例。


在下文中一共展示了Parser.parse方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: test_doc_rdf_sync_to_triples_1

function test_doc_rdf_sync_to_triples_1() {
    const parser: N3.N3Parser = new N3.Parser();
    const result = parser.parse(`@prefix c: <http://example.org/cartoons#>.
      c:Tom a c:Cat.
      c:Jerry a c:Mouse;
      c:smarterThan c:Tom.`);
    result.forEach((s) => console.log(s));
}
开发者ID:CNBoland,项目名称:DefinitelyTyped,代码行数:8,代码来源:n3-tests.ts

示例2: test_doc_rdf_to_triples_1

function test_doc_rdf_to_triples_1() {
    const parser: N3.N3Parser = new N3.Parser();
    parser.parse(`@prefix c: <http://example.org/cartoons#>.
        c:Tom a c:Cat.
        c:Jerry a c:Mouse;
                c:smarterThan c:Tom.`,
        (error: Error, quad: RDF.Quad, prefixes: N3.Prefixes) => {
            if (quad)
                console.log(quad.subject, quad.predicate, quad.object, quad.graph, '.');
            else
                console.log("# That's all, folks!", prefixes);
        });
}
开发者ID:pixelshaded,项目名称:DefinitelyTyped,代码行数:13,代码来源:n3-tests.ts

示例3: test_doc_rdf_stream_to_triples_1

function test_doc_rdf_stream_to_triples_1() {
    const parser: N3.N3Parser = new N3.Parser();
    parser.parse('abc', console.log);

    const streamParser: N3.N3StreamParser = N3.StreamParser();
    const quad: RDF.Quad = streamParser.read();
    const rdfStream = fs.createReadStream('cartoons.ttl');
    const pipedStreamParser: N3.N3StreamParser = rdfStream.pipe(streamParser);
    streamParser.pipe(new class SlowConsumer extends stream.Writable {
        constructor() {
            super({ objectMode: true });
            this._write = (quad: RDF.Quad, encoding, done) => {
                console.log(quad);
                setTimeout(done, 1000);
            };
        }
    }());
}
开发者ID:pixelshaded,项目名称:DefinitelyTyped,代码行数:18,代码来源:n3-tests.ts

示例4: test_doc_rdf_stream_to_triples_1

function test_doc_rdf_stream_to_triples_1() {
    interface QuadBnode extends N3.BaseQuad {
      subject: N3.BlankNode;
      predicate: N3.BlankNode;
      object: N3.BlankNode;
      graph: N3.BlankNode;
    }
    const parser: N3.N3Parser<QuadBnode> = new N3.Parser<QuadBnode>({factory: N3.DataFactory});
    parser.parse('abc', console.log);

    const streamParser: N3.N3StreamParser = N3.StreamParser();
    const quad: RDF.Quad = streamParser.read();
    const rdfStream = fs.createReadStream('cartoons.ttl');
    const pipedStreamParser: N3.N3StreamParser = rdfStream.pipe(streamParser);
    streamParser.pipe(new class SlowConsumer extends stream.Writable {
        constructor() {
            super({ objectMode: true });
            this._write = (quad: RDF.Quad, encoding, done) => {
                console.log(quad);
                setTimeout(done, 1000);
            };
        }
    }());
}
开发者ID:AlexGalays,项目名称:DefinitelyTyped,代码行数:24,代码来源:n3-tests.ts


注:本文中的n3.Parser.parse方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。