Message from JavaScript discussions

November 2017

— Nice

— 

Added these recently

nodePaths - record a list of all paths in an object tree.
paths - record a list of all paths in an object tree, including primitives.
findPath - find a path (the first one seen) to a value.
findPaths - find all paths to a value.
findShortestPath - find the shortest path to a value.

— Will make it possible to have an indexing ORM database kind of thing

— Now I am thinking I'll write something that consumes the output of those functions... it is quite literally just an array of accessors, or an array of arrays of accessors, used to traverse linearly

Message permanent page

— FindPath -> find
findPaths -> filter

— Taken

— Crap

— Both those already exist in the lib

— They are just "deep" versions of the functions you have in Array.prototype

— Nice

— 

var subject = {
people: [
{
name: "Jon Snow",
number: 5555555555
},
{
name: "John Madden",
number: 1231231234
},
{
name: "Jimmy Neutron",
number: 0001112222
}
],
peopleCount: 3
};

// Will clone all numbers and their paths into a new Object
var copy = differentia.filter(subject, function (currentValue, accessor, subject) {
return typeof currentValue === "number";
});

console.log(copy);
// Logs:
/*
{
"peopleCount": 3,
"people": [
{
"number": 5555555555
},
{
"number": 1231231234
},
{
"number": 0001112222
}
]
}
*/

Message permanent page

— Could it be namespaced? .paths.find!