barnard59-base 1.1.0 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.changeset/README.md +8 -0
- package/.changeset/config.json +11 -0
- package/.editorconfig +3 -0
- package/.github/workflows/add-to-backlog.yml +18 -0
- package/.github/workflows/ci.yaml +16 -5
- package/.github/workflows/release.yaml +34 -0
- package/CHANGELOG.md +6 -0
- package/map.js +30 -13
- package/package.json +7 -4
- package/test/map.test.js +72 -1
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
# Changesets
|
|
2
|
+
|
|
3
|
+
Hello and welcome! This folder has been automatically generated by `@changesets/cli`, a build tool that works
|
|
4
|
+
with multi-package repos, or single-package repos to help you version and publish your code. You can
|
|
5
|
+
find the full documentation for it [in our repository](https://github.com/changesets/changesets)
|
|
6
|
+
|
|
7
|
+
We have a quick list of common questions to get you started engaging with this project in
|
|
8
|
+
[our documentation](https://github.com/changesets/changesets/blob/main/docs/common-questions.md)
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://unpkg.com/@changesets/config@2.3.0/schema.json",
|
|
3
|
+
"changelog": "@changesets/cli/changelog",
|
|
4
|
+
"commit": false,
|
|
5
|
+
"fixed": [],
|
|
6
|
+
"linked": [],
|
|
7
|
+
"access": "public",
|
|
8
|
+
"baseBranch": "master",
|
|
9
|
+
"updateInternalDependencies": "patch",
|
|
10
|
+
"ignore": []
|
|
11
|
+
}
|
package/.editorconfig
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
name: Add issues to shared backlog
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
issues:
|
|
5
|
+
types:
|
|
6
|
+
- opened
|
|
7
|
+
pull_request:
|
|
8
|
+
types:
|
|
9
|
+
- opened
|
|
10
|
+
|
|
11
|
+
jobs:
|
|
12
|
+
add-to-project:
|
|
13
|
+
runs-on: ubuntu-latest
|
|
14
|
+
steps:
|
|
15
|
+
- uses: actions/add-to-project@v0.4.0
|
|
16
|
+
with:
|
|
17
|
+
project-url: https://github.com/orgs/zazuko/projects/23
|
|
18
|
+
github-token: ${{ secrets.BACKLOG_PAT }}
|
|
@@ -2,17 +2,28 @@ name: CI
|
|
|
2
2
|
on: push
|
|
3
3
|
jobs:
|
|
4
4
|
test:
|
|
5
|
-
runs-on: ubuntu-
|
|
5
|
+
runs-on: ubuntu-latest
|
|
6
6
|
strategy:
|
|
7
7
|
matrix:
|
|
8
8
|
node:
|
|
9
|
-
- '
|
|
9
|
+
- '18'
|
|
10
10
|
- '16'
|
|
11
11
|
steps:
|
|
12
|
-
- uses: actions/checkout@
|
|
13
|
-
- uses: actions/setup-node@
|
|
12
|
+
- uses: actions/checkout@v3
|
|
13
|
+
- uses: actions/setup-node@v3
|
|
14
14
|
with:
|
|
15
15
|
node-version: ${{ matrix.node }}
|
|
16
16
|
- run: npm install
|
|
17
17
|
- run: npm test
|
|
18
|
-
-
|
|
18
|
+
- name: Codecov
|
|
19
|
+
uses: codecov/codecov-action@v3
|
|
20
|
+
with:
|
|
21
|
+
token: ${{ secrets.CODECOV_TOKEN }}
|
|
22
|
+
|
|
23
|
+
lint:
|
|
24
|
+
runs-on: ubuntu-latest
|
|
25
|
+
steps:
|
|
26
|
+
- uses: actions/checkout@v3
|
|
27
|
+
- uses: actions/setup-node@v3
|
|
28
|
+
- run: npm ci
|
|
29
|
+
- run: npm run lint
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
name: Release
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches:
|
|
6
|
+
- master
|
|
7
|
+
- prerelease
|
|
8
|
+
|
|
9
|
+
concurrency: ${{ github.workflow }}-${{ github.ref }}
|
|
10
|
+
|
|
11
|
+
jobs:
|
|
12
|
+
release:
|
|
13
|
+
name: Release
|
|
14
|
+
runs-on: ubuntu-latest
|
|
15
|
+
steps:
|
|
16
|
+
- name: Checkout Repo
|
|
17
|
+
uses: actions/checkout@v3
|
|
18
|
+
|
|
19
|
+
- uses: actions/setup-node@v3
|
|
20
|
+
with:
|
|
21
|
+
node-version: 18
|
|
22
|
+
|
|
23
|
+
- name: Install Dependencies
|
|
24
|
+
run: npm ci
|
|
25
|
+
|
|
26
|
+
- name: Create Release Pull Request or Publish to npm
|
|
27
|
+
id: changesets
|
|
28
|
+
uses: changesets/action@v1
|
|
29
|
+
with:
|
|
30
|
+
# This expects you to have a script called release which does a build for your packages and calls changeset publish
|
|
31
|
+
publish: yarn release
|
|
32
|
+
env:
|
|
33
|
+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
34
|
+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
package/CHANGELOG.md
CHANGED
package/map.js
CHANGED
|
@@ -1,17 +1,34 @@
|
|
|
1
|
-
import
|
|
1
|
+
import transform from 'parallel-transform'
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
3
|
+
/**
|
|
4
|
+
* Processes chunks with a transform function
|
|
5
|
+
*
|
|
6
|
+
* @param {Object|Function} options Transform function or complex options
|
|
7
|
+
* @params {Function} options.map Transform function
|
|
8
|
+
* @param {Number} [options.concurrency=1] The max number of concurrent chunks being transformed
|
|
9
|
+
* @param {Boolean} [options.ordered=true] Option to keep order of asynchronously transformed chunks
|
|
10
|
+
* @param {Boolean} [options.objectMode=true] Option to transform chunks in object mode
|
|
11
|
+
* @return {ReadableStream}
|
|
12
|
+
*/
|
|
13
|
+
export default function map (options) {
|
|
14
|
+
let func
|
|
15
|
+
let concurrency = 1
|
|
16
|
+
let ordered = true
|
|
17
|
+
let objectMode = true
|
|
18
|
+
if (typeof options === 'function') {
|
|
19
|
+
func = options
|
|
20
|
+
} else {
|
|
21
|
+
func = options.map
|
|
22
|
+
concurrency = options.concurrency || concurrency
|
|
23
|
+
ordered = typeof options.ordered === 'boolean' ? options.ordered : ordered
|
|
24
|
+
objectMode = typeof options.objectMode === 'boolean' ? options.objectMode : objectMode
|
|
25
|
+
}
|
|
11
26
|
|
|
12
|
-
|
|
13
|
-
|
|
27
|
+
return transform(concurrency, { ordered, objectMode }, (data, callback) => {
|
|
28
|
+
Promise.resolve().then(() => {
|
|
29
|
+
return func.call(this, data)
|
|
30
|
+
}).then(result => {
|
|
31
|
+
callback(null, result)
|
|
32
|
+
}).catch(callback)
|
|
14
33
|
})
|
|
15
34
|
}
|
|
16
|
-
|
|
17
|
-
export default map
|
package/package.json
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "barnard59-base",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"description": "Linked Data pipelines",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"scripts": {
|
|
8
|
-
"
|
|
9
|
-
"test": "
|
|
8
|
+
"lint": "stricter-standard",
|
|
9
|
+
"test": "c8 --reporter=lcov --reporter=text mocha",
|
|
10
|
+
"release": "changeset publish"
|
|
10
11
|
},
|
|
11
12
|
"repository": {
|
|
12
13
|
"type": "git",
|
|
@@ -23,14 +24,16 @@
|
|
|
23
24
|
"@opentelemetry/api": "^1.0.1",
|
|
24
25
|
"duplexify": "^4.1.1",
|
|
25
26
|
"glob": "^7.1.7",
|
|
27
|
+
"parallel-transform": "^1.2.0",
|
|
26
28
|
"readable-stream": "^3.0.6",
|
|
27
29
|
"through2": "^4.0.2"
|
|
28
30
|
},
|
|
29
31
|
"devDependencies": {
|
|
32
|
+
"@changesets/cli": "^2.26.1",
|
|
30
33
|
"barnard59-core": "^1.0.0",
|
|
31
34
|
"c8": "^7.7.3",
|
|
32
|
-
"codecov": "^3.8.2",
|
|
33
35
|
"get-stream": "^6.0.1",
|
|
36
|
+
"into-stream": "^7.0.0",
|
|
34
37
|
"isstream": "^0.1.2",
|
|
35
38
|
"mocha": "^9.0.1",
|
|
36
39
|
"rdf-utils-fs": "^2.1.0",
|
package/test/map.test.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { deepStrictEqual } from 'assert'
|
|
2
|
-
import { array } from 'get-stream'
|
|
2
|
+
import getStream, { array } from 'get-stream'
|
|
3
|
+
import intoStream from 'into-stream'
|
|
3
4
|
import { describe, it } from 'mocha'
|
|
4
5
|
import { Readable } from 'readable-stream'
|
|
5
6
|
import map from '../map.js'
|
|
@@ -24,4 +25,74 @@ describe('map', () => {
|
|
|
24
25
|
|
|
25
26
|
deepStrictEqual(output, ['foo_a', 'foo_b'])
|
|
26
27
|
})
|
|
28
|
+
|
|
29
|
+
it('accepts a function as parameter', async () => {
|
|
30
|
+
// given
|
|
31
|
+
const transform = letter => letter.toUpperCase()
|
|
32
|
+
const input = intoStream.object(['a', 'b', 'c'])
|
|
33
|
+
|
|
34
|
+
// when
|
|
35
|
+
const result = await getStream(input.pipe(map(transform)))
|
|
36
|
+
|
|
37
|
+
// then
|
|
38
|
+
deepStrictEqual(result, 'ABC')
|
|
39
|
+
})
|
|
40
|
+
|
|
41
|
+
it('binds pipeline context to transform function', async () => {
|
|
42
|
+
// const
|
|
43
|
+
function transform (letter) {
|
|
44
|
+
return letter + this.suffix
|
|
45
|
+
}
|
|
46
|
+
const input = intoStream.object(['A', 'B', 'C'])
|
|
47
|
+
|
|
48
|
+
// when
|
|
49
|
+
const boundMap = map.bind({ suffix: 'x' })
|
|
50
|
+
const result = await getStream(input.pipe(boundMap(transform)))
|
|
51
|
+
|
|
52
|
+
// then
|
|
53
|
+
deepStrictEqual(result, 'AxBxCx')
|
|
54
|
+
})
|
|
55
|
+
|
|
56
|
+
it('accepts an option to not retain order', async () => {
|
|
57
|
+
// given
|
|
58
|
+
const transform = async letter => {
|
|
59
|
+
if (letter === 'a') {
|
|
60
|
+
await new Promise(resolve => setTimeout(resolve, 10))
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
return letter.toUpperCase()
|
|
64
|
+
}
|
|
65
|
+
const input = intoStream.object(['a', 'b', 'c'])
|
|
66
|
+
|
|
67
|
+
// when
|
|
68
|
+
const result = await getStream(input.pipe(map({
|
|
69
|
+
map: transform,
|
|
70
|
+
ordered: false,
|
|
71
|
+
concurrency: 3
|
|
72
|
+
})))
|
|
73
|
+
|
|
74
|
+
// then
|
|
75
|
+
deepStrictEqual(result, 'BCA')
|
|
76
|
+
})
|
|
77
|
+
|
|
78
|
+
it('retains input order by default', async () => {
|
|
79
|
+
// given
|
|
80
|
+
const transform = async letter => {
|
|
81
|
+
if (letter === 'a') {
|
|
82
|
+
await new Promise(resolve => setTimeout(resolve, 10))
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
return letter.toUpperCase()
|
|
86
|
+
}
|
|
87
|
+
const input = intoStream.object(['a', 'b', 'c'])
|
|
88
|
+
|
|
89
|
+
// when
|
|
90
|
+
const result = await getStream(input.pipe(map({
|
|
91
|
+
map: transform,
|
|
92
|
+
concurrency: 3
|
|
93
|
+
})))
|
|
94
|
+
|
|
95
|
+
// then
|
|
96
|
+
deepStrictEqual(result, 'ABC')
|
|
97
|
+
})
|
|
27
98
|
})
|