UTS-eResearch / ro-crate-js

Research Object Crate (RO-Crate) utilities
GNU General Public License v3.0
2 stars 6 forks source link

Index crate at instantiation #21

Open marcolarosa opened 3 years ago

marcolarosa commented 3 years ago

When instantiating an ROCrate object if a json structure is passed in can the index method be triggered automatically?

let json = { crate json ld }
let crate = new ROCrate(json)
crate.index()
moisbo commented 3 years ago

Yes please. I always forget to index() and freak out

ptsefton commented 3 years ago

I am thinking about a v2 library that actually builds a linked (circular not tree) data structure on ingest - it would keep track of what items it already has in a object (the index) and would thus automatically index a crate on start up. Code that consumes crates such as renderers could be made much simpler as all values would be arrays of either strings or other items.

In the short term there's probably not that much harm in automatically indexing except a performance penalty on software that does an index - so if you go fix the other tools of ours like ro-crate-html-js etc I say go for it!