JavaScript Programming assignment

profileHero234
spreadsheet.mjs

import parse from './expr-parser.mjs'; import AppError from './app-error.mjs'; import { cellRefToCellId } from './util.mjs'; //use for development only import { inspect } from 'util'; class CallInfo{ constructor(value,expr,dependents,ast) { this.value=value; this.expr=expr; this.dependents=dependents; this.ast=ast; } } export default class Spreadsheet { //factory method static async make() { return new Spreadsheet(); } constructor() { var Sheets={}; for(var i=1;i<100;i++){ for(var j='a';j<='z';j++){ } } //@TODO } /** Set cell with id baseCellId to result of evaluating formula * specified by the string expr. Update all cells which are * directly or indirectly dependent on the base cell. Return an * object mapping the id's of all dependent cells to their updated * values. User errors must be reported by throwing a suitable * AppError object having code property set to `SYNTAX` for a * syntax error and `CIRCULAR_REF` for a circular reference * and message property set to a suitable error message. */ async eval(baseCellId, expr) { const updates = {}; //@TODO return updates; } //@TODO add methods } //Map fn property of Ast type === 'app' to corresponding function. const FNS = { '+': (a, b) => a + b, '-': (a, b=null) => b === null ? -a : a - b, '*': (a, b) => a * b, '/': (a, b) => a / b, min: (...args) => Math.min(...args), max: (...args) => Math.max(...args), } //@TODO add other classes, functions, constants etc as needed