diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml new file mode 100644 index 0000000..06d8634 --- /dev/null +++ b/.github/workflows/test.yaml @@ -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 diff --git a/LICENSE.md b/LICENSE.md new file mode 100644 index 0000000..d319c08 --- /dev/null +++ b/LICENSE.md @@ -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. diff --git a/README.md b/README.md index 7c484f4..7d9abbe 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,5 @@ # @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. @@ -9,8 +7,8 @@ Converts [RDF/JS](http://rdf.js.org/) Terms, Quads and Datasets to N-Triple stri ## 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'))) diff --git a/index.js b/index.js index 6c5ef7c..15320fe 100644 --- a/index.js +++ b/index.js @@ -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) { @@ -43,4 +43,4 @@ function toNT (term) { throw new Error(`unknown termType ${term.termType}`) } -module.exports = toNT +export default toNT diff --git a/lib/blankNode.js b/lib/blankNode.js index 786d749..4d5a5a9 100644 --- a/lib/blankNode.js +++ b/lib/blankNode.js @@ -2,4 +2,4 @@ function blankNode (blankNode) { return '_:' + blankNode.value // TODO: escape special chars } -module.exports = blankNode +export default blankNode diff --git a/lib/dataset.js b/lib/dataset.js index 6cac44a..1420118 100644 --- a/lib/dataset.js +++ b/lib/dataset.js @@ -2,4 +2,4 @@ function dataset (dataset, toNT) { return [...dataset].map(quad => toNT(quad)).join('\n') + '\n' } -module.exports = dataset +export default dataset diff --git a/lib/defaultGraph.js b/lib/defaultGraph.js index f56b5ec..826736f 100644 --- a/lib/defaultGraph.js +++ b/lib/defaultGraph.js @@ -2,4 +2,4 @@ function defaultGraph () { return '' } -module.exports = defaultGraph +export default defaultGraph diff --git a/lib/literal.js b/lib/literal.js index a36f09b..fee8aa5 100644 --- a/lib/literal.js +++ b/lib/literal.js @@ -1,4 +1,4 @@ -const namedNode = require('./namedNode.js') +import namedNode from './namedNode.js' const echarRegEx = /["\\\\\n\r]/ const echarRegExAll = /["\\\\\n\r]/g @@ -36,4 +36,4 @@ function literal (literal) { return '"' + escapedValue + '"^^' + namedNode(literal.datatype) } -module.exports = literal +export default literal diff --git a/lib/namedNode.js b/lib/namedNode.js index 5d8586c..e2b4de5 100644 --- a/lib/namedNode.js +++ b/lib/namedNode.js @@ -2,4 +2,4 @@ function namedNode (namedNode) { return '<' + namedNode.value + '>' } -module.exports = namedNode +export default namedNode diff --git a/lib/quad.js b/lib/quad.js index 738cab0..b8dda7c 100644 --- a/lib/quad.js +++ b/lib/quad.js @@ -7,4 +7,4 @@ function quad (quad, toNT) { return `${subjectString} ${predicateString} ${objectString} ${graphString ? graphString + ' ' : ''}.` } -module.exports = quad +export default quad diff --git a/lib/variable.js b/lib/variable.js index fed6e28..ad4a657 100644 --- a/lib/variable.js +++ b/lib/variable.js @@ -2,4 +2,4 @@ function variable (variable) { return '?' + variable.value } -module.exports = variable +export default variable diff --git a/package.json b/package.json index 5a95504..0fdb964 100644 --- a/package.json +++ b/package.json @@ -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": { @@ -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" } } diff --git a/test/test.js b/test/test.js index 04de1ab..1d54c70 100644 --- a/test/test.js +++ b/test/test.js @@ -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', () => {