0.1.10 • Published 8 years ago

nodeobj-selector v0.1.10

Weekly downloads
1
License
ISC
Repository
-
Last release
8 years ago

nodeobj-selector

var selector = require('./nodeobj-selector.js')


var mydata = {
    a:[{
        helo:{
            a:1,
            b:2
        }
    },{
        helo:{
            a:3,
            b:4
        }
    },{
        helo:{
            a:5,
            b:6
        }
    }]
}

console.log(selector(mydata, ['a','[0:-1]','helo', 'a']))
// [ 1, 3, 5 ]

console.log(selector(mydata, ['a','[1:2]','helo', 'a']))
// [ 3, 5 ]

console.log(selector(mydata, ['helo', 'a']))
// [ 1, 3, 5 ]

console.log(selector(mydata, ['a']))
// [ [ { helo: [Object] }, { helo: [Object] }, { helo: [Object] } ],
//   1,
//   3,
//   5 ]

selector(mydata, ['a', '[0:-1]', 'helo', 'a'], function(data){
    console.log(' data: ', data)
    return data
})// the function is sync

console.log(JSON.stringify(mydata))

selector(mydata, ['a', '[0:-1]', 'helo', 'a'], function(data){
    return null 
})

console.log(JSON.stringify(mydata))

selector(mydata, ['a', '[0:-1]', 'helo', 'a'], function(data){
    return "123" 
})

console.log(JSON.stringify(mydata))

selector(mydata, ['a', '[0:-1]', 'helo', 'a'], function(data){
    // remove the object
})

console.log(JSON.stringify(mydata))
0.1.10

8 years ago

0.1.9

8 years ago

0.1.8

8 years ago

0.1.7

8 years ago

0.1.6

8 years ago

0.1.5

8 years ago

0.1.4

8 years ago

0.1.3

8 years ago

0.1.2

8 years ago

0.1.1

8 years ago

0.1.0

8 years ago