import fetch from 'node-fetch' ; const path = require ( 'path' ) ; export function resolveHome ( filepath ) { if ( filepath [ 0 ] === '~' ) { return path . join ( process . env . HOME , filepath . slice ( 1 ) ) ; } console . log ( filepath ) ; return filepath ; } function checkStatus ( res ) { if ( res . ok ) { return res ; } else { throw "file not found" ; } } export async function getJson ( url ) { var data = await fetch ( url , { method : 'GET' } ) ; checkStatus ( data ) ; return data . json ( ) ; } export async function getPbf ( url ) { var data = await fetch ( url , { method : 'GET' } ) ; checkStatus ( data ) ; return new Uint8Array ( await data . buffer ( ) ) ; } export function rmse ( values ) { var sum = 0 ; for ( var value of values ) { sum = sum + Math . pow ( value , 2 ) ; } var mean = sum / values . length ; return Math . sqrt ( mean ) ; }