AI Architecture Analysis
This repository is indexed by RepoMind. By analyzing rdfjs/N3.js in our AI interface, you can instantly generate complete architecture diagrams, visualize control flows, and perform automated security audits across the entire codebase.
Our Agentic Context Augmented Generation (Agentic CAG) engine loads full source files into context on-demand, avoiding the fragmentation of traditional RAG systems. Ask questions about the architecture, dependencies, or specific features to see it in action.
Repository Overview (README excerpt)
Crawler viewLightning fast, asynchronous, streaming RDF for JavaScript The N3.js library is an implementation of the RDF.js low-level specification that lets you handle RDF 1.2 in JavaScript easily. It offers: • **Parsing** triples/quads from Turtle, TriG, N-Triples, N-Quads, and Notation3 (N3) • **Writing** triples/quads to Turtle, TriG, N-Triples, and N-Quads • **Storage** of triples/quads in memory Parsing and writing is: • 🎛 **asynchronous** – triples arrive as soon as possible • 🚰 **streaming** – streams are parsed as data comes in, so you can parse files larger than memory • ⚡️ **fast** – triples are flying out at high speeds Installation For Node.js, N3.js comes as an npm package. N3.js seamlessly works in browsers via webpack or browserify. If you're unfamiliar with these tools, you can read _webpack: Creating a Bundle – getting started_ or _Introduction to browserify_. You will need to create a "UMD bundle" and supply a name (e.g. with the option in browserify). You can also load it via CDN: Creating triples/quads N3.js follows the RDF.js low-level specification. will give you the factory functions to create triples and quads: In the rest of this document, we will treat “triples” and “quads” equally: we assume that a quad is simply a triple in a named or default graph. Parsing From an RDF document to quads transforms Turtle, TriG, N-Triples, or N-Quads document into quads through a callback: The callback's first argument is an optional error value, the second is a quad. If there are no more quads, the callback is invoked one last time with for and a hash of prefixes as third argument. Alternatively, an object can be supplied, where , and are used to listen for , and as follows: If no callbacks are provided, parsing happens synchronously returning an array of quads: By default, parses a permissive superset of Turtle, TriG, N-Triples, and N-Quads. For strict compatibility with any of those languages, pass a argument upon creation: Notation3 (N3) is supported _only_ through the argument: It is possible to provide the base IRI of the document that you want to parse. This is done by passing a argument upon creation: By default, will prefix blank node labels with a prefix. This is done to prevent collisions of unrelated blank nodes having identical labels. The constructor argument can be used to modify the prefix or, if set to an empty string, completely disable prefixing: The parser can output a backwards chaining rule such as in two ways: • as (default) • as (when the flag is set to ) From an RDF stream to quads can parse Node.js streams as they grow, returning quads as soon as they're ready. is a Node.js stream and RDF.js Sink implementation. This solution is ideal if your consumer is slower, since source data is only read when the consumer is ready. A dedicated event signals every prefix with and arguments. A dedicated event can be enabled by setting in the N3.StreamParser constructor. Writing From quads to a string serializes quads as an RDF document. Write quads through . By default, writes Turtle (or TriG if some quads are in a named graph). To write N-Triples (or N-Quads) instead, pass a argument upon creation: From quads to an RDF stream can also write quads to a Node.js stream through . From a quad stream to an RDF stream is a Node.js stream and RDF.js Sink implementation. Blank nodes and lists You might want to use the and list notations of Turtle and TriG. However, a streaming writer cannot create these automatically: the shorthand notations are only possible if blank nodes or list heads are not used later on, which can only be determined conclusively at the end of the stream. The and functions allow you to create them manually instead: Storing allows you to store triples in memory and find them fast. In this example, we create a new store and add the triples and . Then, we find triples with as subject. If you are using multiple stores, you can reduce memory consumption by allowing them to share an entity index: Interface This store adheres to the interface which exposes the following properties Attributes: • — A non-negative integer that specifies the number of quads in the set. Methods: • — Adds the specified quad to the dataset. Existing quads, as defined in , will be ignored. • — Removes the specified quad from the dataset. • — Determines whether a dataset includes a certain quad. • — Returns a new dataset that is comprised of all quads in the current instance matching the given arguments. • — Implements the iterator protocol to allow iteration over all in the dataset as in the example above. Addition and deletion of quads The store implements the following manipulation methods in addition to the standard Interface (documentation): • to insert one quad • to insert an array of quads • to remove one quad • to remove an array of quads • to remove a stream of quads • to remove all quads matching the given pattern • to remove all quads with the given graph • returns an unused blank node identifier Searching quads or entities The store provides the following search methods (documentation): • returns a stream and generator of quads matching the given pattern • returns an array of quads matching the given pattern • counts the number of quads matching the given pattern • executes a callback on all matching quads • returns whether a callback on matching quads always returns true • returns whether a callback on matching quads returns true at least once • returns an array of unique subjects occurring in matching quads • executes a callback on unique subjects occurring in matching quads • returns an array of unique predicates occurring in matching quad • executes a callback on unique predicates occurring in matching quads • returns an array of unique objects occurring in matching quad • executes a callback on unique objects occurring in matching quads • returns an array of unique graphs occurring in matching quad • executes a ca…