0.1.10 • Published 10 years ago

nodeobj-selector v0.1.10

Weekly downloads
1
License
ISC
Repository
-
Last release
10 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

10 years ago

0.1.9

10 years ago

0.1.8

10 years ago

0.1.7

10 years ago

0.1.6

10 years ago

0.1.5

10 years ago

0.1.4

10 years ago

0.1.3

10 years ago

0.1.2

10 years ago

0.1.1

10 years ago

0.1.0

10 years ago