# rdf-triple-builder

> Conveniently construct RDF triples

Latest version **1.0.1** (published 2017-01-01) · MIT license · 0 weekly downloads

## Install

```sh
npm install rdf-triple-builder
pnpm add rdf-triple-builder
yarn add rdf-triple-builder
bun add rdf-triple-builder
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2017-01-01 |
| First published | 2017-01-01 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Patrick Golden |
| Maintainers | ptgolden |
| Keywords | rdf, n3, triples, graph |

## Links

- npm: https://www.npmjs.com/package/rdf-triple-builder
- Repository: https://github.com/ptgolden/rdf-triple-builder
- Homepage: https://github.com/ptgolden/rdf-triple-builder#readme
- Issues: https://github.com/ptgolden/rdf-triple-builder/issues
- npm.io page: https://npm.io/package/rdf-triple-builder

## Dependencies (1)

- [n3](https://npm.io/package/n3.md) ^0.8.5

## Alternatives

- [apollo-link-http-common](https://npm.io/package/apollo-link-http-common.md) — 879.0K weekly downloads
- [react-relay](https://npm.io/package/react-relay.md) — 336.8K weekly downloads
- [relay-test-utils](https://npm.io/package/relay-test-utils.md) — 181.6K weekly downloads
- [@vendure/core](https://npm.io/package/@vendure/core.md) — 14.8K weekly downloads
- [@pnpm/deps.graph-sequencer](https://npm.io/package/@pnpm/deps.graph-sequencer.md) — 13.4K weekly downloads

## Recent versions

- 1.0.1 (latest) — 2017-01-01
- 1.0.0 — 2017-01-01

## README

# RDF Triple Builder
Utility library built on top of [N3](http://npmjs.com/package/n3) to conveniently build groups of RDF triples.

```js
const $ = require('triple-builder')({
  prefixes: { ex: 'http://example.com/' }
})

console.log($('ex:s')('ex:p')('ex:o'))
/* { subject: 'http://example.com/s'
   , predicate: 'http://example.com/p'
   , object: 'http://example.com/o' } */
```


# Use
This library provides a single, curried function.

It must first be called with an options object.

```js
tripleBuilder({ prefixes })
// Function
```

The resultant function must be called with a URI that will be the subject
of the triple.

```js
tripleBuilder({ prefixes })('ex:s')
// Function
```

At this point, the resultant function can be used in one of two ways.

To build a single triple, simply supply two more arguments that will be
treated as the predicate and object of the triple.

```js
tripleBuilder({ prefixes })('ex:s')('ex:p')('ex:o')
// Object({ subject, predicate, object })
```

To build multiple triples, apply one more argument: a JS Object whose keys will
be treated as predicates, and whose values will be treated as objects. If a
value is an array, triples will be returned for each element as an RDF object.

```js
tripleBuilder({ prefixes })('ex:s')({
  'ex:p1': 'ex:o1',
  'ex:p2': [
    'ex:o2',
    'ex:o3',
  ]
})
// Array of 3 triple objects
```

When only one property (i.e. the subject) has been supplied, the resultant
function can also be used as a property in building other triples.

```js
const $ = tripleBuilder({ prefixes })
    , s = $('ex:s')
    , p = $('ex:p')
    , o = $('ex:o')

s(p)(o)
// Produces the same output as s('ex:p')('ex:o')
```

---
_Source: https://npm.io/package/rdf-triple-builder · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
