GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fs: implement glob natively · nodejs/node@a8f2bf0

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • .github/workflows
    • tools.yml
  • LICENSE
  • benchmark
    • fs
      • bench-glob-options.js
      • bench-glob.js
    • path
      • matchesGlob-posix.js
      • matchesGlob-win32.js
  • deps/minimatch
    • LICENSE.md
    • README.md
    • dist
      • commonjs
        • assert-valid-pattern.d.ts.map
        • assert-valid-pattern.d.ts
        • assert-valid-pattern.js.map
        • assert-valid-pattern.js
        • ast.d.ts.map
        • ast.d.ts
        • ast.js.map
        • ast.js
        • brace-expressions.d.ts.map
        • brace-expressions.d.ts
        • brace-expressions.js.map
        • brace-expressions.js
        • escape.d.ts.map
        • escape.d.ts
        • escape.js.map
        • escape.js
        • index.d.ts.map
        • index.d.ts
        • index.js.map
        • index.js
        • package.json
        • unescape.d.ts.map
        • unescape.d.ts
        • unescape.js.map
        • unescape.js
      • esm
        • assert-valid-pattern.d.ts.map
        • assert-valid-pattern.d.ts
        • assert-valid-pattern.js.map
        • assert-valid-pattern.js
        • ast.d.ts.map
        • ast.d.ts
        • ast.js.map
        • ast.js
        • brace-expressions.d.ts.map
        • brace-expressions.d.ts
        • brace-expressions.js.map
        • brace-expressions.js
        • escape.d.ts.map
        • escape.d.ts
        • escape.js.map
        • escape.js
        • index.d.ts.map
        • index.d.ts
        • index.js.map
        • index.js
        • package.json
        • unescape.d.ts.map
        • unescape.d.ts
        • unescape.js.map
        • unescape.js
    • index.js
    • package-lock.json
    • package.json
  • doc
    • api
      • fs.md
      • path.md
    • contributing/maintaining
      • maintaining-dependencies.md
  • lib
    • fs.js
    • internal
      • fs
        • glob.js
        • watchers.js
      • test_runner
        • coverage.js
        • runner.js
  • node.gyp
  • src
    • async_wrap.h
    • base_object_types.h
    • env_properties.h
    • glob
      • glob_ast.h
      • glob_matcher.cc
      • glob_matcher.h
      • glob_parser.cc
      • glob_parser.h
      • glob_program.cc
      • glob_program.h
      • glob_unicode.cc
      • glob_unicode.h
      • glob_walker.cc
      • glob_walker.h
      • node_glob.cc
      • node_glob.h
    • lru_cache-inl.h
    • node_binding.cc
    • node_binding.h
    • node_external_reference.h
    • node_snapshotable.cc
    • node_util.cc
    • path.cc
    • path.h
    • permission
      • fs_permission.cc
      • fs_permission.h
      • permission.cc
      • permission.h
    • util-inl.h
  • test
    • parallel
      • test-fs-glob-exclude-function-async.mjs
      • test-fs-glob-permission-async.mjs
      • test-fs-glob-permission-audit.mjs
      • test-fs-glob-permission-drop.mjs
      • test-fs-glob-permission-subtree.mjs
      • test-glob-syntax.js
    • sequential
      • test-async-wrap-getasyncid.js
  • tools
    • dep_updaters
      • update-minimatch.sh
    • license-builder.sh

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Dismiss banner
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎.github/workflows/tools.yml‎

Copy file name to clipboardExpand all lines: .github/workflows/tools.yml
-9Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ on:
2929
- libffi
3030
- libuv
3131
- llhttp
32-
- minimatch
3332
- nbytes
3433
- nixpkgs-unstable
3534
- nghttp2
@@ -187,14 +186,6 @@ jobs:
187186
cat temp-output
188187
tail -n1 temp-output | grep "NEW_VERSION=" >> "$GITHUB_ENV" || true
189188
rm temp-output
190-
- id: minimatch
191-
subsystem: deps
192-
label: dependencies
193-
run: |
194-
./tools/dep_updaters/update-minimatch.sh > temp-output
195-
cat temp-output
196-
tail -n1 temp-output | grep "NEW_VERSION=" >> "$GITHUB_ENV" || true
197-
rm temp-output
198189
- id: nbytes
199190
subsystem: deps
200191
label: dependencies
Collapse file

‎LICENSE‎

