An open API service indexing awesome lists of open source software.

https://github.com/crackcomm/h5js

h5 javascript library - distributed computing using JSON
https://github.com/crackcomm/h5js

Last synced: 4 months ago
JSON representation

h5 javascript library - distributed computing using JSON

Awesome Lists containing this project

README

          

# h5js

> **NOTE**: See [ipfn](https://github.com/ipfn/ipfn) project.

Distributed computing with JSON.

Checkout `example.js` and `cloud.js` in examples directory.

## Idea

It's more about idea rather than a working library.

### HTML instead of JSON

Another cool idea to think about:

Stop treating HTML as a second class citizen:

```html




```

## Usage

```JavaScript
var h5 = require('h5');

require('./functions.js');

var example =
h5.action('http.request', { url: 'http://www.imdb.com/title/tt0110912/' }).
action('html.extract', { selectors: { title: 'h1.header > span[itemprop="name"]', year: 'h1.header > span > a' } });

example.
run().
then(function(result) {
console.log(result);
}, function(err) {
console.log('Error:', err);
});
```

Example action in JSON form:

```JSON
{
"id": "4627ca64-a168-40f6-9389-cf4fa75b6da2",
"function": {
"name": "http.request",
"args": {
"url": "http://www.imdb.com/title/tt0110912/"
}
},
"next": {
"id": "875d846a-635f-4567-adc9-46ca61b4ef12",
"function": {
"name": "html.extract",
"args": {
"selectors": {
"title": "h1.header > span[itemprop=\"name\"]",
"year": "h1.header > span > a"
}
}
}
}
}
```

Saving action and running in [cloud](https://github.com/crackcomm/h5jserver)

```JavaScript
h5.cloud.set('https://radiant-harbor-8309.herokuapp.com/');

example.
save().
then(function() {
return example.run({url: 'http://www.imdb.com/title/tt0137523/'}, true);
}).
then(function(result) {
console.log('result:', result);
}).
catch(function(err) {
console.log('Cloud error:', err);
});

```