Javascript Array Matrix converting library