Read spectrum files produced by Bentham's BenWin+ Software in Javascript
npm install @bentham-instruments/ben-to-json
const { parse } = require('@benthaminstruments/ben-to-json');
const fs = require('fs');
const ben_file_data = fs.readFileSync('spectra.ben');
let json = parse(ben_file_data);
console.log(json);
import { parse } from '@benthaminstruments/ben-to-json';
import {readFileSync} from 'fs';
const ben_file_data = readFileSync('spectra.ben');
let json = parse(ben_file_data);
console.log(json);
If you are using an old version of node, pre v13, then it needs to be run with in a special way as these older versions were not built with full international support by default.
This support can be added by using the NODE_ICU_DATA to point to an installed version of the
full-icu
package. e.g. "cross-env NODE_ICU_DATA=./node_modules/full-icu node script.js