Javascript enum factory