zikaari / aspen-core Goto Github PK
View Code? Open in Web Editor NEWLicense: MIT License
License: MIT License
Benchmarks show subarraying
is twice as fast than slicing
, because slicing
"copies", but subarraying
"references" the value(s).
Before this change can be patched into master, we need an automated benchmarking suite along with unit testing to ensure we don't break things and at the same time don't slow down exisiting implementation.
Hi! I'm trying to write a function that iterates through the whole tree to find all items that a decoration applies to (incl. cascading targets targeted by SelfAndChildren and not negated).
I tried something like this:
function getActiveFilesCascade(model: FileTreeModel) {
const activeFiles: FileOrDir[] = [];
model.root.iterateTopDown((item, next, stepIn, stepOut) => {
if (!item) return stepOut();
const decorations = model.decorations.getDecorations(item);
if (decorations.classlist.indexOf('active') !== -1) {
activeFiles.push(item);
}
if (item.type === FileType.Directory) {
return stepIn();
}
next();
});
return activeFiles;
}
given a tree like this
root
- A
- B
- C
- D
- E
This iterates [A, B, C, D, null, null]. It never gets to E.
The problem seems to be that it doesn't return to the previous iterator after stepOut. I wonder if this might be an implementation bug in iterateTopDown? If I understand correctly, stepIn puts the next iterator on the stack, and stepOut pops that same iterator, while not allowing to pop the first level. So how can we resume the top level iterator?
Or maybe there is another easier or more performant way to achieve this (find all items a decoration applies to)?
Multiple "roots" and special items (like "buttons" at the bottom, or section separators, or an item at the top of the list describing the root directory, etc.) can be added by essentially making a virtual filesystem using the IBasicFileSystemHost
. However, this is a lot of effort and it would be nice to know other solutions to the problem.
Does anything like this currently exist? If not, do you have plans to add any?
Edit: By "multiple roots", I mean displaying items as siblings in the model when they aren't actually siblings on the real filesystem (for example, displaying /home/logandark/folder1
and /etc/whatever
). AFAIK, since aspen only represents items as having a filename and not a path, this is currently impossible just by adding items to the model, even if those items are artificially injected. But feel free to correct me if I'm wrong.
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.