# @rdfjs/serializer-ntriples

> N-Triples serializer that implements the RDF/JS Sink interface

Latest version **2.0.1** (published 2024-02-10) · MIT license · 0 weekly downloads

## Install

```sh
npm install @rdfjs/serializer-ntriples
pnpm add @rdfjs/serializer-ntriples
yarn add @rdfjs/serializer-ntriples
bun add @rdfjs/serializer-ntriples
```

## Health

**Score 43/100 (D)** — status: abandoned.

Positive: has types package; esm support; no vulnerabilities; high maintenance score; high quality score.

Warnings: low downloads.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 2.0.1 |
| Published | 2024-02-10 |
| First published | 2018-09-04 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | separate (@types/rdfjs__serializer-ntriples) |
| Module format | ESM + CommonJS |
| Dependencies | 4 |
| Unpacked size | 6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | Thomas Bergwinkl |
| Maintainers | bergos |
| Keywords | rdf, rdfjs, serializer, ntriples |

## Links

- npm: https://www.npmjs.com/package/@rdfjs/serializer-ntriples
- Repository: https://github.com/rdfjs-base/serializer-ntriples
- Issues: https://github.com/rdfjs-base/serializer-ntriples/issues
- npm.io page: https://npm.io/package/@rdfjs/serializer-ntriples

## Dependencies (4)

- [duplex-to](https://npm.io/package/duplex-to.md) ^2.0.0
- [@rdfjs/sink](https://npm.io/package/@rdfjs/sink.md) ^2.0.1
- [readable-stream](https://npm.io/package/readable-stream.md) ^4.5.2
- [@rdfjs/to-ntriples](https://npm.io/package/@rdfjs/to-ntriples.md) ^3.0.1

## Recent versions

- 2.0.1 (latest) — 2024-02-10
- 2.0.0 — 2022-10-09
- 1.0.3 — 2020-03-30
- 1.0.2 — 2019-07-29
- 1.0.1 — 2018-09-04

## README

# @rdfjs/serializer-ntriples
[![build status](https://img.shields.io/github/actions/workflow/status/rdfjs-base/serializer-ntriples/test.yaml?branch=master)](https://github.com/rdfjs-base/serializer-ntriples/actions/workflows/test.yaml)
[![npm version](https://img.shields.io/npm/v/@rdfjs/serializer-ntriples.svg)](https://www.npmjs.com/package/@rdfjs/serializer-ntriples)

N-Triples serializer that implements the [RDF/JS Sink interface](http://rdf.js.org/).

## Usage

The package exports the serializer as a class, so an instance must be created before it can be used.
The `.import` method, as defined in the [RDF/JS specification](http://rdf.js.org/#sink-interface), must be called to do the actual serialization.
It expects a quad stream as argument.
The method will return a stream which emits N-Triples as strings.
The constructor doesn't need any options.

### Example

This example shows how to create a serializer instance and how to feed it with a stream of quads.
The N-Triples string emitted by the serializer will be written to the console.

```javascript
import rdf from '@rdfjs/data-model'
import { Readable } from 'readable-stream'
import SerializerNtriples from '@rdfjs/serializer-ntriples'

const serializerNtriples = new SerializerNtriples()
const input = Readable.from([
  rdf.quad(
    rdf.namedNode('http://example.org/sheldon-cooper'),
    rdf.namedNode('http://schema.org/givenName'),
    rdf.literal('Sheldon')
  ),
  rdf.quad(
    rdf.namedNode('http://example.org/sheldon-cooper'),
    rdf.namedNode('http://schema.org/familyName'),
    rdf.literal('Cooper')
  ),
  rdf.quad(
    rdf.namedNode('http://example.org/sheldon-cooper'),
    rdf.namedNode('http://schema.org/knows'),
    rdf.namedNode('http://example.org/amy-farrah-fowler')
  )  
])
const output = serializerNtriples.import(input)

output.on('data', ntriples => {
  console.log(ntriples.toString())
})
```

---
_Source: https://npm.io/package/@rdfjs/serializer-ntriples · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
