extensions icon indicating copy to clipboard operation
extensions copied to clipboard

Object extension

Open Skyhigh173 opened this issue 1 year ago • 17 comments

blocks

image

[!NOTE] You might think that JSON extension is enough, however Object extension is way more faster than json extension, as data will not be reparsed. All variables will be converted to JSON string when you save the project.

performance/benchmark[^1]

  • a ~8.4MB file: image image

  • a json string with length of 200 image 15x faster.

Miscellaneous

(Read IMPORTANT part)

[!IMPORTANT] it will be slower to parse/stringify the entire object due to reviver & replacer.

[!IMPORTANT] variable monitor will not work properly, eg it shows keyvalue instead of {"key":"value"}

[!IMPORTANT] use Cast Extension or () to JSON block to convert it to string.

[!WARNING] this extension overwrites Map.prototype.toString. Map._e (extra utils) were added.

for developers (Map._e extra utils)
  • use Map._e.deepCopy when you need to modify the content of the Map.
  • use Map._e.shallowCopy when you only needs to read the content of the Map.
  • use Map._e.fromMapOrString in set content related blocks.[^2]
  • use Map._e.fromArray when you need to convert array to Map.

[^1]: Parsing time not counted. [^2]: This function tries convert a string to Map if possible.

Skyhigh173 avatar Sep 30 '23 08:09 Skyhigh173