Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
exports.castValue = function(dakota, value) {
// cassandra tuple
if (value instanceof nmCassandraTypes.Tuple) {
value = value.values();
}
// cassandra types
if (value instanceof nmCassandraTypes.BigDecimal) {
return value.toNumber();
}
else if (value instanceof nmCassandraTypes.InetAddress) {
return value.toString();
}
else if (value instanceof nmCassandraTypes.Integer) {
return value.toNumber();
}
else if (value instanceof nmCassandraTypes.LocalDate) {
return value.toString();
}
var parts = split(e.contents);
if (e.keyword === 'frozen') {
return exports.formatValueType(dakota, parts[0], value);
}
else if (e.keyword === 'map') {
nm_.each(value, function(v, key) {
key = exports.formatValueType(dakota, parts[0], key);
value[key] = exports.formatValueType(dakota, parts[1], v);
});
return value;
}
else if (e.keyword === 'tuple') {
value = nm_.map(parts, function(part, index) {
return exports.formatValueType(dakota, part, value[index]);
});
return nmCassandraTypes.Tuple.fromArray(value);
}
else {
value = nm_.map(value, function(v, index) {
return exports.formatValueType(dakota, parts[0], v);
});
return value;
}
}
else {
return value;
}
}
else if (exports.isUserDefinedType(dakota, type)) {
return dakota.getUserDefinedType(type).formatValueTypeForSelf(value);
}
else {
exports.isTuple = function(x) {
return nm_.isArray(x) || (x instanceof nmCassandraTypes.Tuple);
};