lukasbuenger / immutable-treeutils Goto Github PK
View Code? Open in Web Editor NEWFunctional tree traversal helpers for ImmutableJS data structures
License: MIT License
Functional tree traversal helpers for ImmutableJS data structures
License: MIT License
Hello there,
Thank you very much for this Library !
I am quite experienced in React/Redux but quite new to Inmutable.js,
I have set up a simple experiment but I dont manage to get it working,
Could you maybe point out what I am missing here:
import { fromJS } from "immutable";
import TreeUtils from "immutable-treeutils";
const initialState = fromJS({
id: "root",
name: "root",
childNodes: [
{
id: "level1a",
name: "level1a",
childNodes: []
},
{
id: "level1b",
name: "level1b",
childNodes: [
{
id: "level2a",
name: "level2a",
childNodes: []
},
{
id: "level2b",
name: "level2b",
childNodes: []
}
]
}
]
});
const treeUtils = new TreeUtils();
console.log("Find node level1a", treeUtils.id(initialState, 'level1a')); //Undefined
Thanks !
In issue #9, @lukasbuenger decided to remove all ES6 features from this project. Unfortunately, it seems like there is one ES6 feature remaining in the codebase. for...of
was introduced in ES6, and as a result, it's still causing problems for UglifyJS (and presumably, other software that only works with ES5).
ERROR in application.js from UglifyJs
Unexpected token name «of», expected punc «;» [/Users/singingwolfboy/clones/impraise-web/node_modules/immutable-treeutils/index.js:165,0][application.js:215807,17]
Personally, I'm happy to switch to uglify-es
, which is compatible with ES6, but since the author specifically made this change to avoid this kind of compatibility conflict, I wanted to raise this issue.
In many cases it is useful/essential to rely on predictable tree traversal order.
DFS variants include in-order, post-order, pre-order [1]; BFS is knowns as level-order.
The current contract of walk()
is arbitrary-order, although it appears to be doing a reverse of post-order
.
[1] https://en.wikipedia.org/wiki/Tree_traversal#Depth-first_search
I'm running node 8.3.0 without babel.
When trying to include treeutils like this const TreeUtils = require('immutable-treeutils')
. I'm getting the following error:
/Users/patte/src/haku-backend/node_modules/immutable-treeutils/lib/TreeUtils.js:142
value: regeneratorRuntime.mark(function nodes(state, path) {
^
ReferenceError: regeneratorRuntime is not defined
at /Users/patte/src/haku-backend/node_modules/immutable-treeutils/lib/TreeUtils.js:142:10
at Object.<anonymous> (/Users/patte/src/haku-backend/node_modules/immutable-treeutils/lib/TreeUtils.js:1042:2)
at Module._compile (module.js:573:30)
at Object.Module._extensions..js (module.js:584:10)
at Module.load (module.js:507:32)
at tryModuleLoad (module.js:470:12)
at Function.Module._load (module.js:462:3)
at Module.require (module.js:517:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (/Users/patte/republik/src/haku-backend/graphql/resolvers/Document.js:3:19)
at Module._compile (module.js:573:30)
at Object.Module._extensions..js (module.js:584:10)
at Module.load (module.js:507:32)
at tryModuleLoad (module.js:470:12)
at Function.Module._load (module.js:462:3)
at Module.require (module.js:517:17)
[nodemon] app crashed - waiting for file changes before starting...
At the moment trees are always traversed in level order (Breadth-first search). I propose to add an option to change the default tree traversal type.
Hi :)
thank you first for the library.
0.1.11 introduces a breaking change (but is a patch release) and removes all babel compiler hints / .babelrc file. It's not usable in a out of the box babel/webpack configuration anymore.
Is there any migration path?
david
Hi, I just migrated to babel6. If you are interested in, i will send PR.
Thanks,
Kei
It'd be nice to support the next Immutable version even it's still in release-candidate phase.
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.