Copy file name to clipboardExpand all lines: LICENSE
-59Lines changed: 0 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -2058,65 +2058,6 @@ The externally maintained libraries used by Node.js are:
20582058
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
20592059
"""
20602060

2061-
- minimatch, located at deps/minimatch, is licensed as follows:
2062-
"""
2063-
# Blue Oak Model License
2064-
2065-
Version 1.0.0
2066-
2067-
## Purpose
2068-
2069-
This license gives everyone as much permission to work with
2070-
this software as possible, while protecting contributors
2071-
from liability.
2072-
2073-
## Acceptance
2074-
2075-
In order to receive this license, you must agree to its
2076-
rules. The rules of this license are both obligations
2077-
under that agreement and conditions to your license.
2078-
You must not do anything with this software that triggers
2079-
a rule that you cannot or will not follow.
2080-
2081-
## Copyright
2082-
2083-
Each contributor licenses you to do everything with this
2084-
software that would otherwise infringe that contributor's
2085-
copyright in it.
2086-
2087-
## Notices
2088-
2089-
You must ensure that everyone who gets a copy of
2090-
any part of this software from you, with or without
2091-
changes, also gets the text of this license or a link to
2092-
<https://blueoakcouncil.org/license/1.0.0>.
2093-
2094-
## Excuse
2095-
2096-
If anyone notifies you in writing that you have not
2097-
complied with [Notices](#notices), you can keep your
2098-
license by taking all practical steps to comply within 30
2099-
days after the notice. If you do not do so, your license
2100-
ends immediately.
2101-
2102-
## Patent
2103-
2104-
Each contributor licenses you to do everything with this
2105-
software that would otherwise infringe any patent claims
2106-
they can license or become able to license.
2107-
2108-
## Reliability
2109-
2110-
No contributor can revoke this license.
2111-
2112-
## No Liability
2113-
2114-
**_As far as the law allows, this software comes as is,
2115-
without any warranty or condition, and no contributor
2116-
will be liable to anyone for any damages related to this
2117-
software or this license, under any kind of legal claim._**
2118-
"""
2119-
21202061
- npm, located at deps/npm, is licensed as follows:
21212062
"""
21222063
The npm application
Collapse file

‎benchmark/fs/bench-glob-options.js‎

Copy file name to clipboard
+78Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
'use strict';
2+
3+
const common = require('../common');
4+
const {
5+
glob,
6+
globSync,
7+
promises: { glob: globAsync },
8+
} = require('fs');
9+
const path = require('path');
10+
const assert = require('node:assert');
11+
12+
const benchmarkDirectory = path.resolve(__dirname, '..', '..');
13+
14+
const configs = {
15+
n: [1e3],
16+
dir: ['lib'],
17+
pattern: ['**/*.js'],
18+
mode: ['sync', 'promise', 'callback'],
19+
options: ['none', 'withFileTypes', 'exclude-pattern', 'exclude-callback'],
20+
};
21+
22+
const bench = common.createBenchmark(main, configs);
23+
24+
function buildOptions(config) {
25+
const options = { cwd: path.resolve(benchmarkDirectory, config.dir) };
26+
switch (config.options) {
27+
case 'none':
28+
break;
29+
case 'withFileTypes':
30+
options.withFileTypes = true;
31+
break;
32+
case 'exclude-pattern':
33+
options.exclude = ['**/internal/**'];
34+
break;
35+
case 'exclude-callback':
36+
// Excludes nothing: measures the per-entry callback overhead alone.
37+
options.exclude = () => false;
38+
break;
39+
default:
40+
throw new Error(`Unknown options: ${config.options}`);
41+
}
42+
return options;
43+
}
44+
45+
async function main(config) {
46+
const { pattern, mode, n } = config;
47+
const options = buildOptions(config);
48+
49+
let noDead;
50+
bench.start();
51+
52+
for (let i = 0; i < n; i++) {
53+
switch (mode) {
54+
case 'sync':
55+
noDead = globSync(pattern, options);
56+
break;
57+
case 'promise':
58+
noDead = await Array.fromAsync(globAsync(pattern, options));
59+
break;
60+
case 'callback':
61+
noDead = await new Promise((resolve, reject) => {
62+
glob(pattern, options, (err, matches) => {
63+
if (err) {
64+
reject(err);
65+
} else {
66+
resolve(matches);
67+
}
68+
});
69+
});
70+
break;
71+
default:
72+
throw new Error(`Unknown mode: ${mode}`);
73+
}
74+
}
75+
76+
bench.end(n);
77+
assert.ok(noDead.length > 0);
78+
}
Collapse file

‎benchmark/fs/bench-glob.js‎

Copy file name to clipboardExpand all lines: benchmark/fs/bench-glob.js
+16-22Lines changed: 16 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -14,53 +14,47 @@ const benchmarkDirectory = path.resolve(__dirname, '..', '..');
1414
const configs = {
1515
n: [1e3],
1616
dir: ['lib'],
17-
pattern: ['**/*', '*.js', '**/**.js'],
17+
pattern: ['**/*', '*.js', '**/*.js', '**/*.{js,json}'],
1818
mode: ['sync', 'promise', 'callback'],
1919
maxDepth: ['default', '2'],
20-
recursive: ['true', 'false'],
2120
};
2221

2322
const bench = common.createBenchmark(main, configs);
2423

2524
async function main(config) {
26-
const fullPath = path.resolve(benchmarkDirectory, config.dir);
27-
const { pattern, recursive, mode, maxDepth } = config;
28-
const options = { cwd: fullPath, recursive };
25+
const { pattern, mode, n, maxDepth } = config;
26+
const options = { cwd: path.resolve(benchmarkDirectory, config.dir) };
2927
if (maxDepth !== 'default') {
3028
options.maxDepth = Number(maxDepth);
3129
}
32-
const callback = (resolve, reject) => {
33-
glob(pattern, options, (err, matches) => {
34-
if (err) {
35-
reject(err);
36-
} else {
37-
resolve(matches);
38-
}
39-
});
40-
};
4130

4231
let noDead;
4332
bench.start();
4433

45-
for (let i = 0; i < config.n; i++) {
34+
for (let i = 0; i < n; i++) {
4635
switch (mode) {
4736
case 'sync':
4837
noDead = globSync(pattern, options);
4938
break;
5039
case 'promise':
51-
noDead = [];
52-
for await (const match of globAsync(pattern, options)) {
53-
noDead.push(match);
54-
}
40+
noDead = await Array.fromAsync(globAsync(pattern, options));
5541
break;
5642
case 'callback':
57-
noDead = await new Promise(callback);
43+
noDead = await new Promise((resolve, reject) => {
44+
glob(pattern, options, (err, matches) => {
45+
if (err) {
46+
reject(err);
47+
} else {
48+
resolve(matches);
49+
}
50+
});
51+
});
5852
break;
5953
default:
6054
throw new Error(`Unknown mode: ${mode}`);
6155
}
6256
}
6357

64-
bench.end(config.n);
65-
assert.ok(noDead);
58+
bench.end(n);
59+
assert.ok(noDead.length > 0);
6660
}
Collapse file

‎benchmark/path/matchesGlob-posix.js‎

Copy file name to clipboardExpand all lines: benchmark/path/matchesGlob-posix.js
+5-1Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,12 @@ const bench = common.createBenchmark(main, {
1010
'src/foo/bar/biz/baz/index.test.ts',
1111
],
1212
pattern: [
13+
'src/index.ts',
14+
'**/*.ts',
15+
'**/*.{ts,js}',
1316
'src/**/baz/*.test.ts',
1417
'src/**/baz/*.ts',
18+
'src/**/index.@(test|spec).ts',
1519
'test/**/*.ts',
1620
],
1721
n: [1e5],
@@ -24,5 +28,5 @@ function main({ path, pattern, n }) {
2428
a = posix.matchesGlob(path, pattern);
2529
}
2630
bench.end(n);
27-
assert(a + 'a');
31+
assert.strictEqual(typeof a, 'boolean');
2832
}
Collapse file

‎benchmark/path/matchesGlob-win32.js‎

Copy file name to clipboardExpand all lines: benchmark/path/matchesGlob-win32.js
+5-1Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,12 @@ const bench = common.createBenchmark(main, {
1111
'src\\foo\\bar\\biz\\baz\\index.test.ts',
1212
],
1313
pattern: [
14+
'src/index.ts',
15+
'**/*.ts',
16+
'**/*.{ts,js}',
1417
'src/**/baz/*.test.ts',
1518
'src/**/baz/*.ts',
19+
'src/**/index.@(test|spec).ts',
1620
'test/**/*.ts',
1721
],
1822
n: [1e5],
@@ -25,5 +29,5 @@ function main({ path, pattern, n }) {
2529
a = win32.matchesGlob(path, pattern);
2630
}
2731
bench.end(n);
28-
assert(a + 'a');
32+
assert.strictEqual(typeof a, 'boolean');
2933
}
Collapse file

‎deps/minimatch/LICENSE.md‎

Copy file name to clipboardExpand all lines: deps/minimatch/LICENSE.md
-55Lines changed: 0 additions & 55 deletions
This file was deleted.

0 commit comments

Comments
0 (0)
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.