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
- Host: GitHub
- URL: https://github.com/crackcomm/h5js
- Owner: crackcomm
- License: unlicense
- Created: 2014-11-29T13:58:55.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2017-11-15T02:14:38.000Z (over 8 years ago)
- Last Synced: 2025-10-14T09:54:43.805Z (8 months ago)
- Language: JavaScript
- Homepage:
- Size: 12.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
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);
});
```