Skip to content

Commit 8472fdb

Browse files
authored
Merge pull request #3 from rdfjs-base/esm
feat!: made the package esm only
2 parents 50280b9 + dff2f19 commit 8472fdb

File tree

10 files changed

+54
-31
lines changed

10 files changed

+54
-31
lines changed

.github/workflows/ci.yaml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: CI
2+
on: push
3+
jobs:
4+
test:
5+
runs-on: ubuntu-20.04
6+
strategy:
7+
matrix:
8+
node:
9+
- '12'
10+
- '14'
11+
- '16'
12+
steps:
13+
- uses: actions/checkout@v2
14+
- uses: actions/setup-node@v2
15+
with:
16+
node-version: ${{ matrix.node }}
17+
- run: npm install
18+
- run: npm test
19+
- run: npm run coverage

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1-
.idea
21
coverage
32
node_modules
3+
package-lock.json
4+

.npmrc

Lines changed: 0 additions & 1 deletion
This file was deleted.

.travis.yml

Lines changed: 0 additions & 4 deletions
This file was deleted.

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66

77
Wrapper for fetch to simplify sending and retrieving RDF data.
88

9+
Since version 3.0, this packages is [ESM](https://nodejs.org/api/esm.html) only.
10+
Check version 2.x if you are looking for a CommonJS package.
11+
912
## Usage
1013

1114
The package exports a `fetch` function which wraps the request and response object for on-the-fly RDF quad processing.

examples/dbpedia.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const rdfFetch = require('..')
1+
import rdfFetch from '../index.js'
22

33
async function main () {
44
try {

index.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
const defaultFactory = require('@rdfjs/dataset')
2-
const defaultFormats = require('@rdfjs/formats-common')
3-
const rdfFetchLite = require('@rdfjs/fetch-lite')
1+
import defaultFactory from '@rdfjs/dataset'
2+
import rdfFetchLite, { Headers } from '@rdfjs/fetch-lite'
3+
import defaultFormats from '@rdfjs/formats-common'
44

55
function rdfFetch (url, { factory = defaultFactory, formats = defaultFormats, ...options } = {}) {
66
return rdfFetchLite(url, { factory, formats, ...options })
77
}
88

9-
rdfFetch.Headers = rdfFetchLite.Headers
10-
11-
module.exports = rdfFetch
9+
export {
10+
rdfFetch as default,
11+
Headers
12+
}

package.json

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@
22
"name": "@rdfjs/fetch",
33
"version": "2.1.0",
44
"description": "Wrapper for fetch to simplify sending and receiving RDF data",
5+
"type": "module",
56
"main": "index.js",
67
"scripts": {
7-
"test": "standard && mocha"
8+
"coverage": "codecov",
9+
"test": "stricter-standard && c8 --reporter=lcov --reporter=text-summary mocha"
810
},
911
"repository": {
1012
"type": "git",
@@ -22,14 +24,16 @@
2224
},
2325
"homepage": "https://github.com/rdfjs-base/fetch",
2426
"dependencies": {
25-
"@rdfjs/dataset": "^1.0.1",
26-
"@rdfjs/fetch-lite": "^2.1.0",
27-
"@rdfjs/formats-common": "^2.0.1"
27+
"@rdfjs/dataset": "^1.1.1",
28+
"@rdfjs/fetch-lite": "^3.0.0",
29+
"@rdfjs/formats-common": "^2.2.0"
2830
},
2931
"devDependencies": {
3032
"@rdfjs/sink-map": "^1.0.1",
31-
"mocha": "^7.1.1",
32-
"nock": "^11.6.0",
33-
"standard": "^14.3.1"
33+
"c8": "^7.10.0",
34+
"codecov": "^3.8.3",
35+
"mocha": "^9.1.2",
36+
"nock": "^13.1.3",
37+
"stricter-standard": "^0.2.0"
3438
}
3539
}

test/Headers.test.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
const { strictEqual } = require('assert')
2-
const { describe, it } = require('mocha')
3-
const { Headers } = require('..')
1+
import { strictEqual } from 'assert'
2+
import { describe, it } from 'mocha'
3+
import { Headers } from '../index.js'
44

55
describe('Headers', () => {
66
it('should be a constructor', () => {

test/test.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
const { strictEqual } = require('assert')
2-
const { describe, it } = require('mocha')
3-
const nock = require('nock')
4-
const rdf = require('@rdfjs/dataset')
5-
const rdfFetch = require('..')
6-
const SinkMap = require('@rdfjs/sink-map')
1+
import { strictEqual } from 'assert'
2+
import rdf from '@rdfjs/dataset'
3+
import SinkMap from '@rdfjs/sink-map'
4+
import { describe, it } from 'mocha'
5+
import nock from 'nock'
6+
import rdfFetch from '../index.js'
77

88
describe('@rdfjs/fetch', () => {
99
it('should be a function', () => {
@@ -23,7 +23,7 @@ describe('@rdfjs/fetch', () => {
2323
nock('http://example.org')
2424
.get('/formats-common')
2525
.reply(200, function () {
26-
accept = this.req.headers.accept[0]
26+
accept = this.req.headers.accept
2727

2828
return [200, '{}']
2929
})
@@ -50,7 +50,7 @@ describe('@rdfjs/fetch', () => {
5050
nock('http://example.org')
5151
.get('/formats-options')
5252
.reply(200, function () {
53-
accept = this.req.headers.accept[0]
53+
accept = this.req.headers.accept
5454

5555
return [200, '{}']
5656
})

0 commit comments

Comments
 (0)