Javascript object transformer