Open acrisci opened 5 years ago
any news on this?
@Sun1ive I've released dbus-next on npm so people can start using it now if they want.
@Sun1ive I've released dbus-next on npm so people can start using it now if they want.
thank you! ill give it a try
Just a random thought, if this new interface is entirely optional, is it possible to simply hide it in versions less than node 7 and expose it in newer versions using the dynamic nature of javascript. By hiding 7+ language features in modules that are only brought in if node is 7+, one might be able to avoid throwing errors in older node in theory. Whether it's worth the extra transitional code or best to wait for the next major package rev is certainly debatable, but thought I'd mention it in case it's of any use to anyone.
function getNodeMajor()
{
var reg = /^[^\d]*(\d+)/;
var temp = reg.exec(process.version);
return (temp==null||temp[1]==null?0:parseInt(temp[1]));
}
module.exports.NodeMajor = getNodeMajor(); // only need to compute once
. . .
if (module.exports.NodeMajor >= 7)
{
// new feature just for 7+
const OptionalBit = require('optional-bit'); // module containing newer language features
module.exports.newThing = OptionalBit.newThing; // new package feature export
// etc etc
}
else
{
// fallback if any? or leave new stuff undefined?
module.exports.newThing = null; // ?
module.exports.newThing = function() { throw new Error('Feature needs Node 7+')}; // ?
}
Changes from my fork, dbus-next.
I use some ES6 stuff like destructuring and classes which might require bumping the required node version up to 6.0.
But other than that, no breaking changes! All the new interfaces are built on top of the existing low level interfaces and should not interfere with any of the existing code. Only 8 lines have been removed with minimal logic changes.
The README includes examples of the new interfaces.
Check out the new mpris controller script for a complete example of the client in action and doing something useful.
There's also a working example of the service interface.
All the new interfaces have very good integration tests which use a real dbus connection to test both the client and the service at the same time.
Run integration tests:
Coverage of the new interfaces is about 87 percent: