Comparing version 0.0.4 to 0.0.5
@@ -9,3 +9,3 @@ var Repl = require('../') | ||
} | ||
}) | ||
}).start() | ||
} | ||
@@ -17,2 +17,2 @@ | ||
var f = new Foo() | ||
new Foo |
@@ -26,6 +26,8 @@ var repl = require('repl') | ||
Repl.prototype.start = function () { | ||
Repl.prototype.start = function (cb) { | ||
var self = this | ||
this._server = net.createServer(function (socket) { | ||
self._socket = socket | ||
socket.on('error', function (e) { | ||
@@ -67,3 +69,6 @@ self.emit('error', e) | ||
self.emit('replStarted') | ||
cb && cb() | ||
}) | ||
return this | ||
} | ||
@@ -73,8 +78,13 @@ | ||
var self = this | ||
self._socket.end() | ||
this._server.close(function () { | ||
self._server = null | ||
self._socket = null | ||
self.emit('replStopped') | ||
cb && cb() | ||
}) | ||
return this | ||
} |
{ | ||
"name": "replize", | ||
"version": "0.0.4", | ||
"version": "0.0.5", | ||
"description": "Simple REPL for embedding into applications", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -1,5 +0,10 @@ | ||
### REPLize | ||
## REPLize | ||
Add a REPL into your application. | ||
[![Build Status](https://secure.travis-ci.org/diversario/replize.png?branch=master)](http://travis-ci.org/diversario/replize) | ||
[![Coverage Status](https://coveralls.io/repos/diversario/replize/badge.png?branch=master)](https://coveralls.io/r/diversario/replize?branch=master) | ||
[![Dependency Status](https://gemnasium.com/diversario/replize.png)](https://gemnasium.com/diversario/replize) | ||
[![NPM version](https://badge.fury.io/js/replize.png)](http://badge.fury.io/js/replize) | ||
``` | ||
@@ -9,3 +14,3 @@ npm install replize | ||
### Usage | ||
## Usage | ||
@@ -27,3 +32,9 @@ `replize` is most useful when attached onto instances (however, it can be used in any way you like). | ||
### Events | ||
Alternatively, use `telnet`: | ||
``` | ||
$ telnet localhost 20000 | ||
``` | ||
## Events | ||
- `replConnected` `(clientCount)` Client connection is created | ||
@@ -35,4 +46,16 @@ - `replDisconnected` `(clientCount)` Client connection is ended | ||
### Example | ||
## API | ||
#### replize#start([callback]) | ||
Start the TCP server used by REPL. Optional `callback` is called when server starts listening. Emits `replStarted`. | ||
#### replize#stop([callback]) | ||
Stops the TCP server. Optional `callback` is called when server is shutdown. Emits `replStopped`. | ||
#### replize#clients() | ||
Returns the number of clients connected to this instance. | ||
## Example | ||
```javascript | ||
@@ -47,3 +70,3 @@ var Repl = require('replize') | ||
} | ||
}) | ||
}).start() | ||
} | ||
@@ -69,2 +92,25 @@ | ||
See [example](example/) folder. | ||
See [example](example/) folder. | ||
## License | ||
(The MIT License) | ||
Permission is hereby granted, free of charge, to any person obtaining | ||
a copy of this software and associated documentation files (the | ||
'Software'), to deal in the Software without restriction, including | ||
without limitation the rights to use, copy, modify, merge, publish, | ||
distribute, sublicense, and/or sell copies of the Software, and to | ||
permit persons to whom the Software is furnished to do so, subject to | ||
the following conditions: | ||
The above copyright notice and this permission notice shall be | ||
included in all copies or substantial portions of the Software. | ||
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, | ||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. | ||
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY | ||
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, | ||
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE | ||
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
96583
201
112