barnard59-base 2.4.0 → 2.4.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 +7 -0
- package/Readable.d.ts +6 -0
- package/Readable.js +4 -0
- package/batch.d.ts +7 -0
- package/batch.js +8 -0
- package/glob.d.ts +2 -2
- package/glob.js +3 -4
- package/index.d.ts +2 -0
- package/index.js +2 -0
- package/package.json +5 -6
- package/test/glob.test.js +4 -9
package/CHANGELOG.md
CHANGED
package/Readable.d.ts
ADDED
package/Readable.js
CHANGED
package/batch.d.ts
ADDED
package/batch.js
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import { Transform } from 'readable-stream'
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* @param {number} [size]
|
|
5
|
+
* @return {Transform}
|
|
6
|
+
*/
|
|
3
7
|
function batch(size = 0) {
|
|
8
|
+
/** @type {any[]} */
|
|
4
9
|
let array = []
|
|
5
10
|
const maxSize = Number(size)
|
|
6
11
|
return new Transform({
|
|
@@ -16,6 +21,9 @@ function batch(size = 0) {
|
|
|
16
21
|
}
|
|
17
22
|
callback()
|
|
18
23
|
},
|
|
24
|
+
/**
|
|
25
|
+
* @this {Transform}
|
|
26
|
+
*/
|
|
19
27
|
flush(callback) {
|
|
20
28
|
if (array.length > 0) this.push(array)
|
|
21
29
|
callback()
|
package/glob.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
export default glob;
|
|
2
2
|
/**
|
|
3
3
|
* @this {import('barnard59-core').Context}
|
|
4
|
-
* @param {{ pattern: string } & import('glob').
|
|
4
|
+
* @param {{ pattern: string } & Omit<import('glob').GlobOptions, 'withFileTypes'>} options
|
|
5
5
|
* @return {Readable}
|
|
6
6
|
*/
|
|
7
7
|
declare function glob(this: import("barnard59-core").Context, { pattern, ...options }: {
|
|
8
8
|
pattern: string;
|
|
9
|
-
} & import('glob').
|
|
9
|
+
} & Omit<import('glob').GlobOptions, 'withFileTypes'>): Readable;
|
|
10
10
|
import { Readable } from 'readable-stream';
|
package/glob.js
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
import { promisify } from 'node:util'
|
|
2
1
|
import { SpanStatusCode } from '@opentelemetry/api'
|
|
3
|
-
import globFn from 'glob'
|
|
2
|
+
import { glob as globFn } from 'glob'
|
|
4
3
|
import onetime from 'onetime'
|
|
5
4
|
import { Readable } from 'readable-stream'
|
|
6
5
|
import tracer from './lib/tracer.js'
|
|
7
6
|
|
|
8
7
|
/**
|
|
9
8
|
* @this {import('barnard59-core').Context}
|
|
10
|
-
* @param {{ pattern: string } & import('glob').
|
|
9
|
+
* @param {{ pattern: string } & Omit<import('glob').GlobOptions, 'withFileTypes'>} options
|
|
11
10
|
* @return {Readable}
|
|
12
11
|
*/
|
|
13
12
|
function glob({ pattern, ...options }) {
|
|
@@ -19,7 +18,7 @@ function glob({ pattern, ...options }) {
|
|
|
19
18
|
|
|
20
19
|
const init = onetime(async () => {
|
|
21
20
|
span.addEvent('init')
|
|
22
|
-
filenames = await
|
|
21
|
+
filenames = await globFn(pattern, options)
|
|
23
22
|
return filenames.length === 0
|
|
24
23
|
})
|
|
25
24
|
|
package/index.d.ts
CHANGED
|
@@ -9,5 +9,7 @@ export { default as nul } from "./dev-nul.js";
|
|
|
9
9
|
export { default as offset } from "./offset.js";
|
|
10
10
|
export * from "./process.js";
|
|
11
11
|
export { default as toString } from "./toString.js";
|
|
12
|
+
export { default as batch } from "./batch.js";
|
|
13
|
+
export { from as streamValues } from "./Readable.js";
|
|
12
14
|
export { default as concat, object as concatObject } from "./concat.js";
|
|
13
15
|
export { parse as jsonParse, stringify as jsonStringify } from "./json.js";
|
package/index.js
CHANGED
|
@@ -11,3 +11,5 @@ export { default as nul } from './dev-nul.js'
|
|
|
11
11
|
export { default as offset } from './offset.js'
|
|
12
12
|
export * from './process.js'
|
|
13
13
|
export { default as toString } from './toString.js'
|
|
14
|
+
export { default as batch } from './batch.js'
|
|
15
|
+
export { from as streamValues } from './Readable.js'
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "barnard59-base",
|
|
3
|
-
"version": "2.4.
|
|
3
|
+
"version": "2.4.1",
|
|
4
4
|
"description": "Linked Data pipelines",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"scripts": {
|
|
8
8
|
"test": "mocha",
|
|
9
|
-
"prebuild": "rimraf *.d.ts",
|
|
9
|
+
"prebuild": "rimraf -g *.d.ts",
|
|
10
10
|
"build": "tsc",
|
|
11
11
|
"prepack": "npm run build"
|
|
12
12
|
},
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"dependencies": {
|
|
26
26
|
"@opentelemetry/api": "^1.0.1",
|
|
27
27
|
"duplexify": "^4.1.1",
|
|
28
|
-
"glob": "^
|
|
28
|
+
"glob": "^10",
|
|
29
29
|
"onetime": "^6.0.0",
|
|
30
30
|
"parallel-transform": "^1.2.0",
|
|
31
31
|
"readable-stream": "^3.0.6",
|
|
@@ -34,12 +34,11 @@
|
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
36
|
"@types/duplexify": "^3.6.4",
|
|
37
|
-
"@types/glob": "^7.2.0",
|
|
38
37
|
"@types/parallel-transform": "^1.1.4",
|
|
39
|
-
"@types/readable-stream": "^4.0.
|
|
38
|
+
"@types/readable-stream": "^4.0.11",
|
|
40
39
|
"@types/readable-to-readable": "^0.1.0",
|
|
41
40
|
"@types/through2": "^2.0.41",
|
|
42
|
-
"barnard59-core": "^
|
|
41
|
+
"barnard59-core": "^6.0.0",
|
|
43
42
|
"chai": "^4.3.10",
|
|
44
43
|
"get-stream": "^6.0.1",
|
|
45
44
|
"into-stream": "^7.0.0",
|
package/test/glob.test.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { deepStrictEqual, strictEqual } from 'assert'
|
|
2
1
|
import { array } from 'get-stream'
|
|
3
2
|
import { isReadableStream as isReadable, isWritableStream as isWritable } from 'is-stream'
|
|
4
3
|
import sinon from 'sinon'
|
|
@@ -19,15 +18,11 @@ describe('glob', () => {
|
|
|
19
18
|
}
|
|
20
19
|
})
|
|
21
20
|
|
|
22
|
-
it('should be a function', () => {
|
|
23
|
-
strictEqual(typeof glob, 'function')
|
|
24
|
-
})
|
|
25
|
-
|
|
26
21
|
it('should return a Readable stream', () => {
|
|
27
22
|
const s = glob.call({ logger }, { pattern: 'test/support/*' })
|
|
28
23
|
|
|
29
|
-
|
|
30
|
-
|
|
24
|
+
expect(isReadable(s)).to.be.true
|
|
25
|
+
expect(isWritable(s)).to.be.false
|
|
31
26
|
})
|
|
32
27
|
|
|
33
28
|
it('should emit each file name as a chunk', async () => {
|
|
@@ -35,7 +30,7 @@ describe('glob', () => {
|
|
|
35
30
|
|
|
36
31
|
const filenames = await array(s)
|
|
37
32
|
|
|
38
|
-
|
|
33
|
+
expect(filenames).to.contain.all.members([
|
|
39
34
|
'../../test/e2e/definitions/foreach/csv-duplicate.ttl',
|
|
40
35
|
'../../test/e2e/definitions/foreach/with-handler.ttl',
|
|
41
36
|
'../../test/e2e/definitions/foreach/with-variable.ttl',
|
|
@@ -50,7 +45,7 @@ describe('glob', () => {
|
|
|
50
45
|
|
|
51
46
|
const filenames = await array(s)
|
|
52
47
|
|
|
53
|
-
|
|
48
|
+
expect(filenames).to.contain.all.members([
|
|
54
49
|
'csv-duplicate.ttl',
|
|
55
50
|
'with-handler.ttl',
|
|
56
51
|
'with-variable.ttl',
|