]>
git.kaiwu.me - njs.git/commit
Modules: added jsVarNames() method.
The method returns names of variables declared with js_var. An optional
string argument filters returned names by prefix.
This lets JavaScript code discover a configuration-defined variable schema
without duplicating every variable name in the script. For example:
js_var $extract_name;
js_var $extract_arguments_workspace;
function handler(r) {
r.jsVarNames("extract_").forEach(function(name) {
r.variables[name] = extract(name.slice(8));
});
}
The same API is available as s.jsVarNames() in stream. Variables created by
js_set or by the core modules are not returned.