This repository has been archived by the owner on Mar 10, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 299
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
License: MIT Signed-off-by: Alan Shaw <[email protected]>
- Loading branch information
Alan Shaw
committed
Jul 26, 2019
1 parent
e6f97d3
commit d84716a
Showing
3 changed files
with
39 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,50 @@ | ||
'use strict' | ||
|
||
const callbackify = require('../lib/callbackify') | ||
const nodeify = require('promise-nodeify') | ||
|
||
// This file is temporary and for compatibility with legacy usage | ||
module.exports = (send, options) => { | ||
if (typeof send !== 'function') { | ||
options = send | ||
} | ||
|
||
const ls = require('./ls')(options) | ||
const peers = require('./peers')(options) | ||
const publish = require('./publish')(options) | ||
const subscribe = require('./subscribe')(options) | ||
const unsubscribe = require('./unsubscribe')(options) | ||
|
||
return { | ||
ls: callbackify(require('./ls')(options)), | ||
peers: callbackify(require('./peers')(options)), | ||
publish: callbackify(require('./publish')(options)), | ||
subscribe: callbackify(require('./subscribe')(options), { minArgs: 2 }), | ||
unsubscribe: callbackify(require('./unsubscribe')(options), { minArgs: 2 }) | ||
ls: (options, callback) => { | ||
if (typeof options === 'function') { | ||
callback = options | ||
options = {} | ||
} | ||
return nodeify(ls(options), callback) | ||
}, | ||
peers: (topic, options, callback) => { | ||
if (typeof options === 'function') { | ||
callback = options | ||
options = {} | ||
} | ||
return nodeify(peers(topic, options), callback) | ||
}, | ||
publish: (topic, data, options, callback) => { | ||
if (typeof options === 'function') { | ||
callback = options | ||
options = {} | ||
} | ||
return nodeify(publish(topic, data, options), callback) | ||
}, | ||
subscribe: (topic, handler, options, callback) => { | ||
if (typeof options === 'function') { | ||
callback = options | ||
options = {} | ||
} | ||
return nodeify(subscribe(topic, handler, options), callback) | ||
}, | ||
unsubscribe: (topic, handler, callback) => { | ||
return nodeify(unsubscribe(topic, handler), callback) | ||
} | ||
} | ||
} |