forked from linkeddata/rdflib.js
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcore.ts
More file actions
91 lines (82 loc) · 2.45 KB
/
core.ts
File metadata and controls
91 lines (82 loc) · 2.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
/**
* Core RDF primitives - no network dependencies, no heavy parsers
*
* This module provides the essential RDF data structures without
* pulling in Fetcher, UpdateManager, serializers, or format-specific parsers.
*
* Bundle size: ~30KB minified (vs ~600KB for full rdflib)
*
* @example
* import { Store, NamedNode, Literal } from 'rdflib/core'
*
* const store = new Store()
* const subject = new NamedNode('http://example.org/subject')
* const predicate = new NamedNode('http://example.org/predicate')
* const object = new Literal('value')
* store.add(subject, predicate, object)
*
* @module core
*/
import BlankNode from './blank-node'
import Collection from './collection'
import Empty from './empty'
import Literal from './literal'
import NamedNode from './named-node'
import Namespace from './namespace'
import Node from './node'
import Statement from './statement'
import Variable from './variable'
import Formula from './formula-lite'
import Store from './store-lite'
import * as uri from './uri'
import CanonicalDataFactory from './factories/canonical-data-factory'
// Create factory functions using CanonicalDataFactory
const graph = () => new Store()
const lit = (value: string, lang?: string) => CanonicalDataFactory.literal(value, lang)
const st = (s: any, p: any, o: any, g?: any) => CanonicalDataFactory.quad(s, p, o, g)
const namedNode = (uri: string) => CanonicalDataFactory.namedNode(uri)
const variable = (name: string) => new Variable(name)
const blankNode = (id?: string) => CanonicalDataFactory.blankNode(id)
const defaultGraph = () => CanonicalDataFactory.defaultGraph()
const literal = (value: string, langOrDt?: string | NamedNode) => CanonicalDataFactory.literal(value, langOrDt)
const quad = (s: any, p: any, o: any, g?: any) => CanonicalDataFactory.quad(s, p, o, g)
const triple = (s: any, p: any, o: any) => CanonicalDataFactory.quad(s, p, o)
const term = Node.fromValue
const NextId = BlankNode.nextId
export * from './utils/terms'
export { termValue } from './utils/termValue'
export {
// Core classes
BlankNode,
Collection,
Empty,
Formula,
Literal,
NamedNode,
Namespace,
Node,
Statement,
Store,
Variable,
// Factories
CanonicalDataFactory,
CanonicalDataFactory as DataFactory,
// Utilities
uri,
term,
NextId,
// Alias
Store as IndexedFormula,
// RDFJS DataFactory interface
graph,
lit,
st,
namedNode,
blankNode,
defaultGraph,
literal,
quad,
triple,
variable,
namedNode as sym,
}