Comments (5)
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.
@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.
@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.
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.
@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)
- Uint64.toString fails for large numbers HOT 2
- Using jDataView in chrome throws Uncaught ReferenceError: NODE is not defined HOT 3
- Better support for negative bitLength HOT 11
- Use backing buffer/view's methods when available. HOT 5
- Use native methods for bit access HOT 4
- Remove string concatenation at runtime HOT 3
- Bitfields doesn't work well in littleEndian mode HOT 1
- Dist file without sourceMappingURL HOT 5
- it
- Bitfield API ignores endianness. HOT 2
- Question: Is jDataView runnable in web worker? HOT 1
- Question: How to convert the "uint16" value to half-precision float (i.e. "float16")? HOT 1
- Weird Float types (48 & 80 bit) HOT 1
- readString() with variable 7-bit based integer as prefix length HOT 1
- untar demo intersperses chunks of JavaScript in textareas HOT 1
- dataview constructor argument offset is invalid HOT 10
- Getting an error only after minification of dist/browser/jdataview.js? HOT 4
- Constuctor doesn't work the same as a real DataView? HOT 7
- Cannot use 'in' operator to search for 'Buffer' in undefined HOT 6
- Remove old fallbacks HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jdataview.