js_validate_script {js} | R Documentation |
Validate JavaScript
Description
Simple wrapper for ct$validate
in V8
.
Tests if code constitutes a syntactically valid JS script.
Usage
js_validate_script(text, error = TRUE)
Arguments
text |
character vector with JavaScript code |
error |
raise error on invalid code |
Examples
js_validate_script("function foo(x){2*x}") #TRUE
js_validate_script("foo = function(x){2*x}") #TRUE
# Anonymous functions in global scope are invalid
js_validate_script("function(x){2*x}", error = FALSE) #FALSE
# Use ! or () to check anonymous function syntax
js_validate_script("!function(x){2*x}") #TRUE
js_validate_script("(function(x){2*x})") #TRUE
[Package js version 1.2 Index]