Skip to content
This repository was archived by the owner on Dec 20, 2024. It is now read-only.

Commit bedaa26

Browse files
committed
batch: remove side effects
1 parent e66d7f3 commit bedaa26

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

lib/batch.js

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,20 @@
11
var encodeKey = require('./encode-key');
22
var encodeValue = require('./encode-value');
33

4-
module.exports = function(ops, batchOptions, dbOptions){
5-
ops.forEach(function(op){
6-
op.key = encodeKey(op.key, [op, batchOptions, dbOptions]);
4+
module.exports = function(ops, optionObjects){
5+
return ops.map(function(_op){
6+
var localOptionObjects = [_op].concat(optionObjects);
77

8-
if ('value' in op) {
9-
op.value = encodeValue(op.value, [op, batchOptions, dbOptions]);
8+
var op = {
9+
type: _op.type,
10+
key: encodeKey(_op.key, localOptionObjects)
11+
};
12+
13+
if ('value' in _op) {
14+
op.value = encodeValue(_op.value, localOptionObjects);
1015
}
1116

12-
delete op.keyEncoding;
13-
delete op.valueEncoding;
14-
delete op.encoding;
17+
return op;
1518
});
1619
};
1720

0 commit comments

Comments
 (0)