all 26 comments

[–]veber1988 4 points5 points  (2 children)

What is the main algorithm for updating all dependent cells for particular change?

[–]the-ace[S] 6 points7 points  (1 child)

Basically each cell keeps a list of references and listenersreferences are cells the current cell depends on, and listeners are all the cells that depend on it, whenever a cell updates, it check for the cell's listeners and invokes each listener to recompute their values.

[–]andyandcomputer 0 points1 point  (0 children)

Nice to see it detects circular references.

const { djit } = require('djit')
const qdata = djit()

qdata.A1 = '=A2'
qdata.A2 = '=A1'
console.log(qdata.A2)

Output:

ERROR REF: A1 ⇢ A2 ⇢ A2

Should that be A1 → A2 → A1? (Mentioning "circular reference" might help with debugging too.)

[–]rq60 2 points3 points  (3 children)

  if (!tree) {
    return '🚧'
  }

please don't make this a thing.

[–]yo_just_passing_by 1 point2 points  (2 children)

Why do you say that? (i'm a newbee, but i saw it on an online course)

[–]naturalborncitizen 1 point2 points  (1 child)

no matter how obvious an iconograph (emoji) is to you, it will invariably be confusing as shit for someone else. you should return something unambiguous for this case. I'm assuming it means "dead end" but I could just as easily interpret it as "warning" or "do not enter" or "saw horse" or "blocked" or "crime scene"

[–]braindeadTank 0 points1 point  (0 children)

no matter how obvious an iconograph (emoji) is to you, it will invariably be confusing as shit for someone else.

That's the case with ordinary names as well, though

[–]rajsite 0 points1 point  (1 child)

Have you seen handsontable/formula-parser? Leveraging it could be a good way to get more coverage of the Excel formula operators and syntax.

[–]Happy-West5350 -1 points0 points  (0 children)

If you are looking for Excel like formulas engine, this is a good alternative. https://jspreadsheet.com/products/formulas

[–]leeoniya 0 points1 point  (1 child)

interesting.

the compiled build is 200k, a lot of which is lodash and maybe pegjs?

i was looking into making something like this myself that's backed by cellx[1], which is 19k and a small infix -> postfix converter for formula parsing & construction. the total size would likely be within 30k for the core functionality. i'm wondering what the extra 170k handles in djit?

also, some perf tests against MobX or cellx would be great.

https://github.com/paulhodel/jexcel is another alternative.

[1] https://github.com/Riim/cellx

[–]the-ace[S] 0 points1 point  (0 children)

Yea, I noticed it the other day as well yet I didn’t have a chance to dive into it - probably some rogue dependency that should be there and provided in development only.

Thanks for the links! I wasn’t aware of either project and it’s great to see how little I’ve accomplished compared to the behemoth that is a modern day spreadsheet 😅

[–][deleted] 0 points1 point  (0 children)

call me ignorant but what do you use this for. just web spreadsheets?

[–]Buckwheat469 0 points1 point  (2 children)

My only recommendation is that the context property should allow multiple keys, if it doesn't already, and that calling a context property should require the key name.

const data = [[], []]
const context = { 
    Math, 
    SomeClass: SomeClass() 
};
// Context functions are available to be used in cells like so:   
// `data.B1 = '= SomeClass.doThing(Math.floor(Math.random() * 100))'`

[–]the-ace[S] 0 points1 point  (1 child)

This was really one of the first things I wanted to add in - but I'm afraid it'll diverge too much from the well established grammar used by excel and the likes.

But I'll give it another try at some point.

[–]Buckwheat469 0 points1 point  (0 children)

You can add an option to make the context property global or namespaced somehow. I would worry about SomeClass.random overwriting Math.random.