brojd / obj-traverse Goto Github PK
View Code? Open in Web Editor NEWLicense: MIT License
License: MIT License
I've written a somewhat similar library to this one, called object-scan. I actually believe that object-scan
would be well suited for powering this library, but I'm digressing...
Your demo looks really cool and I'm planning to do something similar. Ideally I would want to make the result editable at the same time as displaying it. Just wondering if you have some suggestions. Currently looking at Draft.js
and it looks promising.
I can't import any of the methods of the library. Not sure why. I am using Rollup instead of Webpack if that matters, as I noticed you have webpack code in the repo.
Here is the error from my server console:
'findFirst' is not exported by node_modules/obj-traverse/lib/obj-traverse.js, imported by src/node_modules/@sv/stores/manifest.js
...
4: import { findFirst } from 'obj-traverse/lib/obj-traverse'
^
UPD: This issue was invalid at the time it was created and not relevant, please ignore
Here is log:
module.js:549
throw err;
^
Error: Cannot find module 'obj-traverse'
at Function.Module._resolveFilename (module.js:547:15)
at Function.Module._load (module.js:474:25)
at Module.require (module.js:596:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (/app/index.js:10:20)
at Module._compile (module.js:652:30)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
at Function.Module._load (module.js:497:3)
at Function.Module.runMain (module.js:693:10)
at startup (bootstrap_node.js:191:16)
at bootstrap_node.js:612:3
Can you help me with this?
It's really nice that we can play with library without taking to the local environment.
Can you enhance the demo to add custom test data?
Please add feature to find by key only. Many cases where we don't know what a key value would be but we only know the key name. Also it would be nice to have a why to add new node
Title
I've run into an issue where if the value of my child is null, then an exception is thrown.
var tree = JSON.parse('{
"groupId": 1,
"displayName": "RootName",
"children": [
{
"groupId": 22,
"displayName": "Child Group 22",
"children": null, <-----------EXISTS BUT IS NULL
"hasChildren": true,
"groupType": "Organization",
"accessType": "Restricted"
},
{
"groupId": 9,
"displayName": "Child Group 9",
"children": null,<-----------EXISTS BUT IS NULL
"hasChildren": true,
"groupType": "Organization",
"accessType": "Restricted"
}
],
"hasChildren": false,
"groupType": "Organization",
"accessType": "Restricted"
}');
var newChildrenArray = JSON.parse('{
"groups": [
{
"groupId": 23,
"displayName": "Child of Child Group 22",
"children": null,
"hasChildren": false,
"groupType": "Organization",
"accessType": "Restricted"
}
]
}');
var parentId = 22;
Then executing as:
findAndModifyFirst(tree, "children", { groupdId: parentId }, { children: newChildrenArray["groups"] })
I would expect it to modify the tree to:
'{
"groupId": 1,
"displayName": "RootName",
"children": [
{
"groupId": 22,
"displayName": "Child Group 22",
"children": [
{
"groupId": 23,
"displayName": "Child of Child Group 22",
"children": null,
"hasChildren": false,
"groupType": "Organization",
"accessType": "Restricted"
}],
"hasChildren": true,
"groupType": "Organization",
"accessType": "Restricted"
},
{
"groupId": 9,
"displayName": "Child Group 9",
"children": null,
"hasChildren": true,
"groupType": "Organization",
"accessType": "Restricted"
}
],
"hasChildren": false,
"groupType": "Organization",
"accessType": "Restricted"
}
Instead it throws and exception ''cannot read length of undefined" for
obj-traverse.js line 2136: for (var i = 0; i < obj[childrenKey].length; i++) {
I attempted to modify the count
var childCount = (obj[childrenKey]) ? obj[childrenKey].length : 0;
for (var i = 0; i < childCount; i++) {
but it still throws and exception. Any thoughts on what I am doing wrong or a work around?
Need a way to perform multiple task. Example delete option, modify option
findFirst ( tree, 'children', { name8: ?} )
OR
findFirst ( tree, 'children', { ?: name8} )
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.