rhalff / dot-object

Transform json objects using dot notation
MIT License
471 stars 46 forks source link

Modifiers only process properties with separators #38

Closed ackushiw closed 5 years ago

ackushiw commented 5 years ago

Modifiers on root properties do not process the transformation

var dot = require('dot-object');

var row = {
  'nr': 200,
  'nested.nr': 200,
};

var mods = {
  'nr': [val => val * 2],
  'nested.nr': [val => val * 2]
};

dot.object(row, mods);

console.log(row);

Result:

{
  nr: 200,
  nested: {
    nr: 400
  }
}

Expected:

{
  nr: 400,
  nested: {
     nr: 400
  }
}
rhalff commented 5 years ago

This should work if override is set to true.

There is also a test preventing this:

should not process non dot value with modifier when override is false

This test however doesn't make much sense to me now and causes unexpected and even erroneous behavior, so I'll update the test and remove the requirement to set override to true.

rhalff commented 5 years ago

Fixed in new version released as v1.9.0