diff --git a/doc/api/vm.md b/doc/api/vm.md index defa029821aa00..e7aafb9e74e65c 100644 --- a/doc/api/vm.md +++ b/doc/api/vm.md @@ -637,6 +637,34 @@ console.log(globalVar); // 1000 ``` +## vm.compileFunction(code[, params[, options]]) + +* `code` {string} The body of the function to compile. +* `params` {string[]} An array of strings containing all parameters for the + function. +* `options` {Object} + * `filename` {string} Specifies the filename used in stack traces produced + by this script. **Default:** `''`. + * `lineOffset` {number} Specifies the line number offset that is displayed + in stack traces produced by this script. **Default:** `0`. + * `columnOffset` {number} Specifies the column number offset that is displayed + in stack traces produced by this script. **Default:** `0`. + * `cachedData` {Buffer} Provides an optional `Buffer` with V8's code cache + data for the supplied source. + * `produceCachedData` {boolean} Specifies whether to produce new cache data. + **Default:** `false`. + * `parsingContext` {Object} The sandbox/context in which the said function + should be compiled in. + * `contextExtensions` {Object[]} An array containing a collection of context + extensions (objects wrapping the current scope) to be applied while + compiling. **Default:** `[]`. + +Compiles the given code into the provided context/sandbox (if no context is +supplied, the current context is used), and returns it wrapped inside a +function with the given `params`. + ## vm.createContext([sandbox[, options]])