promisified-dbus-native
Advanced tools
Comparing version 0.0.1 to 0.0.2
24
index.js
@@ -46,2 +46,3 @@ 'use strict'; | ||
const bus = createClient.apply(dbus, arguments); | ||
const getService = bus.getService; | ||
@@ -63,2 +64,25 @@ bus.getService = function(name) { | ||
} | ||
const getObject = bus.getObject; | ||
bus.getObject = function(path, name, callback) { | ||
if (typeof callback !== 'undefined') { | ||
return getObject.apply(bus, arguments); | ||
} else { | ||
return bus.getService(path).getObject(name); | ||
} | ||
} | ||
const getInterface = bus.getInterface; | ||
bus.getInterface = function(path, objname, name, callback) { | ||
if (typeof callback !== 'undefined') { | ||
return getInterface.apply(bus, arguments); | ||
} else { | ||
return new Promise((resolve, reject) => { | ||
bus.getService(path).getObject(objname) | ||
.then(obj => resolve(obj.as(name))) | ||
.catch(reject); | ||
}); | ||
} | ||
} | ||
return bus; | ||
@@ -65,0 +89,0 @@ } |
{ | ||
"name": "promisified-dbus-native", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"description": "promisified dbus-native", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
12
test.js
@@ -6,7 +6,11 @@ const dbus = require('./'); | ||
const service = await bus.getService('org.freedesktop.DBus'); | ||
const obj = await service.getObject('/org/freedesktop/DBus'); | ||
const iface = await obj.as('org.freedesktop.DBus.Introspectable'); | ||
const result = await iface.Introspect(); | ||
let obj = await service.getObject('/org/freedesktop/DBus'); | ||
let iface = await obj.as('org.freedesktop.DBus.Introspectable'); | ||
let result = await iface.Introspect(); | ||
console.log(result); | ||
obj = await bus.getObject('org.freedesktop.DBus', '/org/freedesktop/DBus'); | ||
iface = await bus.getInterface('org.freedesktop.DBus', '/org/freedesktop/DBus', 'org.freedesktop.DBus.Introspectable'); | ||
result = await iface.Introspect(); | ||
console.log(result); | ||
})(); | ||
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
4482
92