dotpather-transform

2.0.1 • Public • Published

dotpather-transform

Build Status

tranform nested objects with dotpaths

install

npm i dotpather-transform

usage

 
var dotpather = require('dotpather-transform')
var transform = dotpather('one.two.three')
 
var data = {
  one: { 
    two: {
      three: 4
    }
  }
}
 
var transformed = transform(data, function(number) {
  return number + 1;
})
 
// { one: { two: { three: 5 } } }
 

You can also refer to array indexes

 
var transform = dotpather('one.two.three.1.five.1')
var data = {
  one: { 
    two: {
      three: [4, { five: [ 6, 7 ] }]
    }
  }
}
 
let obj = transform(data, function(number) {
  return number + 1;
})
 
// { one: { two: { three: [4, { five: [ 6, 8 ] } ] } } }
 

/dotpather-transform/

    Package Sidebar

    Install

    npm i dotpather-transform

    Weekly Downloads

    1

    Version

    2.0.1

    License

    ISC

    Unpacked Size

    6.2 kB

    Total Files

    6

    Last publish

    Collaborators

    • skinnyjames