On Sun, Mar 25, 2012 at 06:57:20AM -0700, Brandon Benvie wrote: > This is a cool little tool I've been meaning to make for a while. It > combines the features of Buffers, TypedArrays, and DataView into one useful > interface by using Proxies to provide an amorphous surface. A ViewBuffer > can start out using the same parameters as a regular Buffer, or it can wrap > an existing buffer. The primary way to set and get data from it is using > the numbered indexes like Buffers have or arrays. The difference is that > you can set the "view" that the data is accessed through. > > https://github.com/Benvie/view-buffer > > *Note: this isn't tested at all and isn't currently targeted at production > use. In npm it's set to require node >=0.7. It also requires running with > --harmony_proxies and --harmony_collections (or --harmony).* > > *simple creation:* > var buffer = ViewBuffer(10); > buffer [3] = 100; > { view: 'Uint8', > bytes: 10, > length: 10, > '0': 0, > '1': 0, > '2': 0, > '3': 100, > '4': 0, > '5': 0, > '6': 0, > '7': 0, > '8': 0, > '9': 0 } > > Here's where we go flipmode > buffer.view = 'uint32'; > { view: 'Uint32', > bytes: 10, > length: 2, > '0': 1677721600, > '1': 0 }
How fast is it? It sounds relatively inefficient... Also, what if the 32-bit numbers in your buffer aren't aligned at 4?
pgpOhYht9meii.pgp
Description: PGP signature
