BME280 module refactor #828
Replies: 6 comments
-
Posted at 2015-11-07 by @gfwilliams That's great - thanks! As long as it's tested then yes, a PR would be really good. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2015-11-14 by Moray [edited] PR completed. In the end rather than strip down all the variable names, I made the new version compatible with Closure advanced optimisation and contributed a .min.js made via that route. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2015-11-14 by @allObjects
...will come to your knowledge-sharing brown-bag session/class about that. When and where will take place? |
Beta Was this translation helpful? Give feedback.
-
Posted at 2015-11-16 by @gfwilliams Thanks! It's interesting to see the changes needed to allow advanced optimisations. I might actually get rid of the |
Beta Was this translation helpful? Give feedback.
-
Posted at 2015-11-18 by Moray @allObjects it's pretty straightforward. The basic rule is refer to anything you don't want minified as an indirect property reference, so me.property should be written as me['property']. After minification is applied, this goes back to me.property, so although the unoptimised code looks more prolix, the minified is fine. The main problem seems to me that someone later will "improve" the unminified code so that it stops working with advanced optimisation. I looked at using the exports and externs options in advanced optimisation https://developers.google.com/closure/compiler/docs/api-tutorial3?hl=en but they don't work well for the Espruino use case as is. Externs could work with some changes to WebIDE perhaps. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2015-11-19 by Moray Just an aside on externs in Closure. In advanced compilation, it would be helpful to have an Espruino externs file which would prevent minification for example to methods of E or other Espruino bundled classes. I might have a go at this at some point. With more work, every module intended for Closure advanced optimisation could have an extern file to prevent references to it being minified when used with Closure. I am unlikely to find time for this. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2015-11-07 by Moray
The BME280 module is a bit unnecessarily large, so I'm refactoring it, primarily to remove unnecessary variable declarations and debugging code, reduce the length of non-minifiable public method names and generally tidy up a bit.
Is there a protocol for this sort of thing, eg discussing here, or should I just change and create a pull request?
FWIW here's the code, anything else?
Beta Was this translation helpful? Give feedback.
All reactions