standardize some function signatures and factor out a lot of boilerplate

This commit is contained in:
ansuz
2020-02-03 18:32:21 -05:00
parent d1c6e67d17
commit 88be40ede3
5 changed files with 95 additions and 129 deletions

View File

@@ -5,6 +5,7 @@ const Meta = require("../metadata");
const BatchRead = require("../batch-read");
const WriteQueue = require("../write-queue");
const Core = require("./core");
const Util = require("../common-util");
const batchMetadata = BatchRead("GET_METADATA");
Data.getMetadata = function (Env, channel, cb) {
@@ -34,7 +35,9 @@ Data.getMetadata = function (Env, channel, cb) {
}
*/
var queueMetadata = WriteQueue();
Data.setMetadata = function (Env, data, unsafeKey, cb) {
Data.setMetadata = function (Env, safeKey, data, cb) {
var unsafeKey = Util.unescapeKeyCharacters(safeKey);
var channel = data.channel;
var command = data.command;
if (!channel || !Core.isValidId(channel)) { return void cb ('INVALID_CHAN'); }