Javascript on the Server
Overview
Javascript is the language that powers the davinci platform in the browser, but it is also a powerful language for running
code on you local machine or server.
Node.js provides a platform for running Javascript locally. Davinci
provides tools for running code that you run on davinci locally on your machine.
file-data.js
The library can be found here:
file-data.js
const fd = require('./file-data.js');
Reading data
file-data.js contains a function for reading text files in different formats.
const fd = require('./file-data.js');
(async function(){
//infer the type from the extension
let data = await fd.data('c:/path/data.json');
//specify the type in the second input
let data2 = await fd.data('c:/path/data.json', 'hson');
})()
Types
- json - standard json format
- hson - a json file where every row is an array. The first row contains the header names
- tab - tab delimited file
- csv - standard csv format
- hcsv