1 // Copyright 2022-present 650 Industries. All rights reserved. 2 3 public extension JavaScriptRuntime { 4 /** 5 Evaluates JavaScript code represented as a string. 6 7 - Parameter source: A string representing a JavaScript expression, statement, or sequence of statements. 8 The expression can include variables and properties of existing objects. 9 - Returns: The completion value of evaluating the given code represented as `JavaScriptValue`. 10 If the completion value is empty, `undefined` is returned. 11 - Note: It wraps the original `evaluateScript` to better handle and rethrow exceptions. 12 */ 13 func eval(_ source: String) throws -> JavaScriptValue { 14 return try evaluateScript(source) 15 } 16 } 17