Skip to content

Commit

Permalink
chore: mjs rewrite
Browse files Browse the repository at this point in the history
  • Loading branch information
FRSgit committed Jan 6, 2025
1 parent 5571e11 commit 290f4f7
Show file tree
Hide file tree
Showing 15 changed files with 168 additions and 3,805 deletions.
1 change: 0 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ jobs:
cache: 'pnpm'
- run: pnpm install
- run: pnpm lint
- run: pnpm build
- name: Unit tests & coverage
run: pnpm test:ci
- if: github.event_name == 'push' && github.ref == 'refs/heads/main'
Expand Down
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -245,15 +245,15 @@ const result = sync({

| Rank | Library | Average latency [ms] | Difference percentage (comparing to best average latency) |
| ---- | ----------------------------- | -------------------- | ----------------------------------------------------------------------------- |
| 1 | @frsource/frs-replace (sync) | 0.46 ± 1.06% | +0.00% |
| 2 | replace-in-file (sync) | 0.81 ± 1.37% | +78.29% |
| 3 | @frsource/frs-replace (async) | 1.82 ± 1.18% | +300.19% |
| 4 | replace-in-file (async) | 3.15 ± 1.33% | +591.39% |
| 1 | @frsource/frs-replace (async) | 0.61 ± 1.09% | +0.00% |
| 2 | @frsource/frs-replace (sync) | 0.71 ± 0.97% | +16.18% |
| 3 | replace-in-file (sync) | 0.86 ± 0.81% | +40.94% |
| 4 | replace-in-file (async) | 0.95 ± 1.55% | +56.40% |

### input & replacement as strings

| Rank | Library | Average latency [ms] | Difference percentage (comparing to best average latency) |
| ---- | ----------------------------- | -------------------- | ----------------------------------------------------------------------------- |
| 1 | @frsource/frs-replace (sync) | 0.01 ± 0.28% | +0.00% |
| 2 | @frsource/frs-replace (async) | 0.01 ± 0.27% | +11.43% |
| 3 | replaceString | 0.18 ± 0.93% | +2171.86% |
| 1 | @frsource/frs-replace (sync) | 0.00 ± 0.32% | +0.00% |
| 2 | @frsource/frs-replace (async) | 0.01 ± 0.36% | +18.69% |
| 3 | replaceString | 0.07 ± 1.23% | +1451.45% |
8 changes: 4 additions & 4 deletions benchmark/multiple-file-replace.bench.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ describe(`input as glob pattern [${inputFilesNo} files]`, () => {
bench(
'@frsource/frs-replace (async)',
async () => {
const { async } = await import('../src/index.js');
const { async } = await import('../src/index.mjs');
await async({
needle: regex,
replacement,
Expand All @@ -70,7 +70,7 @@ describe(`input as glob pattern [${inputFilesNo} files]`, () => {
bench(
'@frsource/frs-replace (sync)',
async () => {
const { sync } = await import('../src/index.js');
const { sync } = await import('../src/index.mjs');
sync({
needle: regex,
replacement,
Expand Down Expand Up @@ -111,7 +111,7 @@ describe('input & replacement as strings', () => {
bench(
'@frsource/frs-replace (async)',
async () => {
const { async } = await import('../src/index.js');
const { async } = await import('../src/index.mjs');
await async({
needle: regex.source,
replacement,
Expand All @@ -124,7 +124,7 @@ describe('input & replacement as strings', () => {
bench(
'@frsource/frs-replace (sync)',
async () => {
const { sync } = await import('../src/index.js');
const { sync } = await import('../src/index.mjs');
sync({
needle: regex.source,
replacement,
Expand Down
2 changes: 1 addition & 1 deletion bin/cli.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import { resolve } from 'path';
import yargs from 'yargs/yargs';
import { hideBin } from 'yargs/helpers';
import { sync } from '../dist/index.mjs';
import sync from '../src/sync.mjs';

(~process.argv.indexOf('--no-stdin')
? Promise.resolve()
Expand Down
19 changes: 6 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,11 @@
"frs-replace": "./bin/cli.mjs"
},
"type": "module",
"source": "src/index.ts",
"main": "dist/index.mjs",
"types": "dist/index.d.ts",
"exports": {
".": {
"types": "./dist/index.d.ts",
"default": "./dist/index.mjs"
},
".": "./src/index.mjs",
"./sync": "./src/sync.mjs",
"./async": "./src/async.mjs",
"./*": "./*.mjs"
},
"repository": "https://github.com/FRSOURCE/frs-replace.git",
Expand All @@ -26,7 +23,7 @@
"homepage": "https://github.com/FRSOURCE/frs-replace#readme",
"files": [
"bin/cli.mjs",
"dist",
"src/*.mjs",
"package.json"
],
"keywords": [
Expand All @@ -45,8 +42,7 @@
"javascript"
],
"scripts": {
"start": "pnpm clean && microbundle watch",
"build": "pnpm clean && microbundle src/index.ts --target node --compress -f modern",
"typecheck": "tsc --project tsconfig.json",
"release": "semantic-release",
"release:ci": "pnpm release --yes",
"test": "vitest",
Expand All @@ -57,8 +53,7 @@
"lint": "pnpm eslint && pnpm prettier",
"fix": "pnpm eslint --fix && prettier . --write",
"bench": "vitest bench",
"test:bench": "TEST_TYPE=bench vitest",
"clean": "rimraf dist"
"test:bench": "TEST_TYPE=bench vitest"
},
"devDependencies": {
"@frsource/eslint-config": "1.33.0",
Expand All @@ -78,11 +73,9 @@
"execa": "^9.5.2",
"globals": "^15.14.0",
"globals-vitest": "^1.6.0",
"microbundle": "^0.15.1",
"prettier": "^3.2.5",
"replace-in-file": "8.3.0",
"replace-string": "4.0.0",
"rimraf": "^5.0.5",
"semantic-release": "^23.0.8",
"tmp-promise": "3.0.3",
"typescript": "^5.4.5",
Expand Down
Loading

0 comments on commit 290f4f7

Please sign in to comment.