quick protocol implementation in javascript