bewest/sgvdata

View on GitHub
lib/json.js

Summary

Maintainability
A
35 mins
Test Coverage
'use strict';

function echo (record, opts) {
  if ('sgv' in record && 'date' in record) {
    var res = {
      sgv: record.sgv.toString( )
    , dateString: record.dateString || ''
    , date: parseInt(record.date)
    , device: record.device || ''
    , direction: record.direction || ''
    };
    if (res.sgv && isFinite(res.date)) {
      return res;
    }
  }
  if (opts && opts.strict) { throw new Error(record); }
}


function configure ( ) {
  return configure;
}

configure.echo = echo;
module.exports = configure;