<commit_before>[![Build Status](https://travis-ci.org/mondora/asteroid.svg?branch=master)](https://travis-ci.org/mondora/asteroid)
[![Coverage Status](https://coveralls.io/repos/mondora/asteroid/badge.png)](https://coveralls.io/r/mondora/asteroid)

[Example todo app using AngularJS.](http://mondora.github.io/meteor-todo)
[Same app using Meteor's front-end.](http://meteor.todo.pscanf.com)

#asteroid

A javascript client (browser and node) for a Meteor backend.

##Table of contents

[Why](#why)

[Install](#install)

[Example usage](#example-usage)

[Advantages over the canonical Meteor front-end](#advantages-over-the-canonical-meteor-front-end)

[Build asteroid locally](#build-asteroid-locally)

[Contribute](#contribute)

[API](#api)

##Why

Meteor is an awesome platform, but its canonical
front-end is not very flexible. Asteroid gives the
possibility to connect to a Meteor backend with any JS app.

Some of the things Asteroid allows you to do are:

*	make any existing application reactive

*	use any front-end framework you want with Meteor

*	develop browser extensions backed by Meteor

[Blog post on the library](http://mondora.com/#!/post/e2da7bd7ccb774de13324488b4e24abd)

##Install

###In the browser

First, dowload the library:

    bower install asteroid

Then, add the necessary libraries to your `index.html`:

    <script src="bower_components/ddp.js/src/ddp.js"></script>
    <script src="bower_components/q/q.js"></script>
    <script src="bower_components/asteroid/dist/asteroid.browser.js"></script>
    
If you want to login via oauth providers (facebook, google etc),
also include the appropriate plugin:

    <script src="bower_components/asteroid/dist/plugins/facebook-login.js"></script>

For facebook connect support in cordova via the [facebook connect plugin](https://github.com/Wizcorp/phonegap-facebook-plugin),
see https://github.com/keyvanfatehi/asteroid-facebook-connect
    
###In a chrome extension or in cordova

Just replace `asteroid.browser.js` with `asteroid.chrome.js` or `asteroid.cordova.js`.

If using from within a chrome extension make sure to request for the `tabs` and `storage` permissions in your extensions manifest file.

###In node

Download the package:

    npm install asteroid

Require it in your project:

    var Asteroid = require("asteroid");

##Example usage

```javascript
// Connect to a Meteor backend
var ceres = new Asteroid("localhost:3000");

// Use real-time collections
ceres.subscribe("tasksPublication");
var tasks = ceres.getCollection("tasks");
tasks.insert({
  description: "Do the laundry"
});
// Get the task
var laundryTaskRQ = tasks.reactiveQuery({description: "Do the laundry"});
// Log the array of results
console.log(laundryTaskRQ.result);
// Listen for changes
laundryTaskRQ.on("change", function () {
  console.log(laundryTaskRQ.result);
});

// Login your user
ceres.loginWithTwitter();
```

##Advantages over the canonical Meteor front-end

* Small footprint.

* Framework agnostic. Use the tools you already know and
  love to build your app.

* Allows to use Meteor as a full-blown backend or just as a
  real-time platform pluggable into any existing project.

* Easily connect to multiple Meteor servers at the same
  time, perfect for building admin interfaces.

 
##Build asteroid locally

Clone the repository (or your fork) on your computer.

    git clone https://github.com/mondora/asteroid

Enter the project's directory and install the required
dependencies:

    cd asteroid/
    npm install

Start the development environment (requires ´gulp` installed globally):

    gulp

Visit `localhost:8080/browser.html` and `localhost:8080/node.html`
for unit tests result.


##Contribute

Contributions are as always very very welcome. If you
want to help but don't know how to get started,
[feel free to schedule a pair programming session with me!](http://mondora.com/#!/post/4ddde81d13b2152ab068b54e85bd4a2a)



##API



##Asteroid methods<commit_msg>Markdown fix<commit_after>[![Build Status](https://travis-ci.org/mondora/asteroid.svg?branch=master)](https://travis-ci.org/mondora/asteroid)
[![Coverage Status](https://coveralls.io/repos/mondora/asteroid/badge.png)](https://coveralls.io/r/mondora/asteroid)

[Example todo app using AngularJS.](http://mondora.github.io/meteor-todo)
[Same app using Meteor's front-end.](http://meteor.todo.pscanf.com)

#asteroid

A javascript client (browser and node) for a Meteor backend.

##Table of contents

[Why](#why)

[Install](#install)

[Example usage](#example-usage)

[Advantages over the canonical Meteor front-end](#advantages-over-the-canonical-meteor-front-end)

[Build asteroid locally](#build-asteroid-locally)

[Contribute](#contribute)

[API](#api)

##Why

Meteor is an awesome platform, but its canonical
front-end is not very flexible. Asteroid gives the
possibility to connect to a Meteor backend with any JS app.

Some of the things Asteroid allows you to do are:

*	make any existing application reactive

*	use any front-end framework you want with Meteor

*	develop browser extensions backed by Meteor

[Blog post on the library](http://mondora.com/#!/post/e2da7bd7ccb774de13324488b4e24abd)

##Install

###In the browser

First, dowload the library:

    bower install asteroid

Then, add the necessary libraries to your `index.html`:

    <script src="bower_components/ddp.js/src/ddp.js"></script>
    <script src="bower_components/q/q.js"></script>
    <script src="bower_components/asteroid/dist/asteroid.browser.js"></script>
    
If you want to login via oauth providers (facebook, google etc),
also include the appropriate plugin:

    <script src="bower_components/asteroid/dist/plugins/facebook-login.js"></script>

For facebook connect support in cordova via the [facebook connect plugin](https://github.com/Wizcorp/phonegap-facebook-plugin),
see https://github.com/keyvanfatehi/asteroid-facebook-connect
    
###In a chrome extension or in cordova

Just replace `asteroid.browser.js` with `asteroid.chrome.js` or `asteroid.cordova.js`.

If using from within a chrome extension make sure to request for the `tabs` and `storage` permissions in your extensions manifest file.

###In node

Download the package:

    npm install asteroid

Require it in your project:

    var Asteroid = require("asteroid");

##Example usage

```javascript
// Connect to a Meteor backend
var ceres = new Asteroid("localhost:3000");

// Use real-time collections
ceres.subscribe("tasksPublication");
var tasks = ceres.getCollection("tasks");
tasks.insert({
  description: "Do the laundry"
});
// Get the task
var laundryTaskRQ = tasks.reactiveQuery({description: "Do the laundry"});
// Log the array of results
console.log(laundryTaskRQ.result);
// Listen for changes
laundryTaskRQ.on("change", function () {
  console.log(laundryTaskRQ.result);
});

// Login your user
ceres.loginWithTwitter();
```

##Advantages over the canonical Meteor front-end

* Small footprint.

* Framework agnostic. Use the tools you already know and
  love to build your app.

* Allows to use Meteor as a full-blown backend or just as a
  real-time platform pluggable into any existing project.

* Easily connect to multiple Meteor servers at the same
  time, perfect for building admin interfaces.

 
##Build asteroid locally

Clone the repository (or your fork) on your computer.

    git clone https://github.com/mondora/asteroid

Enter the project's directory and install the required
dependencies:

    cd asteroid/
    npm install

Start the development environment (requires `gulp` installed globally):

    gulp

Visit `localhost:8080/browser.html` and `localhost:8080/node.html`
for unit tests result.


##Contribute

Contributions are as always very very welcome. If you
want to help but don't know how to get started,
[feel free to schedule a pair programming session with me!](http://mondora.com/#!/post/4ddde81d13b2152ab068b54e85bd4a2a)



##API



##Asteroid methods
{'fraction_non_alphanumeric': 0.10814908401768794, 'fraction_numerical': 0.011876184459886292, 'mean_word_length': 4.646219686162625, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 19, 'https://': 14, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3761462', 'n_tokens_mistral': 2580, 'n_tokens_neox': 2343, 'n_words': 792}