Skip to content

Commit c0360e8

Browse files
authored
Switch to ES Modules and balanced-match 3.0.0 (#62)
1 parent 2520537 commit c0360e8

14 files changed

+53
-47
lines changed

bench/bench.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
'use strict';
2-
const expand = require('..');
3-
const fs = require('fs');
4-
const resfile = __dirname + '/../test/cases.txt';
1+
import expand from '..';
2+
import fs from 'fs';
3+
4+
const resfile = new URL('../test/cases.txt', import.meta.url);
55
const cases = fs.readFileSync(resfile, 'utf8').split('\n');
66

77
bench('Average', function() {

example.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const expand = require('./');
1+
import expand from './index.js'
22

33
console.log(expand('http://any.org/archive{1996..1999}/vol{1..4}/part{a,b,c}.html'));
44
console.log(expand('http://www.numericals.com/file{1..100..10}.txt'));

index.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const balanced = require('balanced-match');
1+
import balanced from 'balanced-match';
22

33
const escSlash = '\0SLASH'+Math.random()+'\0';
44
const escOpen = '\0OPEN'+Math.random()+'\0';
@@ -71,7 +71,7 @@ function parseCommaParts(str) {
7171
/**
7272
* @param {string} str
7373
*/
74-
function expandTop(str) {
74+
export default function expandTop(str) {
7575
if (!str)
7676
return [];
7777

@@ -231,5 +231,3 @@ function expand(str, isTop) {
231231

232232
return expansions;
233233
}
234-
235-
module.exports = expandTop;

package-lock.json

Lines changed: 10 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,15 @@
77
"url": "git://github.com/juliangruber/brace-expansion.git"
88
},
99
"homepage": "https://github.com/juliangruber/brace-expansion",
10-
"main": "index.js",
10+
"exports": "./index.js",
11+
"type": "module",
1112
"scripts": {
1213
"test": "node--test",
1314
"gentest": "bash test/generate.sh",
1415
"bench": "matcha bench/bench.js"
1516
},
1617
"dependencies": {
17-
"balanced-match": "^1.0.0"
18+
"balanced-match": "^3.0.0"
1819
},
1920
"devDependencies": {
2021
"@c4312/matcha": "^1.3.1",
@@ -42,5 +43,8 @@
4243
"iphone/6.0..latest",
4344
"android-browser/4.2..latest"
4445
]
46+
},
47+
"engines": {
48+
"node": ">= 16"
4549
}
4650
}

test/bash-comparison.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
const test = require('test');
2-
const assert = require('assert');
3-
const expand = require('..');
4-
const fs = require('fs');
5-
const resfile = __dirname + '/bash-results.txt';
1+
import test from 'node:test';
2+
import assert from 'assert';
3+
import expand from '../index.js';
4+
import fs from 'fs';
5+
6+
const resfile = new URL('./bash-results.txt', import.meta.url);
67
const cases = fs.readFileSync(resfile, 'utf8').split('><><><><');
78

89
// throw away the EOF marker

test/dollar.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
const test = require('test');
2-
const assert = require('assert');
3-
const expand = require('..');
1+
import test from 'node:test';
2+
import assert from 'assert';
3+
import expand from '../index.js';
44

55
test('ignores ${', function() {
66
assert.deepStrictEqual(expand('${1..3}'), ['${1..3}']);

test/empty-option.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
const test = require('test');
2-
const assert = require('assert');
3-
const expand = require('..');
1+
import test from 'node:test';
2+
import assert from 'assert';
3+
import expand from '../index.js';
44

55
test('empty option', function() {
66
assert.deepStrictEqual(expand('-v{,,,,}'), [

test/negative-increment.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
const test = require('test');
2-
const assert = require('assert');
3-
const expand = require('..');
1+
import test from 'node:test';
2+
import assert from 'assert';
3+
import expand from '../index.js';
44

55
test('negative increment', function() {
66
assert.deepStrictEqual(expand('{3..1}'), ['3', '2', '1']);

test/nested.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
const test = require('test');
2-
const assert = require('assert');
3-
const expand = require('..');
1+
import test from 'node:test';
2+
import assert from 'assert';
3+
import expand from '../index.js';
44

55
test('nested', function() {
66
assert.deepStrictEqual(expand('{a,b{1..3},c}'), [

0 commit comments

Comments
 (0)