(cm1, f)
| 1285 | |
| 1286 | // Wraps a function in an operation. Returns the wrapped function. |
| 1287 | function operation(cm1, f) { |
| 1288 | return function() { |
| 1289 | var cm = cm1 || this, withOp = !cm.curOp; |
| 1290 | if (withOp) startOperation(cm); |
| 1291 | try { var result = f.apply(cm, arguments); } |
| 1292 | finally { if (withOp) endOperation(cm); } |
| 1293 | return result; |
| 1294 | }; |
| 1295 | } |
| 1296 | function docOperation(f) { |
| 1297 | return function() { |
| 1298 | var withOp = this.cm && !this.cm.curOp, result; |
no test coverage detected