Skip to content

Commit 7a7b1c6

Browse files
committed
All my homies hate commonjs
1 parent 2f67322 commit 7a7b1c6

3 files changed

Lines changed: 12 additions & 5 deletions

File tree

index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
module.exports = function replaceAsync(string, searchValue, replacer) {
1+
export default function replaceAsync(string, searchValue, replacer) {
22
try {
33
if (typeof replacer === "function") {
44
// 1. Run fake pass of `replace`, collect values from `replacer` calls
@@ -22,4 +22,4 @@ module.exports = function replaceAsync(string, searchValue, replacer) {
2222
} catch (error) {
2323
return Promise.reject(error);
2424
}
25-
};
25+
}

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "string-replace-async",
3-
"version": "2.0.0",
3+
"version": "3.0.0",
44
"description": "Asynchronous String.prototype.replace()",
55
"license": "MIT",
66
"repository": "dsblv/string-replace-async",
@@ -9,8 +9,9 @@
99
"email": "disobolev@icloud.com",
1010
"url": "https://github.com/dsblv"
1111
},
12+
"type": "module",
1213
"engines": {
13-
"node": ">=0.12"
14+
"node": ">= 14.0.0"
1415
},
1516
"scripts": {
1617
"test": "jest"

readme.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,16 @@
88
$ npm install string-replace-async
99
```
1010

11+
**Note:** If you're using pre-14 version of Node or your node codebase isn't converted to [ES Modules](https://nodejs.org/api/esm.html#esm_introduction) yet, please use Version 2 specifically!
12+
13+
```
14+
$ npm install string-replace-async@^2.0.0
15+
```
16+
1117
## Usage
1218

1319
```js
14-
let replaceAsync = require("string-replace-async");
20+
import replaceAsync from "string-replace-async";
1521

1622
await replaceAsync("#rebeccapurple", /#(\w+)/g, async (match, name) => {
1723
let color = await getColorByName(name);

0 commit comments

Comments
 (0)