Skip to content

Commit

Permalink
feat!: switched to esm, updated ci (node version), fixed badge in rea…
Browse files Browse the repository at this point in the history
…dme, updated deps, added license file
  • Loading branch information
bergos committed Feb 9, 2024
1 parent 0de937f commit 83c98f5
Show file tree
Hide file tree
Showing 13 changed files with 70 additions and 32 deletions.
21 changes: 21 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Test
on:
- pull_request
- push
jobs:
test:
runs-on: ubuntu-20.04
strategy:
matrix:
node:
- '18'
- '20'
- '21'
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node }}
- run: npm install
- run: npm test
- uses: codecov/codecov-action@v3
21 changes: 21 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2024 Thomas Bergwinkl

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
8 changes: 3 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
# @rdfjs/to-ntriples

[![Build Status](https://travis-ci.org/rdfjs/to-ntriples.svg?branch=master)](https://travis-ci.org/rdfjs/to-ntriples)

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

Converts [RDF/JS](http://rdf.js.org/) Terms, Quads and Datasets to N-Triple strings.

## Examples

```javascript
const rdf = require('@rdfjs/data-model')
const toNT = require('@rdfjs/to-ntriples')
import rdf from '@rdfjs/data-model'
import toNT from '@rdfjs/to-ntriples'

// convert a Term/Literal to a N-Triple string (output: "example"@en)
console.log(toNT(rdf.literal('example', 'en')))
Expand Down
16 changes: 8 additions & 8 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
const blankNode = require('./lib/blankNode.js')
const dataset = require('./lib/dataset.js')
const defaultGraph = require('./lib/defaultGraph.js')
const literal = require('./lib/literal.js')
const namedNode = require('./lib/namedNode.js')
const quad = require('./lib/quad.js')
const variable = require('./lib/variable.js')
import blankNode from './lib/blankNode.js'
import dataset from './lib/dataset.js'
import defaultGraph from './lib/defaultGraph.js'
import literal from './lib/literal.js'
import namedNode from './lib/namedNode.js'
import quad from './lib/quad.js'
import variable from './lib/variable.js'

function toNT (term) {
if (!term) {
Expand Down Expand Up @@ -43,4 +43,4 @@ function toNT (term) {
throw new Error(`unknown termType ${term.termType}`)
}

module.exports = toNT
export default toNT
2 changes: 1 addition & 1 deletion lib/blankNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ function blankNode (blankNode) {
return '_:' + blankNode.value // TODO: escape special chars
}

module.exports = blankNode
export default blankNode
2 changes: 1 addition & 1 deletion lib/dataset.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ function dataset (dataset, toNT) {
return [...dataset].map(quad => toNT(quad)).join('\n') + '\n'
}

module.exports = dataset
export default dataset
2 changes: 1 addition & 1 deletion lib/defaultGraph.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ function defaultGraph () {
return ''
}

module.exports = defaultGraph
export default defaultGraph
4 changes: 2 additions & 2 deletions lib/literal.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const namedNode = require('./namedNode.js')
import namedNode from './namedNode.js'

const echarRegEx = /["\\\\\n\r]/
const echarRegExAll = /["\\\\\n\r]/g
Expand Down Expand Up @@ -36,4 +36,4 @@ function literal (literal) {
return '"' + escapedValue + '"^^' + namedNode(literal.datatype)
}

module.exports = literal
export default literal
2 changes: 1 addition & 1 deletion lib/namedNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ function namedNode (namedNode) {
return '<' + namedNode.value + '>'
}

module.exports = namedNode
export default namedNode
2 changes: 1 addition & 1 deletion lib/quad.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ function quad (quad, toNT) {
return `${subjectString} ${predicateString} ${objectString} ${graphString ? graphString + ' ' : ''}.`
}

module.exports = quad
export default quad
2 changes: 1 addition & 1 deletion lib/variable.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ function variable (variable) {
return '?' + variable.value
}

module.exports = variable
export default variable
12 changes: 5 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
"name": "@rdfjs/to-ntriples",
"version": "2.0.0",
"description": "Converts RDF/JS Terms, Quads and Datasets to N-Triple strings",
"type": "module",
"main": "index.js",
"scripts": {
"coverage": "codecov",
"test": "stricter-standard && c8 --reporter=lcov --reporter=text mocha"
},
"repository": {
Expand All @@ -23,12 +23,10 @@
"url": "https://github.com/rdfjs-base/to-ntriples/issues"
},
"homepage": "https://github.com/rdfjs-base/to-ntriples",
"dependencies": {},
"devDependencies": {
"@rdfjs/data-model": "^1.3.0",
"c8": "^7.7.3",
"codecov": "^3.8.2",
"mocha": "^9.0.1",
"stricter-standard": "^0.2.0"
"@rdfjs/data-model": "^2.0.1",
"c8": "^9.1.0",
"mocha": "^10.3.0",
"stricter-standard": "^0.3.0"
}
}
8 changes: 4 additions & 4 deletions test/test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const { strictEqual, throws } = require('assert')
const rdf = require('@rdfjs/data-model')
const { describe, it } = require('mocha')
const toNT = require('../index.js')
import { strictEqual, throws } from 'node:assert'
import rdf from '@rdfjs/data-model'
import { describe, it } from 'mocha'
import toNT from '../index.js'

describe('@rdfjs/to-ntriples', () => {
it('should be a function', () => {
Expand Down

0 comments on commit 83c98f5

Please sign in to comment.