Giter VIP home page Giter VIP logo

Comments (5)

peterseverin avatar peterseverin commented on September 26, 2024

Is there a workaround for this issue? I'm trying to implement a binary serialization where the final buffer size is not known in advance. I would expect to have the possibility to grow the buffer as needed.

from jdataview.

RReverser avatar RReverser commented on September 26, 2024

@peterseverin For now, in own projects I had to use fixed-size buffer with calculated size big enough to hold my data. The problem is that all the existing implementations (except old generic Array) don't support dynamic extension, so this needs to be solved on jDataView size with either "ropes" mechanism (where one instance can continue other) or copy-on-extend.

Since it's needed not just for me, I'll try to get back to it soon, but if you could implement it and send PR, I'd appreciate that.

from jdataview.

peterseverin avatar peterseverin commented on September 26, 2024

@RReverser I think copy on extend would be an acceptable solution. This is a common solution in Java when using arrays. I'll try to add something simple in _checkBounds method but a good solution would probably need a more systematic approach, probably in _setBytes method.

from jdataview.

yuraj11 avatar yuraj11 commented on September 26, 2024

Bump, Are you still working on this? I have found something helpful - https://github.com/KimLS/dynamic-buffer-js It would be nice feature If you could generate binary file dynamically (when you don't know final arraybuffer size).

from jdataview.

RReverser avatar RReverser commented on September 26, 2024

@yuraj11 Looks like it just performs copy-on-extend that we already discussed, and in very inefficient manner (copying byte-by-byte): https://github.com/KimLS/dynamic-buffer-js/blob/master/src/dynamic_buffer.js#L134-L137

At this point I believe we can track the status of ES proposal ArrayBuffer.transfer that is essentially efficient realloc: https://github.com/tc39/ecma262 ( https://gist.github.com/lukewagner/2735af7eea411e18cf20 )

When it's accepted, we can just use it together with copy-on-extend purely as polyfill for old browsers.

from jdataview.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.