Implement protocol for user functions in js