Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
docs.forEach(function(third) { // document
var document = collection + '/' + third;
assert.equal(extname(third), '.bson');
var _id = third.split('.bson')[0];
var data = BSON.deserialize(fs.readFileSync(document, {
encoding: null
}));
assert.deepEqual(data, DOCS[_id]);
fs.unlinkSync(document);
});
fs.rmdirSync(collection);
s.on('message', function (ms) {
debug('Process ' + process.pid + ' received message: ' + ms);
const mo = BSON.deserialize(ms);
// Ignore invalid messages; this is probably worth an error, though
if (!isValidMessage(mo)) {
return;
}
let fd;
const fdSeq = mo[0];
const msg = mo[1];
// If our message has an associated file descriptor that we
// have not yet received, queue it for later delivery.
if (fdSeq) {
if (!(fd = fdWaitingForMsg[fdSeq])) {
msgWaitingForFd[fdSeq] = msg;
assert.equal(fs.statSync(database).isDirectory(), true);
var second = fs.readdirSync(database);
assert.equal(second.length, 2);
assert.equal(second[1], 'logins');
fs.unlinkSync(database + '/.metadata/' + second[1]);
var collection = database + '/' + second[1];
if (fs.statSync(collection).isDirectory() === false) {
return;
}
var docs = fs.readdirSync(collection);
assert.equal(docs.length, 1, 'forget?');
var third = docs[0];
var document = collection + '/' + third;
assert.equal(extname(third), '.bson');
var _id = third.split('.bson')[0];
var data = BSON.deserialize(fs.readFileSync(document, {
encoding: null
}));
assert.deepEqual(data, DOCS[_id]);
assert.equal(String(data._id), DOCS[Object.keys(DOCS)[0]]._id);
fs.unlinkSync(document);
fs.rmdirSync(collection);
fs.rmdirSync(database + '/.metadata/');
fs.rmdirSync(database);
});
done();
channel.consume(queue, function (msg) {
var data = bson.deserialize(msg.content)
console.log(`received from ${data.device_name}, status: ${data.device_status}`)
channel.ack(msg)
})
}
channel.consume(queue, function (msg) {
var data = bson.deserialize(msg.content)
console.log(`received from ${data.device_name}, messageId: ${data.message_id},payload: ${data.payload.toString()}`)
channel.ack(msg)
})
load(): Notes {
atom.stateStore
.save(atom.getStateKey(LEGACY_CUSTOM_STATE_KEY), {})
.catch(() => {});
const cachePath = path.join(this._dir, CACHE_FILENAME);
try {
return fs.existsSync(cachePath)
? BSON.deserialize(fs.readFileSync(cachePath))
: {};
} catch (error) {
showWarningNotification("Failed to load notes cache", error);
return {};
}
}
channel.consume(queue, function (msg) {
handlerFunc(bson.deserialize(msg.content))
channel.ack(msg)
})
}
deserialize(data) {
return BSON.deserialize(data)
}
}