Possible mistake on line no. 21, isPrimary()
isPrimary() returns 'undefined' because the property seems to not exist, but using the property isMaster() returns the value properly and the example code works fine.
Thanks! if you come across this, and please revert if this is a mistake from my end.