Skip to content

Commit

Permalink
Switch to ES Modules and balanced-match 3.0.0 (#62)
Browse files Browse the repository at this point in the history
  • Loading branch information
lanodan authored Oct 7, 2023
1 parent 2520537 commit c0360e8
Show file tree
Hide file tree
Showing 14 changed files with 53 additions and 47 deletions.
8 changes: 4 additions & 4 deletions bench/bench.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict';
const expand = require('..');
const fs = require('fs');
const resfile = __dirname + '/../test/cases.txt';
import expand from '..';
import fs from 'fs';

const resfile = new URL('../test/cases.txt', import.meta.url);
const cases = fs.readFileSync(resfile, 'utf8').split('\n');

bench('Average', function() {
Expand Down
2 changes: 1 addition & 1 deletion example.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const expand = require('./');
import expand from './index.js'

console.log(expand('http://any.org/archive{1996..1999}/vol{1..4}/part{a,b,c}.html'));
console.log(expand('http://www.numericals.com/file{1..100..10}.txt'));
Expand Down
6 changes: 2 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const balanced = require('balanced-match');
import balanced from 'balanced-match';

const escSlash = '\0SLASH'+Math.random()+'\0';
const escOpen = '\0OPEN'+Math.random()+'\0';
Expand Down Expand Up @@ -71,7 +71,7 @@ function parseCommaParts(str) {
/**
* @param {string} str
*/
function expandTop(str) {
export default function expandTop(str) {
if (!str)
return [];

Expand Down Expand Up @@ -231,5 +231,3 @@ function expand(str, isTop) {

return expansions;
}

module.exports = expandTop;
17 changes: 10 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 6 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,15 @@
"url": "git://github.com/juliangruber/brace-expansion.git"
},
"homepage": "https://github.com/juliangruber/brace-expansion",
"main": "index.js",
"exports": "./index.js",
"type": "module",
"scripts": {
"test": "node--test",
"gentest": "bash test/generate.sh",
"bench": "matcha bench/bench.js"
},
"dependencies": {
"balanced-match": "^1.0.0"
"balanced-match": "^3.0.0"
},
"devDependencies": {
"@c4312/matcha": "^1.3.1",
Expand Down Expand Up @@ -42,5 +43,8 @@
"iphone/6.0..latest",
"android-browser/4.2..latest"
]
},
"engines": {
"node": ">= 16"
}
}
11 changes: 6 additions & 5 deletions test/bash-comparison.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
const test = require('test');
const assert = require('assert');
const expand = require('..');
const fs = require('fs');
const resfile = __dirname + '/bash-results.txt';
import test from 'node:test';
import assert from 'assert';
import expand from '../index.js';
import fs from 'fs';

const resfile = new URL('./bash-results.txt', import.meta.url);
const cases = fs.readFileSync(resfile, 'utf8').split('><><><><');

// throw away the EOF marker
Expand Down
6 changes: 3 additions & 3 deletions test/dollar.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const test = require('test');
const assert = require('assert');
const expand = require('..');
import test from 'node:test';
import assert from 'assert';
import expand from '../index.js';

test('ignores ${', function() {
assert.deepStrictEqual(expand('${1..3}'), ['${1..3}']);
Expand Down
6 changes: 3 additions & 3 deletions test/empty-option.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const test = require('test');
const assert = require('assert');
const expand = require('..');
import test from 'node:test';
import assert from 'assert';
import expand from '../index.js';

test('empty option', function() {
assert.deepStrictEqual(expand('-v{,,,,}'), [
Expand Down
6 changes: 3 additions & 3 deletions test/negative-increment.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const test = require('test');
const assert = require('assert');
const expand = require('..');
import test from 'node:test';
import assert from 'assert';
import expand from '../index.js';

test('negative increment', function() {
assert.deepStrictEqual(expand('{3..1}'), ['3', '2', '1']);
Expand Down
6 changes: 3 additions & 3 deletions test/nested.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const test = require('test');
const assert = require('assert');
const expand = require('..');
import test from 'node:test';
import assert from 'assert';
import expand from '../index.js';

test('nested', function() {
assert.deepStrictEqual(expand('{a,b{1..3},c}'), [
Expand Down
6 changes: 3 additions & 3 deletions test/order.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const test = require('test');
const assert = require('assert');
const expand = require('..');
import test from 'node:test';
import assert from 'assert';
import expand from '../index.js';

test('order', function() {
assert.deepStrictEqual(expand('a{d,c,b}e'), [
Expand Down
6 changes: 3 additions & 3 deletions test/pad.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const test = require('test');
const assert = require('assert');
const expand = require('..');
import test from 'node:test';
import assert from 'assert';
import expand from '../index.js';

test('pad', function() {
assert.deepStrictEqual(expand('{9..11}'), [
Expand Down
6 changes: 3 additions & 3 deletions test/same-type.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const test = require('test');
const assert = require('assert');
const expand = require('..');
import test from 'node:test';
import assert from 'assert';
import expand from '../index.js';

test('x and y of same type', function() {
assert.deepStrictEqual(expand('{a..9}'), ['{a..9}']);
Expand Down
6 changes: 3 additions & 3 deletions test/sequence.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const test = require('test');
const assert = require('assert');
const expand = require('..');
import test from 'node:test';
import assert from 'assert';
import expand from '../index.js';

test('numeric sequences', function() {
assert.deepStrictEqual(expand('a{1..2}b{2..3}c'), [
Expand Down

0 comments on commit c0360e8

Please sign in to comment.