1.2.3 • Published 2 years ago
nested-data-navigator v1.2.3
nested-data-navigator

Nested Data Navigator is a lightweight JavaScript package for navigating and retrieving values from nested data structures.
Install
You can install the package using npm:
npm install nested-data-navigator
Usage
const { grabValue, grabPath } = require("nested-data-navigator");
var person = {
firstName: "Ali",
lastName: "Parsa",
age: 21,
info: {
address: {
city: 'New York',
zip: '10001',
}
}
};
console.log(grabValue(person, "info.city", "default value")) //=> 'New Yourk'
console.log(grabPath(person, "info.city", "default value")) //=> '.info.address.city'
Example
You can grab value or path without select parents:
const { grabValue, grabPath } = require("nested-data-navigator");
var sample_1 = {
firstName: "Ali",
lastName: "Parsa",
age: 21,
info: {
address: {
city: 'New York',
zip: '10001',
}
}
};
var sample_2 = {
firstName: "Ali",
lastName: "Parsa",
age: 21,
info: {
location: {
city: 'Canada',
zip: '10001',
}
}
};
console.log(grabValue(sample_1, "info.city")) //=> 'New York'
console.log(grabPath(person, "info.city")) //=> '.info.address.city'
console.log(grabValue(sample_2, "city")) //=> 'Canada'
console.log(grabPath(person, "city")) //=> '.info.location.city'
console.log(grabValue(sample_2, "info.wrong","not found!")) //=> 'not found!'
1.2.3
2 years ago
1.2.1
2 years ago
1.1.4
2 years ago
1.1.3
2 years ago
1.1.2
2 years ago
1.1.1
2 years ago
1.1.0
2 years ago
1.0.15
2 years ago
1.0.14
2 years ago
1.0.13
2 years ago
1.0.12
2 years ago
1.0.11
2 years ago
1.0.10
2 years ago
1.0.9
2 years ago
1.0.8
2 years ago
1.0.7
2 years ago
1.0.6
2 years ago
1.0.5
2 years ago
1.0.4
2 years ago
1.0.3
2 years ago
1.0.2
2 years ago
1.0.1
2 years ago
1.0.0
2 years ago