Comments (2)
Struct arrays are analogous to C arrays - that is, there is no such thing as an array of undetermined length. You must either over-provision the length of your array to start with, or implement logic to expand/replace the arrays on your own. It's unlikely that the library will support such expansion logic moving forward as the means by which an array is expanded is dependent on the application itself.
Usually, expansion of an independent array is implemented by creating a new array of the desired size, copying the contents of the old array into the new one, and freeing the old array for garbage collection. Alternately, you can create a new array separately and use logic to create something of a "virtual index" that maps to the appropriate array - but you'll lose some of the performance benefits of using contiguous memory.
Changing the size of arrays within a struct at runtime is inadvisable as it will invalidate all previous instances of the struct by changing the offsets at which fields reside - so all previous instances of the struct would need to be converted each time any of their array fields grow.
from node-struct.
Maybe you'd be better with something like smart-buffer and de-serializing your data as a stream.
from node-struct.
Related Issues (20)
- Why '_' prefix for _setBuff HOT 1
- Field offset and size not accessible
- Null-terminated string HOT 5
- Make a minor or major version bump HOT 3
- Invalid integer value HOT 1
- Dose the API Serport "float" and "double" type fields,my project require it to work
- `word8` function removal broke `semver`
- Pass an array length from a field. HOT 3
- Clone function does not properly copy properties
- time_t variables HOT 3
- How do I use the same template to read different buffers? HOT 1
- What about long? HOT 2
- Add 'encoding' as 3rd param in Structs.chars HOT 1
- cannot find Key error HOT 2
- Typescript declarations HOT 2
- Support for `chars` reversed byte order
- Array size read from buffer
- Usage question. HOT 2
- Struct.chars('hex') not work
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 node-struct.