Comments (2)
Current architecture/implementation:
-
analysis
object which exposes API for analysis. -
plugins for analysing. Every plugin gets virtual file object as a first argument. This
file
object hasast
property. Then plugin should returnRx
observable which would emit copy offile
object enriched with metadata.
**- altough you can't assume that in the future versions Rx would be used at all. You should rather suppose that your plugin takes file object as a argument and return results via some sort of callback.
Current using of Rx is just implementation detail. So you would better split your plugin on two files: one written in Vanilla JS and second which be wrapper for current implementation in Rx. Check for example this:
https://github.com/hex13/lupa/blob/master/plugins/javascript.js
there is no Rx at all in this plugin. It's just glued later to work with Rx inanalysis.js
**file
object has such structure (it extends vinyl file object: https://github.com/gulpjs/vinyl )
{
// properties from Vinyl file objects
path: '.......',.
contents: new Buffer('......')
ast: {....} // parsed AST,
metadata: [
{type: 'function', name: 'onClick'},
{type: 'function', name: 'onMouseOver'},
] // array with metadata
}
Because mutable state easily can cause many bugs (been there, done that) and the test coverage is mediocre #9, plugins should treat file objects as immutable objects (i.e. clone objects instead of changing in-place).
But do not use file.clone()
because it would copy whole buffer (tried that and it was very slow. Use helper like Metadata.addMetadata
here (example plugin): https://github.com/hex13/lupa/blob/master/plugins/coffeescript.js
And notice that API is still unstable and probably many things change in the near future.
There are also some trade outs - cloning objects can take time and be memory costly. So maybe it would be better to consider some in-place mutable modifing but in the safe way? (mutability is not always bad).
And many things are not here yet. The project was rewritten from scratch few times. It took time. But now it's time to stabilize this whole thing.
from lupa.
Project is in maintenance only mode. I will fix potential bugs or make some slight improvements - but overally I've started already a new project which will be alternative to Lupa (it will allow for more detailed analysis than Lupa currently does).
So soon Lupa can either be deprecated or just rewritten (actually I'm rewriting from scratch all features, but I don't know if I will name new library e.g. Lupa 2 or create whole new name).
from lupa.
Related Issues (15)
- paths with asterisk.
- support for fluent interface doesn't work HOT 1
- pathes from `require` incorrectly resolved HOT 2
- TODO: default plugins for all files. HOT 1
- it doesn't detect require('foo').Bar HOT 1
- Which JavaScript parser should Lupa use? HOT 2
- TODO: remove old code 🚽 HOT 1
- TODO: more tests
- TODO: optimize 🚀
- hashbang in JS files causes error HOT 2
- add file information for entities
- using of `fs` module
- TODO: README
- TODO: scopes HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from lupa.