barnard59-base 3.0.0 → 3.0.1

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/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # barnard59-base
2
2
 
3
+ ## 3.0.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [#408](https://github.com/zazuko/barnard59/pull/408) [`2359425`](https://github.com/zazuko/barnard59/commit/23594250599bbde63503ae8c0895405df669c922) Thanks [@tpluscode](https://github.com/tpluscode)! - Set the required node version to `>=16.18` in `engines`
8
+
3
9
  ## 3.0.0
4
10
 
5
11
  ### Major Changes
package/filter.js CHANGED
@@ -18,7 +18,7 @@ function filter(func, ...args) {
18
18
  return obj((chunk, encoding, callback) => {
19
19
  Promise.resolve().then(() => {
20
20
  return func.call(this, chunk, encoding, ...args)
21
- }).then(result => {
21
+ }).then((result) => {
22
22
  if (result) {
23
23
  return callback(null, chunk)
24
24
  }
package/forEach.js CHANGED
@@ -86,7 +86,8 @@ class ForEach extends stream.Duplex {
86
86
  this.pull = null
87
87
 
88
88
  return callback()
89
- } catch (/** @type {any} */ cause) {
89
+ }
90
+ catch (/** @type {any} */ cause) {
90
91
  const err = new Error(`error in forEach sub-pipeline ${this.ptr.value}`)
91
92
 
92
93
  err.stack += `\nCaused by: ${cause.stack}`
package/glob.js CHANGED
@@ -42,11 +42,13 @@ function glob({ pattern, ...options }) {
42
42
 
43
43
  // @ts-ignore
44
44
  stream._read()
45
- } catch (/** @type {any} */ err) {
45
+ }
46
+ catch (/** @type {any} */ err) {
46
47
  span.recordException(err)
47
48
  span.setStatus({ code: SpanStatusCode.ERROR, message: err.message })
48
49
  stream.destroy(err)
49
- } finally {
50
+ }
51
+ finally {
50
52
  span.end()
51
53
  }
52
54
  },
package/limit.js CHANGED
@@ -6,13 +6,14 @@ export default function limit(limit) {
6
6
  /**
7
7
  * @param {AsyncIterable<*>} stream
8
8
  */
9
- return async function * (stream) {
9
+ return async function* (stream) {
10
10
  let count = 0
11
11
  for await (const chunk of stream) {
12
12
  count++
13
13
  if (count <= limit) {
14
14
  yield chunk
15
- } else {
15
+ }
16
+ else {
16
17
  break
17
18
  }
18
19
  }
package/map.js CHANGED
@@ -37,7 +37,8 @@ export default function map(options, ...args) {
37
37
  let objectMode = true
38
38
  if (typeof options === 'function') {
39
39
  func = options
40
- } else {
40
+ }
41
+ else {
41
42
  func = options.map
42
43
  concurrency = options.concurrency || concurrency
43
44
  ordered = typeof options.ordered === 'boolean' ? options.ordered : ordered
@@ -47,8 +48,8 @@ export default function map(options, ...args) {
47
48
  return transform(concurrency, { ordered, objectMode }, (data, callback) => {
48
49
  Promise.resolve().then(() => {
49
50
  return func.call(this, data, ...args)
50
- }).then(result => {
51
- callback(null, result)
52
- }).catch(callback)
51
+ }).then((result) => {
52
+ return setImmediate(() => callback(null, result))
53
+ }).catch(err => setImmediate(() => callback(err, null)))
53
54
  })
54
55
  }
package/offset.js CHANGED
@@ -6,7 +6,7 @@ export default function (offset) {
6
6
  /**
7
7
  * @param {AsyncIterable<*>} stream
8
8
  */
9
- return async function * (stream) {
9
+ return async function* (stream) {
10
10
  let count = 0
11
11
 
12
12
  for await (const chunk of stream) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "barnard59-base",
3
- "version": "3.0.0",
3
+ "version": "3.0.1",
4
4
  "description": "Linked Data pipelines",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -36,19 +36,21 @@
36
36
  "@types/parallel-transform": "^1.1.4",
37
37
  "@types/readable-to-readable": "^0.1.0",
38
38
  "@types/through2": "^2.0.41",
39
- "barnard59-core": "^7.0.0",
40
- "chai": "^4.3.10",
39
+ "barnard59-core": "^7.0.1",
40
+ "chai": "^6.3.0",
41
41
  "get-stream": "^6.0.1",
42
42
  "into-stream": "^7.0.0",
43
43
  "is-stream": "^3.0.0",
44
44
  "rimraf": "^6.1.3",
45
- "sinon": "^17.0.0"
45
+ "sinon": "^19"
46
46
  },
47
47
  "engines": {
48
- "node": ">= 14.0.0"
48
+ "node": ">= 16.8"
49
49
  },
50
50
  "mocha": {
51
- "require": "../../test/mocha-setup.cjs",
52
- "loader": "ts-node/esm/transpile-only"
51
+ "require": [
52
+ "tsx",
53
+ "../../test/mocha-setup.js"
54
+ ]
53
55
  }
54
56
  }
@@ -4,8 +4,8 @@ import getStream from 'get-stream'
4
4
  import { expect } from 'chai'
5
5
  import * as Readable from '../Readable.js'
6
6
 
7
- describe('Readable', () => {
8
- it('should return a readable stream', async () => {
7
+ describe('Readable', function () {
8
+ it('should return a readable stream', async function () {
9
9
  // given
10
10
  const stream = Readable.from(0, 1, 2, 3, 4)
11
11
 
@@ -4,19 +4,19 @@ import { array } from 'get-stream'
4
4
  import { isReadableStream as isReadable, isWritableStream as isWritable } from 'is-stream'
5
5
  import batch from '../batch.js'
6
6
 
7
- describe('batch', () => {
8
- it('should be a function', () => {
7
+ describe('batch', function () {
8
+ it('should be a function', function () {
9
9
  strictEqual(typeof batch, 'function')
10
10
  })
11
11
 
12
- it('should return a duplex stream', async () => {
12
+ it('should return a duplex stream', async function () {
13
13
  const result = batch()
14
14
 
15
15
  strictEqual(isWritable(result), true)
16
16
  strictEqual(isReadable(result), true)
17
17
  })
18
18
 
19
- it('should do nothing if there are no input chunks', async () => {
19
+ it('should do nothing if there are no input chunks', async function () {
20
20
  const input = Readable({
21
21
  objectMode: true,
22
22
  read: () => {
@@ -29,7 +29,7 @@ describe('batch', () => {
29
29
  deepStrictEqual(result, [])
30
30
  })
31
31
 
32
- it('should split input in batches', async () => {
32
+ it('should split input in batches', async function () {
33
33
  const expected = [['a', 'b'], ['c', 'd'], ['e']]
34
34
  const input = Readable({
35
35
  objectMode: true,
@@ -43,7 +43,7 @@ describe('batch', () => {
43
43
  deepStrictEqual(result, expected)
44
44
  })
45
45
 
46
- it('should emit a single batch', async () => {
46
+ it('should emit a single batch', async function () {
47
47
  const expected = [['a', 'b', 'c', 'd', 'e']]
48
48
  const input = Readable({
49
49
  objectMode: true,
@@ -1,22 +1,22 @@
1
- import { deepStrictEqual, strictEqual, rejects } from 'assert'
1
+ import { deepStrictEqual, strictEqual, rejects } from 'node:assert'
2
2
  import { Readable } from 'node:stream'
3
3
  import getStream, { array } from 'get-stream'
4
4
  import { isReadableStream as isReadable, isWritableStream as isWritable } from 'is-stream'
5
5
  import concat, { object } from '../concat.js'
6
6
 
7
- describe('concat', () => {
8
- it('should be a function', () => {
7
+ describe('concat', function () {
8
+ it('should be a function', function () {
9
9
  strictEqual(typeof concat, 'function')
10
10
  })
11
11
 
12
- it('should return a Readable', () => {
12
+ it('should return a Readable', function () {
13
13
  const s = concat(new Readable({ read: () => {} }))
14
14
 
15
15
  strictEqual(isReadable(s), true)
16
16
  strictEqual(isWritable(s), false)
17
17
  })
18
18
 
19
- it('should process one stream after another', async () => {
19
+ it('should process one stream after another', async function () {
20
20
  let end0 = null
21
21
  let start1 = null
22
22
 
@@ -43,7 +43,7 @@ describe('concat', () => {
43
43
  strictEqual(end0 <= start1, true)
44
44
  })
45
45
 
46
- it('should emit chunks from all streams in order', async () => {
46
+ it('should emit chunks from all streams in order', async function () {
47
47
  const stream0 = new Readable({
48
48
  read: () => {
49
49
  stream0.push('a')
@@ -67,7 +67,7 @@ describe('concat', () => {
67
67
  strictEqual(result, 'abcd')
68
68
  })
69
69
 
70
- it('should forward error events', async () => {
70
+ it('should forward error events', async function () {
71
71
  const stream0 = new Readable({
72
72
  read: () => {
73
73
  stream0.destroy(new Error('test'))
@@ -87,19 +87,19 @@ describe('concat', () => {
87
87
  await rejects(() => getStream(s))
88
88
  })
89
89
 
90
- describe('object', () => {
91
- it('should be a function', () => {
90
+ describe('object', function () {
91
+ it('should be a function', function () {
92
92
  strictEqual(typeof object, 'function')
93
93
  })
94
94
 
95
- it('should return a Readable', () => {
95
+ it('should return a Readable', function () {
96
96
  const s = object(new Readable({ read: () => {} }))
97
97
 
98
98
  strictEqual(isReadable(s), true)
99
99
  strictEqual(isWritable(s), false)
100
100
  })
101
101
 
102
- it('should process one stream after another', async () => {
102
+ it('should process one stream after another', async function () {
103
103
  let end0 = null
104
104
  let start1 = null
105
105
 
@@ -126,7 +126,7 @@ describe('concat', () => {
126
126
  strictEqual(end0 <= start1, true)
127
127
  })
128
128
 
129
- it('should emit chunks from all streams in order', async () => {
129
+ it('should emit chunks from all streams in order', async function () {
130
130
  const stream0 = new Readable({
131
131
  objectMode: true,
132
132
  read: () => {
@@ -152,7 +152,7 @@ describe('concat', () => {
152
152
  deepStrictEqual(result, ['a', 'b', 'c', 'd'])
153
153
  })
154
154
 
155
- it('should forward error events', async () => {
155
+ it('should forward error events', async function () {
156
156
  const stream0 = new Readable({
157
157
  objectMode: true,
158
158
  read: () => {
@@ -1,10 +1,11 @@
1
- import { deepStrictEqual } from 'assert'
1
+ /* eslint-disable mocha/no-nested-tests */
2
+ import { deepStrictEqual } from 'node:assert'
2
3
  import { Readable } from 'node:stream'
3
4
  import { array } from 'get-stream'
4
5
  import filter from '../filter.js'
5
6
 
6
- describe('filter', () => {
7
- it('should pass pipeline context to callback function', async () => {
7
+ describe('filter', function () {
8
+ it('should pass pipeline context to callback function', async function () {
8
9
  // given
9
10
  const input = new Readable({
10
11
  objectMode: true,
@@ -28,7 +29,7 @@ describe('filter', () => {
28
29
  deepStrictEqual(output, ['a'])
29
30
  })
30
31
 
31
- it('should pass additional arguments to callback function', async () => {
32
+ it('should pass additional arguments to callback function', async function () {
32
33
  // given
33
34
  const input = new Readable({
34
35
  objectMode: true,
@@ -1,22 +1,22 @@
1
- import { deepStrictEqual, strictEqual } from 'assert'
1
+ import { deepStrictEqual, strictEqual } from 'node:assert'
2
2
  import { Readable } from 'node:stream'
3
3
  import { array } from 'get-stream'
4
4
  import { isReadableStream as isReadable, isWritableStream as isWritable } from 'is-stream'
5
5
  import flatten from '../flatten.js'
6
6
 
7
- describe('flatten', () => {
8
- it('should be a function', () => {
7
+ describe('flatten', function () {
8
+ it('should be a function', function () {
9
9
  strictEqual(typeof flatten, 'function')
10
10
  })
11
11
 
12
- it('should return a duplex stream', async () => {
12
+ it('should return a duplex stream', async function () {
13
13
  const result = flatten()
14
14
 
15
15
  strictEqual(isWritable(result), true)
16
16
  strictEqual(isReadable(result), true)
17
17
  })
18
18
 
19
- it('should do nothing if there are no input chunks', async () => {
19
+ it('should do nothing if there are no input chunks', async function () {
20
20
  const input = Readable({
21
21
  objectMode: true,
22
22
  read: () => {
@@ -29,8 +29,8 @@ describe('flatten', () => {
29
29
  deepStrictEqual(result, [])
30
30
  })
31
31
 
32
- it('should flatten object with a iterator interface', async () => {
33
- const toIterator = input => {
32
+ it('should flatten object with a iterator interface', async function () {
33
+ const toIterator = (input) => {
34
34
  return {
35
35
  [Symbol.iterator]: input[Symbol.iterator].bind(input),
36
36
  }
@@ -50,8 +50,8 @@ describe('flatten', () => {
50
50
  deepStrictEqual(result, expected)
51
51
  })
52
52
 
53
- it('should flatten object with a forEach method', async () => {
54
- const toForEach = input => {
53
+ it('should flatten object with a forEach method', async function () {
54
+ const toForEach = (input) => {
55
55
  return {
56
56
  forEach: input.forEach.bind(input),
57
57
  }
@@ -71,7 +71,7 @@ describe('flatten', () => {
71
71
  deepStrictEqual(result, expected)
72
72
  })
73
73
 
74
- it('should emit an error if the chunks don\'t implement Symbol.iterator or .forEach', async () => {
74
+ it('should emit an error if the chunks don\'t implement Symbol.iterator or .forEach', async function () {
75
75
  let error = null
76
76
  const input = Readable({
77
77
  objectMode: true,
@@ -83,7 +83,8 @@ describe('flatten', () => {
83
83
 
84
84
  try {
85
85
  await array(input.pipe(flatten()))
86
- } catch (err) {
86
+ }
87
+ catch (err) {
87
88
  error = err
88
89
  }
89
90
 
package/test/glob.test.js CHANGED
@@ -4,10 +4,10 @@ import sinon from 'sinon'
4
4
  import { expect } from 'chai'
5
5
  import glob from '../glob.js'
6
6
 
7
- describe('glob', () => {
7
+ describe('glob', function () {
8
8
  let logger
9
9
 
10
- beforeEach(() => {
10
+ beforeEach(function () {
11
11
  logger = {
12
12
  debug: sinon.spy(),
13
13
  info: sinon.spy(),
@@ -18,14 +18,14 @@ describe('glob', () => {
18
18
  }
19
19
  })
20
20
 
21
- it('should return a Readable stream', () => {
21
+ it('should return a Readable stream', function () {
22
22
  const s = glob.call({ logger }, { pattern: 'test/support/*' })
23
23
 
24
24
  expect(isReadable(s)).to.be.true
25
25
  expect(isWritable(s)).to.be.false
26
26
  })
27
27
 
28
- it('should emit each file name as a chunk', async () => {
28
+ it('should emit each file name as a chunk', async function () {
29
29
  const s = glob.call({ logger }, { pattern: '../../test/e2e/definitions/foreach/*' })
30
30
 
31
31
  const filenames = await array(s)
@@ -37,7 +37,7 @@ describe('glob', () => {
37
37
  ])
38
38
  })
39
39
 
40
- it('should forward additional options', async () => {
40
+ it('should forward additional options', async function () {
41
41
  const s = glob.call({ logger }, {
42
42
  cwd: '../../test/e2e/definitions/foreach',
43
43
  pattern: '*',
@@ -52,7 +52,7 @@ describe('glob', () => {
52
52
  ])
53
53
  })
54
54
 
55
- it('should warn when no files are matched', async () => {
55
+ it('should warn when no files are matched', async function () {
56
56
  const s = glob.call({ logger }, {
57
57
  cwd: '../../test/e2e/definitions/foreach',
58
58
  pattern: 'foobar',
@@ -63,7 +63,7 @@ describe('glob', () => {
63
63
  expect(logger.warn).to.have.been.called
64
64
  })
65
65
 
66
- it('should not warn files have been matched', async () => {
66
+ it('should not warn files have been matched', async function () {
67
67
  const s = glob.call({ logger }, {
68
68
  cwd: '../../test/e2e/definitions/foreach',
69
69
  pattern: '*',
@@ -3,14 +3,14 @@ import { expect } from 'chai'
3
3
  import getStream from 'get-stream'
4
4
  import limit from '../limit.js'
5
5
 
6
- describe('limit', () => {
7
- it('should return generator', () => {
6
+ describe('limit', function () {
7
+ it('should return generator', function () {
8
8
  const step = limit(1)
9
9
 
10
10
  expect(step).to.be.instanceOf(Function)
11
11
  })
12
12
 
13
- it('stop processing chunks when limit is reached', async () => {
13
+ it('stop processing chunks when limit is reached', async function () {
14
14
  // given
15
15
  const step = limit(1)
16
16
 
package/test/map.test.js CHANGED
@@ -1,11 +1,12 @@
1
- import { deepStrictEqual } from 'assert'
1
+ /* eslint-disable mocha/no-nested-tests */
2
+ import { deepStrictEqual } from 'node:assert'
2
3
  import { Readable } from 'node:stream'
3
4
  import getStream, { array } from 'get-stream'
4
5
  import intoStream from 'into-stream'
5
6
  import map from '../map.js'
6
7
 
7
- describe('map', () => {
8
- it('should pass pipeline context to mapper function', async () => {
8
+ describe('map', function () {
9
+ it('should pass pipeline context to mapper function', async function () {
9
10
  const input = new Readable({
10
11
  read: () => {
11
12
  input.push('a')
@@ -25,7 +26,7 @@ describe('map', () => {
25
26
  deepStrictEqual(output, ['foo_a', 'foo_b'])
26
27
  })
27
28
 
28
- it('should pass optional arguments to mapper function', async () => {
29
+ it('should pass optional arguments to mapper function', async function () {
29
30
  const input = new Readable({
30
31
  read: () => {
31
32
  input.push('a')
@@ -41,7 +42,7 @@ describe('map', () => {
41
42
  deepStrictEqual(output, ['foo_a', 'foo_b'])
42
43
  })
43
44
 
44
- it('should pass optional arguments to mapper function when used with options object', async () => {
45
+ it('should pass optional arguments to mapper function when used with options object', async function () {
45
46
  const input = new Readable({
46
47
  read: () => {
47
48
  input.push('a')
@@ -59,7 +60,7 @@ describe('map', () => {
59
60
  deepStrictEqual(output, ['foo_a', 'foo_b'])
60
61
  })
61
62
 
62
- it('accepts a function as parameter', async () => {
63
+ it('accepts a function as parameter', async function () {
63
64
  // given
64
65
  const transform = letter => letter.toUpperCase()
65
66
  const input = intoStream.object(['a', 'b', 'c'])
@@ -71,7 +72,7 @@ describe('map', () => {
71
72
  deepStrictEqual(result, 'ABC')
72
73
  })
73
74
 
74
- it('binds pipeline context to transform function', async () => {
75
+ it('binds pipeline context to transform function', async function () {
75
76
  // const
76
77
  function transform(letter) {
77
78
  return letter + this.suffix
@@ -86,9 +87,9 @@ describe('map', () => {
86
87
  deepStrictEqual(result, 'AxBxCx')
87
88
  })
88
89
 
89
- it('accepts an option to not retain order', async () => {
90
+ it('accepts an option to not retain order', async function () {
90
91
  // given
91
- const transform = async letter => {
92
+ const transform = async (letter) => {
92
93
  if (letter === 'a') {
93
94
  await new Promise(resolve => setTimeout(resolve, 10))
94
95
  }
@@ -108,9 +109,9 @@ describe('map', () => {
108
109
  deepStrictEqual(result, 'BCA')
109
110
  })
110
111
 
111
- it('retains input order by default', async () => {
112
+ it('retains input order by default', async function () {
112
113
  // given
113
- const transform = async letter => {
114
+ const transform = async (letter) => {
114
115
  if (letter === 'a') {
115
116
  await new Promise(resolve => setTimeout(resolve, 10))
116
117
  }
@@ -3,14 +3,14 @@ import { expect } from 'chai'
3
3
  import getStream from 'get-stream'
4
4
  import offset from '../offset.js'
5
5
 
6
- describe('offset', () => {
7
- it('should return generator', () => {
6
+ describe('offset', function () {
7
+ it('should return generator', function () {
8
8
  const step = offset(1)
9
9
 
10
10
  expect(step).to.be.instanceOf(Function)
11
11
  })
12
12
 
13
- it('stop processing chunks when limit is reached', async () => {
13
+ it('stop processing chunks when limit is reached', async function () {
14
14
  // given
15
15
  const step = offset(2)
16
16