You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+58-1Lines changed: 58 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -91,8 +91,17 @@ function add(a, b) {
91
91
API
92
92
---------------------------------------
93
93
94
-
unassert package exports three functions. [`unassertAst`](https://github.com/unassert-js/unassert#const-modifiedast--unassertastast-options) is the main function. [`createVisitor`](https://github.com/unassert-js/unassert#const-visitor--createvisitoroptions) and [`defaultOptions`](https://github.com/unassert-js/unassert#const-options--defaultoptions) are for customization.
Remove assertion calls from the code. Default behaviour can be customized by `options`.
229
+
Note that the `ast` is manipulated directly.
230
+
231
+
#### MagicString
232
+
233
+
If a [MagicString](https://www.npmjs.com/package/magic-string) is passed instead of a normal string,
234
+
this function will simply modify that string and return it.
235
+
236
+
#### options
237
+
238
+
Object for configuration options. passed `options` is `Object.assign`ed with default options. If not passed, default options will be used.
239
+
240
+
##### options.modules
241
+
242
+
The same as for [`unassertAst`](#optionsmodules).
243
+
244
+
##### options.sourceMap
245
+
246
+
If `true`, a sourcemap of the changes will be generated in addition to the code.
247
+
248
+
You can alternatively specify [sourcemap options](https://github.com/rich-harris/magic-string#sgeneratemap-options-) if you which to customize how the sourcemap is generated.
204
249
205
250
### const visitor = createVisitor(options)
206
251
@@ -218,6 +263,18 @@ import { createVisitor } from 'unassert'
218
263
219
264
Create visitor object to be used with `estraverse.replace`. Visitor can be customized by `options`.
220
265
266
+
#### options
267
+
268
+
Object for configuration options. passed `options` is `Object.assign`ed with default options. If not passed, default options will be used.
269
+
270
+
##### options.modules
271
+
272
+
The same as for [`unassertAst`](#optionsmodules).
273
+
274
+
##### options.code
275
+
276
+
A [MagicString](https://www.npmjs.com/package/magic-string) of the code the ast represents.
277
+
If given, this code will be updated with the changes made to the ast.
0 commit comments