Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
this.get(key, (err, res) => {
if (isFailure(err)) return cb(err);
const val = res.value;
if (!Array.isArray(val))
return cb(new couchbase.Error('Not a set'));
cb(undefined, { cas: res.cas, value: val.indexOf(value) !== -1 });
});
};
this.get(key, (err, res) => {
if (isFailure(err)) return cb(err);
const val = res.value;
if (!val.isMap)
return cb(new couchbase.Error('Not a map'));
if (!val.hasOwnProperty(path))
return cb(new couchbaseError('Path invalid'));
cb(undefined, { cas: res.cas, value: val[path] });
});
};
this.get(key, (err, res) => {
if (isFailure(err)) return cb(err);
if (!Array.isArray(res.value))
return cb(new couchbase.Error('Not a list'));
if (index >= res.value.length)
return cb(new couchbaseError('Index out of range'));
cb(undefined, { cas: res.cas, value: res.value[index] });
});
};
this.get(key, (err, res) => {
if (isFailure(err)) {
if (elv(options) && options.createQueue) {
const newQueue = [ value ];
return self.insert(key, newQueue, (e, r) => {
if (isFailure(e)) return cb(e);
cb(undefined, { cas: r.cas, value: newQueue });
});
} else {
return cb(err);
}
}
if (!Array.isArray(res.value))
return cb(new couchbase.Error('Not a queue'));
const val = res.value;
val.push(value);
self.replace(key, val, (e, r) => {
if (elv(e)) return cb(e);
cb(undefined, { cas: r.cas, value: val });
});
});
};