aboutsummaryrefslogtreecommitdiff
path: root/README.md
diff options
context:
space:
mode:
authorAkshay Nair <phenax5@gmail.com>2022-02-17 21:43:14 +0530
committerAkshay Nair <phenax5@gmail.com>2022-02-17 21:43:14 +0530
commitd43d9e5933b1bc92e362321b054c951a4a4b000f (patch)
tree9ae9898e38da8647d3fefa71f213083862f3b6e3 /README.md
parent8de4bd6d732c3490a7d7a3d7433d8974b8592895 (diff)
downloadelxr-d43d9e5933b1bc92e362321b054c951a4a4b000f.tar.gz
elxr-d43d9e5933b1bc92e362321b054c951a4a4b000f.zip
docs: adds replaceAll example
Diffstat (limited to 'README.md')
-rw-r--r--README.md14
1 files changed, 14 insertions, 0 deletions
diff --git a/README.md b/README.md
index f6e4054..eb2c9ee 100644
--- a/README.md
+++ b/README.md
@@ -36,6 +36,9 @@ Whitespaces are ignored (except within literals)
### Examples
+
+#### matchAll
+
```js
// | Match for any number or any non-empty string or any object with `prop` is true
matchAll(/ \n | \s\T /, [null, 23, '', 'wow', false ]
@@ -81,3 +84,14 @@ matchAll(/ [seperator true], [id \s\T]+ /, [
// }
```
+
+#### replaceAll
+
+```js
+// | Match for any number or any non-empty string or any object with `prop` is true
+const replacer = (_, matches) => matches.value.reduce((a, b) => a + b, 0)
+replaceAll(/ \n+ /, replacer, [ 'start', 3, 5, 'mid', 2, 0, 4, 'end' ])
+
+// > [ 'start', 8, 'mid', 6, 'end' ]
+```
+