blob: c31521a8227d4b09b80c583dc84fb3e6f0132f21 [file] [log] [blame]
// Copyright 2015 The Vanadium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
var now = require('date-now');
module.exports = normalize;
// Takes data from API messages and converts them to appropriate objects
// (lowecase, correct values, etc.).
function normalize(data) {
// convert `data.Timestamp` nanosecond value to a float in milliseconds.
var oneMillion = 1e6;
var timestamp = data.Timestamp ? (data.Timestamp / oneMillion) : now();
return {
message: data.Message,
file: data.File,
stream: data.Stream,
timestamp: timestamp
};
}