Could String internalize an ArrayBuffer?

Coroutines coroutines at gmail.com
Sat Dec 5 13:44:12 UTC 2015


I'm not sure what I'm asking for/looking for.

What I want is to be able to view a String through a typed array
without duplicating the memory/contents of that string.

As I understand it, typed arrays operate over an ArrayBuffer, not Strings.

Does anyone know of a way to do this?

If it's not possible, would it make sense to have String inherit from
or internally contain an ArrayBuffer that could be gotten somehow?
Maybe with something lie ::valueOf() ?

In the last week I've been playing with typed arrays so I can compare
2 files by word-sized types.  The problem I'm having is when I receive
a String and not an ArrayBuffer from a third-party library.  I'd love
it if I could avoid converting the String into a duplicated
ArrayBuffer.

Cheers


More information about the es-discuss mailing list