From 7665e449cdfff1e660ed2bbac3de4507cb063a18 Mon Sep 17 00:00:00 2001 From: John Christopher Anderson Date: Mon, 27 Sep 2010 20:06:22 +0000 Subject: CommonJS support in map functions git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@1001895 13f79535-47bb-0310-9956-ffa450edef68 --- share/server/loop.js | 1 + share/server/state.js | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) (limited to 'share/server') diff --git a/share/server/loop.js b/share/server/loop.js index 300151e9..d5bbd977 100644 --- a/share/server/loop.js +++ b/share/server/loop.js @@ -100,6 +100,7 @@ var Loop = function() { // "view" : Views.handler, "reset" : State.reset, "add_fun" : State.addFun, + "add_lib" : State.addLib, "map_doc" : Views.mapDoc, "reduce" : Views.reduce, "rereduce" : Views.rereduce diff --git a/share/server/state.js b/share/server/state.js index 9af9e475..e6416382 100644 --- a/share/server/state.js +++ b/share/server/state.js @@ -14,6 +14,7 @@ var State = { reset : function(config) { // clear the globals and run gc State.funs = []; + State.lib = null; State.query_config = config || {}; init_sandbox(); gc(); @@ -21,7 +22,11 @@ var State = { }, addFun : function(newFun) { // Compile to a function and add it to funs array - State.funs.push(Couch.compileFunction(newFun)); + State.funs.push(Couch.compileFunction(newFun, {views : {lib : State.lib}})); + print("true"); + }, + addLib : function(lib) { + State.lib = lib; print("true"); } } -- cgit v1.2.3