add utility function to convert prolog terms into javascript ones