
Security News
Official Go SDK for MCP in Development, Stable Release Expected in August
The official Go SDK for the Model Context Protocol is in development, with a stable, production-ready release expected by August 2025.
object-tree
Advanced tools
npm install --save object-tree
var data = {
food: {
caramel: {
tastes: {
chocolate: 1.234
}
}
}
}
var ot = new ObjectTree()
var actual = ot.lookup('food.caramel.tastes.chocolate', data)
console.log(actual) // 1.234
var data = {
food: {
caramel: {
tastes: {
chocolate: 1.234
}
}
}
}
var ot = new ObjectTree({seperator: '::'})
var actual = ot.lookup('food::caramel::tastes::chocolate', data)
console.log(actual) // 1.234
var data = {
food: {
caramel: {
tastes: {
chocolate: 1.234
}
}
}
}
var ot = new ObjectTree()
var actual = ot.lookup(['food','caramel','tastes','chocolate','smells','code'], data)
console.log(actual) // 1.234
var data = {
food: {
caramel: {
tastes: {
chocolate: 1.234
}
}
}
}
var ot = new ObjectTree()
var actual = ot.lookup({'food':'caramel','tastes':'chocolate'}, data)
console.log(actual) // 1.234
var data = {
food: {
caramel: {
tastes: {
'*': 444,
chocolate: 1.234
}
}
}
}
var ot = new ObjectTree({
wildcard: '*'
})
var actual = ot.lookup({'food':'caramel','tastes':'flower'}, data)
console.log(actual) // 444
var ot = new ObjectTree()
var actual = ot.lookupTemplate('{food.caramel.tastes.chocolate}', {
food: {
'caramel': {
tastes: {
'chocolate': 1.234
}
}
}
}
)
assert.equal(actual, 1.234)
var ot = new ObjectTree({
template: {
left: '<',
right: '>'
}
})
var actual = ot.lookupTemplate('<food.caramel.tastes.chocolate>', {
food: {
'caramel': {
tastes: {
'chocolate': 1.234
}
}
}
}
)
assert.equal(actual, 1.234)
var tree = {
the: {
barn: {
'*': 0,
is: {
free: 1
}
},
food: {
is: {
tasty: 2
}
}
}
}
var ot = new ObjectTree({wildcard: '*'})
var eventBus = ot.generateFilters(tree)
eventBus.on('filter', function(value, filter, attrList) {
will be called 3 times:
// value=0, filter={the: 'barn'}, attrList=['the', 'barn']
// value=1, filter={the: 'barn', is: 'free'}, attrList=['the', 'barn', 'is', 'free']
// value=2, filter={the: 'food', is: 'tasty'}, attrList=['the', 'food', 'is', 'tasty']
})
eventBus.on('end', function() {
// no more 'filter' events
})
var obj = {attr1: false, attr2: true}
ot.set('attr2.nested1.nested2', Date.now(), obj)) // true
set returns true if the object was modified
FAQs
lookup js objects values from a flat structure
The npm package object-tree receives a total of 5 weekly downloads. As such, object-tree popularity was classified as not popular.
We found that object-tree demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
The official Go SDK for the Model Context Protocol is in development, with a stable, production-ready release expected by August 2025.
Security News
New research reveals that LLMs often fake understanding, passing benchmarks but failing to apply concepts or stay internally consistent.
Security News
Django has updated its security policies to reject AI-generated vulnerability reports that include fabricated or unverifiable content.