barnard59-base 2.5.2 → 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,21 @@
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
+
9
+ ## 3.0.0
10
+
11
+ ### Major Changes
12
+
13
+ - [#399](https://github.com/zazuko/barnard59/pull/399) [`e5b0100`](https://github.com/zazuko/barnard59/commit/e5b01008eefe180859da3dc940fdb1b90a866abe) Thanks [@tpluscode](https://github.com/tpluscode)! - Removed `readable-stream` and replaced all usages with `node:stream`
14
+
15
+ ### Patch Changes
16
+
17
+ - [#398](https://github.com/zazuko/barnard59/pull/398) [`6a7c8af`](https://github.com/zazuko/barnard59/commit/6a7c8afbbc5889c581db05d1654e38f75e914218) Thanks [@tpluscode](https://github.com/tpluscode)! - Updated `glob` to v13
18
+
3
19
  ## 2.5.2
4
20
 
5
21
  ### Patch Changes
package/Readable.js CHANGED
@@ -1,4 +1,4 @@
1
- import Readable from 'readable-stream'
1
+ import { Readable } from 'node:stream'
2
2
 
3
3
  /**
4
4
  * @param {any[]} array
package/batch.js CHANGED
@@ -1,4 +1,4 @@
1
- import { Transform } from 'readable-stream'
1
+ import { Transform } from 'node:stream'
2
2
 
3
3
  /**
4
4
  * @param {number} [size]
package/combine.js CHANGED
@@ -1,10 +1,10 @@
1
1
  import duplexify from 'duplexify'
2
2
 
3
3
  /**
4
- * Limit the amount of chunks in a pipe.
5
- * @returns {import('stream').Duplex} A transform stream.
6
- * @param {(import('stream').Duplex)[]} streams
7
- * @param {*} options
4
+ * Limit the number of chunks in a pipe.
5
+ * @returns {import('node:stream').Duplex} A transform stream.
6
+ * @param {import('node:stream').Duplex[]} streams
7
+ * @param {*} [options]
8
8
  */
9
9
  function combine(streams, options) {
10
10
  if (streams.length === 0) {
package/concat.js CHANGED
@@ -1,8 +1,8 @@
1
- import { finished, Readable } from 'readable-stream'
1
+ import { finished, Readable } from 'node:stream'
2
2
 
3
3
  class ConcatStream extends Readable {
4
4
  /**
5
- * @param {(import('stream').Duplex)[]} streams
5
+ * @param {import('node:stream').Duplex[]} streams
6
6
  * @param {{
7
7
  * objectMode?: boolean
8
8
  * }} [options]
@@ -47,7 +47,7 @@ class ConcatStream extends Readable {
47
47
  }
48
48
 
49
49
  /**
50
- * @param {(import('stream').Duplex)[]} streams
50
+ * @param {import('node:stream').Duplex[]} streams
51
51
  * @return {Readable}
52
52
  */
53
53
  function factory(...streams) {
@@ -55,7 +55,7 @@ function factory(...streams) {
55
55
  }
56
56
 
57
57
  /**
58
- * @param {(import('stream').Duplex)[]} streams
58
+ * @param {import('node:stream').Duplex[]} streams
59
59
  * @return {Readable}
60
60
  */
61
61
  const object = (...streams) => {
package/dev-nul.js CHANGED
@@ -1,4 +1,4 @@
1
- import { Writable } from 'readable-stream'
1
+ import { Writable } from 'node:stream'
2
2
 
3
3
  class Nul extends Writable {
4
4
  constructor() {
package/filter.js CHANGED
@@ -12,13 +12,13 @@ import { obj } from 'through2'
12
12
  * @this {import('barnard59-core').Context}
13
13
  * @param {Filter<T, A>} func
14
14
  * @param {A} args
15
- * @return {import('stream').Transform}
15
+ * @return {import('node:stream').Transform}
16
16
  */
17
17
  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/flatten.js CHANGED
@@ -11,7 +11,7 @@ import { obj } from 'through2'
11
11
  */
12
12
 
13
13
  /**
14
- * @return {import('stream').Transform} Transform
14
+ * @return {import('node:stream').Transform} Transform
15
15
  */
16
16
  function flatten() {
17
17
  return obj(function (/** IterableLike */ chunk, encoding, callback) {
package/forEach.js CHANGED
@@ -1,9 +1,9 @@
1
1
  import { promisify } from 'node:util'
2
+ import * as stream from 'node:stream'
2
3
  import { context } from '@opentelemetry/api'
3
- import stream from 'readable-stream'
4
4
  import ReadableToReadable from 'readable-to-readable'
5
5
 
6
- const { finished, Duplex } = stream
6
+ const finished = promisify(stream.finished)
7
7
 
8
8
  /**
9
9
  * @typedef {Pick<import('barnard59-core').Context, 'createPipeline' | 'variables'> & {
@@ -11,7 +11,7 @@ const { finished, Duplex } = stream
11
11
  * variable: string
12
12
  * }} ForEachOptions
13
13
  *
14
- * @typedef {import('stream').Duplex & {
14
+ * @typedef {import('node:stream').Duplex & {
15
15
  * pipeline: import('barnard59-core').Pipeline
16
16
  * }} PipelineStream
17
17
  */
@@ -20,7 +20,7 @@ async function nextLoop() {
20
20
  return new Promise(resolve => setTimeout(resolve, 0))
21
21
  }
22
22
 
23
- class ForEach extends Duplex {
23
+ class ForEach extends stream.Duplex {
24
24
  /**
25
25
  * @param {ForEachOptions} context
26
26
  */
@@ -81,12 +81,13 @@ class ForEach extends Duplex {
81
81
  this.subPipeline.stream.end(chunk)
82
82
  }
83
83
 
84
- await promisify(finished)(this.subPipeline.stream)
84
+ await finished(this.subPipeline.stream)
85
85
 
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}`
@@ -96,7 +97,7 @@ class ForEach extends Duplex {
96
97
  }
97
98
 
98
99
  async _read() {
99
- if (this._writableState.finished) {
100
+ if (this.writableFinished) {
100
101
  return this.push(null)
101
102
  }
102
103
 
package/glob.js CHANGED
@@ -1,7 +1,7 @@
1
+ import { Readable } from 'node:stream'
1
2
  import { SpanStatusCode } from '@opentelemetry/api'
2
3
  import { glob as globFn } from 'glob'
3
4
  import onetime from 'onetime'
4
- import { Readable } from 'readable-stream'
5
5
  import tracer from './lib/tracer.js'
6
6
 
7
7
  /**
@@ -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/json.js CHANGED
@@ -1,4 +1,4 @@
1
- import { Transform } from 'readable-stream'
1
+ import { Transform } from 'node:stream'
2
2
 
3
3
  class JsonParse extends Transform {
4
4
  constructor() {
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
@@ -23,7 +23,7 @@ import transform from 'parallel-transform'
23
23
  * @this {import('barnard59-core').Context}
24
24
  * @param {MapOptions<From, To, Args>} options Transform function or complex options
25
25
  * @param {Args} args Additional arguments to pass to the transform function
26
- * @return {import('stream').Transform}
26
+ * @return {import('node:stream').Transform}
27
27
  * @template From, To
28
28
  * @template {Array<unknown>} Args
29
29
  */
@@ -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": "2.5.2",
3
+ "version": "3.0.1",
4
4
  "description": "Linked Data pipelines",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -25,32 +25,32 @@
25
25
  "dependencies": {
26
26
  "@opentelemetry/api": "^1.9.1",
27
27
  "duplexify": "^4.1.1",
28
- "glob": "^12",
28
+ "glob": "^13.0.6",
29
29
  "onetime": "^6.0.0",
30
30
  "parallel-transform": "^1.2.0",
31
- "readable-stream": "^3.0.6",
32
31
  "readable-to-readable": "^0.1.3",
33
32
  "through2": "^4.0.2"
34
33
  },
35
34
  "devDependencies": {
36
35
  "@types/duplexify": "^3.6.4",
37
36
  "@types/parallel-transform": "^1.1.4",
38
- "@types/readable-stream": "^4.0.11",
39
37
  "@types/readable-to-readable": "^0.1.0",
40
38
  "@types/through2": "^2.0.41",
41
- "barnard59-core": "^6.1.4",
42
- "chai": "^4.3.10",
39
+ "barnard59-core": "^7.0.1",
40
+ "chai": "^6.3.0",
43
41
  "get-stream": "^6.0.1",
44
42
  "into-stream": "^7.0.0",
45
43
  "is-stream": "^3.0.0",
46
- "rimraf": "^3.0.2",
47
- "sinon": "^17.0.0"
44
+ "rimraf": "^6.1.3",
45
+ "sinon": "^19"
48
46
  },
49
47
  "engines": {
50
- "node": ">= 14.0.0"
48
+ "node": ">= 16.8"
51
49
  },
52
50
  "mocha": {
53
- "require": "../../test/mocha-setup.cjs",
54
- "loader": "ts-node/esm/transpile-only"
51
+ "require": [
52
+ "tsx",
53
+ "../../test/mocha-setup.js"
54
+ ]
55
55
  }
56
56
  }
package/process.js CHANGED
@@ -1,4 +1,4 @@
1
- import { Transform } from 'readable-stream'
1
+ import { Transform } from 'node:stream'
2
2
 
3
3
  class StdOut extends Transform {
4
4
  /**
@@ -21,7 +21,7 @@ export function stdout() {
21
21
  }
22
22
 
23
23
  /**
24
- * @return {import('stream').Readable}
24
+ * @return {import('node:stream').Readable}
25
25
  */
26
26
  export function stdin() {
27
27
  return process.stdin
@@ -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
 
@@ -1,22 +1,22 @@
1
1
  import { deepStrictEqual, strictEqual } from 'node:assert'
2
+ import { Readable } from 'node:stream'
2
3
  import { array } from 'get-stream'
3
4
  import { isReadableStream as isReadable, isWritableStream as isWritable } from 'is-stream'
4
- import { Readable } from 'readable-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
+ import { Readable } from 'node:stream'
2
3
  import getStream, { array } from 'get-stream'
3
4
  import { isReadableStream as isReadable, isWritableStream as isWritable } from 'is-stream'
4
- import { Readable } from 'readable-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'
3
+ import { Readable } from 'node:stream'
2
4
  import { array } from 'get-stream'
3
- import { Readable } from 'readable-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
+ import { Readable } from 'node:stream'
2
3
  import { array } from 'get-stream'
3
4
  import { isReadableStream as isReadable, isWritableStream as isWritable } from 'is-stream'
4
- import { Readable } from 'readable-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'
3
+ import { Readable } from 'node:stream'
2
4
  import getStream, { array } from 'get-stream'
3
5
  import intoStream from 'into-stream'
4
- import { Readable } from 'readable-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
 
package/toReadable.js CHANGED
@@ -1,4 +1,4 @@
1
- import Readable from 'readable-stream'
1
+ import Readable from 'node:stream'
2
2
 
3
3
  class ToReadable extends Readable {
4
4
  constructor(content, { objectMode = false } = {}) {
package/toString.js CHANGED
@@ -1,4 +1,4 @@
1
- import { Transform } from 'readable-stream'
1
+ import { Transform } from 'node:stream'
2
2
 
3
3
  class ToString extends Transform {
4
4
  constructor() {
@@ -11,7 +11,7 @@ class ToString extends Transform {
11
11
  /**
12
12
  * @param {Uint8Array | string} chunk
13
13
  * @param {BufferEncoding} encoding
14
- * @param {import('stream').TransformCallback} callback
14
+ * @param {import('node:stream').TransformCallback} callback
15
15
  */
16
16
  _transform(chunk, encoding, callback) {
17
17
  callback(null, chunk.toString())
package/Readable.d.ts DELETED
@@ -1,6 +0,0 @@
1
- /**
2
- * @param {any[]} array
3
- * @return {ReturnType<Readable.from>}
4
- */
5
- export function from(...array: any[]): ReturnType<typeof Readable.from>;
6
- import Readable from 'readable-stream';
package/batch.d.ts DELETED
@@ -1,7 +0,0 @@
1
- export default batch;
2
- /**
3
- * @param {number} [size]
4
- * @return {Transform}
5
- */
6
- declare function batch(size?: number | undefined): Transform;
7
- import { Transform } from 'readable-stream';
package/combine.d.ts DELETED
@@ -1,8 +0,0 @@
1
- export default combine;
2
- /**
3
- * Limit the amount of chunks in a pipe.
4
- * @returns {import('stream').Duplex} A transform stream.
5
- * @param {(import('stream').Duplex)[]} streams
6
- * @param {*} options
7
- */
8
- declare function combine(streams: (import('stream').Duplex)[], options: any): import('stream').Duplex;
package/concat.d.ts DELETED
@@ -1,15 +0,0 @@
1
- export default factory;
2
- /**
3
- * @param {(import('stream').Duplex)[]} streams
4
- * @return {Readable}
5
- */
6
- declare function factory(...streams: (import('stream').Duplex)[]): Readable;
7
- declare namespace factory {
8
- export { object };
9
- }
10
- /**
11
- * @param {(import('stream').Duplex)[]} streams
12
- * @return {Readable}
13
- */
14
- export function object(...streams: (import('stream').Duplex)[]): Readable;
15
- import { Readable } from 'readable-stream';
package/dev-nul.d.ts DELETED
@@ -1,6 +0,0 @@
1
- export default factory;
2
- /**
3
- * @return {Writable}
4
- */
5
- declare function factory(): Writable;
6
- import { Writable } from 'readable-stream';
package/filter.d.ts DELETED
@@ -1,19 +0,0 @@
1
- export default filter;
2
- /**
3
- * <T, A>
4
- */
5
- export type Filter<T, A extends unknown[]> = (this: import('barnard59-core').Context, chunk: T, encoding: string, ...args: A) => boolean | Promise<boolean>;
6
- /**
7
- * @typedef {(this: import('barnard59-core').Context, chunk: T, encoding: string, ...args: A) => boolean | Promise<boolean>} Filter<T, A>
8
- * @template T
9
- * @template {Array<unknown>} A
10
- */
11
- /**
12
- * @template T
13
- * @template {Array<unknown>} A
14
- * @this {import('barnard59-core').Context}
15
- * @param {Filter<T, A>} func
16
- * @param {A} args
17
- * @return {import('stream').Transform}
18
- */
19
- declare function filter<T, A extends unknown[]>(this: import("barnard59-core").Context, func: Filter<T, A>, ...args: A): import('stream').Transform;
package/flatten.d.ts DELETED
@@ -1,17 +0,0 @@
1
- export default flatten;
2
- export type ForEachCallback = (item: unknown) => void;
3
- export type IterableLike = Iterable<unknown> | {
4
- forEach(cb: ForEachCallback): void;
5
- };
6
- /**
7
- * @callback ForEachCallback
8
- * @param {unknown} item
9
- * @return {void}
10
- */
11
- /**
12
- * @typedef {Iterable<unknown> | { forEach(cb: ForEachCallback): void }} IterableLike
13
- */
14
- /**
15
- * @return {import('stream').Transform} Transform
16
- */
17
- declare function flatten(): import('stream').Transform;
package/forEach.d.ts DELETED
@@ -1,40 +0,0 @@
1
- export default factory;
2
- export type ForEachOptions = Pick<import('barnard59-core').Context, 'createPipeline' | 'variables'> & {
3
- pipeline: PipelineStream;
4
- variable: string;
5
- };
6
- export type PipelineStream = import('stream').Duplex & {
7
- pipeline: import('barnard59-core').Pipeline;
8
- };
9
- /**
10
- * @this {import('barnard59-core').Context}
11
- * @param {PipelineStream} pipeline
12
- * @param {string} variable
13
- * @return {ForEach}
14
- */
15
- declare function factory(this: import("barnard59-core").Context, pipeline: PipelineStream, variable: string): ForEach;
16
- declare class ForEach extends stream.Duplex {
17
- /**
18
- * @param {ForEachOptions} context
19
- */
20
- constructor({ createPipeline, pipeline, variable, variables }: ForEachOptions);
21
- _read(): Promise<boolean | undefined>;
22
- /**
23
- * @param {*} chunk
24
- * @param {string} encoding
25
- * @param {(error?: (Error | null)) => void} callback
26
- */
27
- _write(chunk: any, encoding: string, callback: (error?: (Error | null)) => void): Promise<void>;
28
- createPipeline: (ptr: import("clownface").GraphPointer, arg?: Partial<import("barnard59-core").PipelineOptions> | undefined) => import("barnard59-core").Pipeline;
29
- ptr: import("clownface").GraphPointer;
30
- variable: string;
31
- variables: Map<string, unknown>;
32
- pull: ReadableToReadable.ReadFunction | null;
33
- set subPipeline(subPipeline: import("barnard59-core").Pipeline);
34
- /**
35
- * @type import('barnard59-core').Pipeline
36
- */
37
- get subPipeline(): import("barnard59-core").Pipeline;
38
- }
39
- import stream from 'readable-stream';
40
- import ReadableToReadable from 'readable-to-readable';
package/glob.d.ts DELETED
@@ -1,10 +0,0 @@
1
- export default glob;
2
- /**
3
- * @this {import('barnard59-core').Context}
4
- * @param {{ pattern: string } & Omit<import('glob').GlobOptions, 'withFileTypes'>} options
5
- * @return {Readable}
6
- */
7
- declare function glob(this: import("barnard59-core").Context, { pattern, ...options }: {
8
- pattern: string;
9
- } & Omit<import('glob').GlobOptions, 'withFileTypes'>): Readable;
10
- import { Readable } from 'readable-stream';
package/index.d.ts DELETED
@@ -1,15 +0,0 @@
1
- export { default as combine } from "./combine.js";
2
- export { default as filter } from "./filter.js";
3
- export { default as flatten } from "./flatten.js";
4
- export { default as forEach } from "./forEach.js";
5
- export { default as glob } from "./glob.js";
6
- export { default as limit } from "./limit.js";
7
- export { default as map } from "./map.js";
8
- export { default as nul } from "./dev-nul.js";
9
- export { default as offset } from "./offset.js";
10
- export * from "./process.js";
11
- export { default as toString } from "./toString.js";
12
- export { default as batch } from "./batch.js";
13
- export { from as streamValues } from "./Readable.js";
14
- export { default as concat, object as concatObject } from "./concat.js";
15
- export { parse as jsonParse, stringify as jsonStringify } from "./json.js";
package/json.d.ts DELETED
@@ -1,9 +0,0 @@
1
- /**
2
- * @return {Transform}
3
- */
4
- export function parse(): Transform;
5
- /**
6
- * @return {Transform}
7
- */
8
- export function stringify(): Transform;
9
- import { Transform } from 'readable-stream';
package/lib/tracer.d.ts DELETED
@@ -1,2 +0,0 @@
1
- export default tracer;
2
- declare const tracer: import("@opentelemetry/api").Tracer;
package/limit.d.ts DELETED
@@ -1,5 +0,0 @@
1
- /**
2
- * Limit the amount of chunks in a pipe.
3
- * @param {number} limit Limit the amount of chunks passed through the pipe.
4
- */
5
- export default function limit(limit: number): (stream: AsyncIterable<any>) => AsyncGenerator<any, void, unknown>;
package/map.d.ts DELETED
@@ -1,33 +0,0 @@
1
- /**
2
- * @typedef {(this: import('barnard59-core').Context, chunk: From, ...args: Args) => Promise<To> | To} MapCallback
3
- * @template From, To
4
- * @template {Array<unknown>} Args
5
- */
6
- /**
7
- * @typedef {{
8
- * map: MapCallback<From, To, Args>
9
- * concurrency?: number
10
- * ordered?: boolean
11
- * objectMode?: boolean
12
- * }|MapCallback<From, To, Args>} MapOptions
13
- * @template From, To
14
- * @template {Array<unknown>} Args
15
- */
16
- /**
17
- * Processes chunks with a transform function
18
- *
19
- * @this {import('barnard59-core').Context}
20
- * @param {MapOptions<From, To, Args>} options Transform function or complex options
21
- * @param {Args} args Additional arguments to pass to the transform function
22
- * @return {import('stream').Transform}
23
- * @template From, To
24
- * @template {Array<unknown>} Args
25
- */
26
- export default function map<From, To, Args extends unknown[]>(this: import("barnard59-core").Context, options: MapOptions<From, To, Args>, ...args: Args): import('stream').Transform;
27
- export type MapCallback<From, To, Args extends unknown[]> = (this: import('barnard59-core').Context, chunk: From, ...args: Args) => Promise<To> | To;
28
- export type MapOptions<From, To, Args extends unknown[]> = {
29
- map: MapCallback<From, To, Args>;
30
- concurrency?: number;
31
- ordered?: boolean;
32
- objectMode?: boolean;
33
- } | MapCallback<From, To, Args>;
package/offset.d.ts DELETED
@@ -1,5 +0,0 @@
1
- /**
2
- * Limit the amount of chunks in a pipe.
3
- * @param {number} offset
4
- */
5
- export default function _default(offset: number): (stream: AsyncIterable<any>) => AsyncGenerator<any, void, unknown>;
package/process.d.ts DELETED
@@ -1,9 +0,0 @@
1
- /**
2
- * @return {Transform}
3
- */
4
- export function stdout(): Transform;
5
- /**
6
- * @return {import('stream').Readable}
7
- */
8
- export function stdin(): import('stream').Readable;
9
- import { Transform } from 'readable-stream';
package/toString.d.ts DELETED
@@ -1,6 +0,0 @@
1
- export default factory;
2
- /**
3
- * @return {Transform}
4
- */
5
- declare function factory(): Transform;
6
- import { Transform } from 'readable-stream';