processing.js shorten() and expand() functions

Filed under Open Source, Processing.js, Seneca College

I put a little more work into the shorten() test lately to check how it functions with arrays of objects.  Right now its only doing a shallow copy so i’ll have to add code to support arrays of objects properly for 0.2 and also support elements in an array that might be arrays in themselves.

I think for now shorten() is ready to be used in a 0.1 context.

Ive also got a test up for expand()Expand takes an array and optionally a size argument and expands the array to twice its size if there is no newSize argument, otherwise it makes the array the size of the newsize argument passed in.  This function returns a copy of the array passed in.  The same results take place if this function is used with arrays of objects.  You essentially end up with 2 references and each one has a different .length property so it appears to work but once an element is changed in one array it also changes in the other array.  So I’ve obviously not made a proper copy for arrays of objects.  Shouldn’t be to hard to fix for a 0.2 release.

Next up : unhex(), nfc(), and nfs().

I’ll be putting up my code on GIT in a few days.

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*