Mercurial > browser-couch
view worker-map-reducer.js @ 51:e29662aba1b6
Removed an annoying js2-mode warning.
author | Atul Varma <varmaa@toolness.com> |
---|---|
date | Tue, 14 Apr 2009 17:17:22 -0700 |
parents | a5e2db06b58d |
children |
line wrap: on
line source
function map(func, dict) { var mapDict = {}; var currDoc; function emit(key, value) { var item = mapDict[key]; if (!item) item = mapDict[key] = {keys: [], values: []}; item.keys.push(currDoc.id); item.values.push(value); } for (key in dict) { currDoc = dict[key]; func(currDoc, emit); } return mapDict; } function onmessage(event) { var mapFunc = eval("(" + event.data.map + ")"); postMessage(map(mapFunc, event.data.dict)); };