visionmedia/axon-rpc — pull request #14 by bretcope (2014-04-21 04:03:10+00:00)
Title: Add support for current and older versions of axon.

The current versions of axon and axon-rpc in npm are incompatible. At the very least, it would be great to get a npm version bump on axon-rpc because master is compatible with the current axon.

---

I added a check for whether the method `sock.format` exists, and only call it if it does. This makes axon-rpc compatible with versions of axon which use AMP while maintaining compatibility with older versions which don't.

I also bumped the version of axon in the dev dependencies to 2.0.0, and added `scripts.test` to package.json to make the tests easier to run.

Lastly, while the tests run fine for me on Linux, they blow up on Windows with:

```
0 passing (1s)
5 failing

1) Server#expose(name, fn) should expose a single function:
Uncaught Error: connect EADDRNOTAVAIL
at exports._errnoException (util.js:745:11)
at Object.afterConnect [as oncomplete] (net.js:995:19)

2) Server#expose(obj) should expose multiple:
Uncaught Error: connect EADDRNOTAVAIL
at exports._errnoException (util.js:745:11)
at Object.afterConnect [as oncomplete] (net.js:995:19)

...
```

Which is caused by the change in axon 1.0.0 to use INADDR_ANY instead of the loopback address for Socket#connect by default. So I explicitly specified localhost for the client in the tests, and now it works on all OS's again.