Giter VIP home page Giter VIP logo

node-nrepl-client's Introduction

node.js nREPL client Build Status

Connects node.js as a nrepl client to a Clojure nrepl server.

This is different from cljs-noderepl and similar projects as it does not connect node.js as the repl "target" (so that a nrepl Clojure client can eval code in a JS context) but the other way around ;)

Usage

To connect to a running nREPL server and send and receive an eval request do:

var nreplClient = require('nrepl-client');
nreplClient.connect({port: 7889}).once('connect', function() {
    var expr = '(+ 3 4)';
    client.eval(expr, function(err, result) {
        console.log('%s => ', expr, err || result);
        client.end();
    });
});

For a more detailed example and to use node.js also to start an nREPL Clojure process see examples/simple-connect.js.


## API

### `nrepl-client`

* `connect(options)`
  * Creates a [`net.Socket`](http://nodejs.org/api/net.html#net_class_net_socket)
    connection to an nREPL server. The connection object itself will have added
    methods, see below.
  * `options`: options from the [`net.connect`](http://nodejs.org/api/net.html#net_net_connect_options_connectionlistener) call.
  * returns a `net.Socket` clojure connection

* clojure connection
  * Wraps [nREPL messages](https://github.com/clojure/tools.nrepl#messages).
  * `clone([session,] callback)
  * `close([session,] callback)
  * `describe([verbose,] callback)
  * `eval(code, [session, id, evalFunc,] callback)
  * `interrupt(session, id, callback)
  * `loadFile(fileContent, [fileName, filePath,] callback)
  * `lsSessions(callback)
  * `stdin(stdin, callback)
  * `send(msgObj, callback)` sends a custom message

### `nrepl-client/nrepl-server`

* `start(options, callback)`
  * `options` options for configuring the nREPL server. Optional. `options == {startTimeout: NUMBER, verbose: BOOL, projectPath: STRING, hostname: STRING, port: NUMBER}`. See [nrepl-server.js](src/nrepl-server.js) for defaults.
  * `callback(err, serverState)` function called when the server is started. `serverState == {proc: PROCESS, hostname: STRING, port: NUMBER, started: BOOL, exited: BOOL, timedout: BOOL}`

* `stop(serverState, callback)`
  * `serverState` serverState returned from start
  * `callback(err)` function called when the server is stopped

node-nrepl-client's People

Contributors

rksm avatar stumitchell avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.