Commit eed85c976be79699b77f859046143b69e0c94b5e
build docs
wanderer committed on 3/27/2018, 7:31:15 PMParent: 136ef4bd7ca697c515688fa0a7b42c49930b5710
Files changed
README.md | changed |
index.js | changed |
.travis.yml | added |
docs/index.md | added |
README.md | ||
---|---|---|
@@ -1,20 +1,32 @@ | ||
1 | 1 … | # SYNOPSIS |
2 | -[![NPM Package](https://img.shields.io/npm/v/<modeule-name>.svg?style=flat-square)](https://www.npmjs.org/package/<module-name>) | |
3 | -[![Build Status](https://img.shields.io/travis/<gh-user>/<repo>.svg?branch=master&style=flat-square)](https://travis-ci.org/<gh-user>/<repo>) | |
4 | -[![Coverage Status](https://img.shields.io/coveralls/<gh-user>/<repo>.svg?style=flat-square)](https://coveralls.io/r/<gh-user>/<repo>) | |
2 … | +[![NPM Package](https://img.shields.io/npm/v/primea-objects.svg?style=flat-square)](https://www.npmjs.org/package/primea-objects) | |
3 … | +[![Build Status](https://img.shields.io/travis/primea/primea-objects.svg?branch=master&style=flat-square)](https://travis-ci.org/primea/primea-objects) | |
4 … | +[![Coverage Status](https://img.shields.io/coveralls/primea/primea-objects.svg?style=flat-square)](https://coveralls.io/r/primea/primea-objects) | |
5 | 5 … | |
6 | 6 … | [![js-standard-style](https://cdn.rawgit.com/feross/standard/master/badge.svg)](https://github.com/feross/standard) |
7 | 7 … | |
8 | -This isdi easdfkl; asdfj kal;sdjfkl ajsdklfj akls;j wat? | |
8 … | +Object helper classes for Primea's system Objects | |
9 | 9 … | |
10 | 10 … | # INSTALL |
11 | -`npm install <name>` | |
11 … | +`npm install primea-objects` | |
12 | 12 … | |
13 | 13 … | # USAGE |
14 | 14 … | |
15 | 15 … | ```javascript |
16 | - javascript = new Javascript() | |
16 … | +const objects = require('primea-objects') | |
17 … | + | |
18 … | +const id = new objects.ID(Buffer.from([0x1])) | |
19 … | +const modRef = new objects.ModuleRef({'name': ['i32']}, id) | |
20 … | +const funcRef = rmodRef.getFuncRef('name') | |
21 … | + | |
22 … | +// all objects can be encoded to cbor with borc | |
23 … | +const cbor = require('borc') | |
24 … | +const encodedModRef = cbor.encode(modRef) | |
25 … | + | |
26 … | +// and decoded with the decoder | |
27 … | +objects.decoder.decodeFirst(encodedModRef) | |
28 … | + | |
17 | 29 … | ``` |
18 | 30 … | |
19 | 31 … | # API |
20 | 32 … | [./docs/](./docs/index.md) |
index.js | ||
---|---|---|
@@ -16,8 +16,12 @@ | ||
16 | 16 … | link: new cbor.Tagged(TAGS.link, null), |
17 | 17 … | func: new cbor.Tagged(TAGS.func, 0) |
18 | 18 … | } |
19 | 19 … | |
20 … | +/** | |
21 … | + * a cbor decoder for the objects | |
22 … | + * @type {Object} | |
23 … | + */ | |
20 | 24 … | const decoder = new cbor.Decoder({ |
21 | 25 … | tags: { |
22 | 26 … | [TAGS.id]: val => new ID(val), |
23 | 27 … | [TAGS.func]: val => new FunctionRef({ |
@@ -34,32 +38,63 @@ | ||
34 | 38 … | } |
35 | 39 … | } |
36 | 40 … | }) |
37 | 41 … | |
42 … | +class ID { | |
43 … | + /** | |
44 … | + * an ID | |
45 … | + * @param {Buffer} id - the id as an buffer | |
46 … | + */ | |
47 … | + constructor (id) { | |
48 … | + this.id = id | |
49 … | + } | |
50 … | + | |
51 … | + encodeCBOR (gen) { | |
52 … | + return gen.write(new cbor.Tagged(TAGS.id, this.id)) | |
53 … | + } | |
54 … | +} | |
55 … | + | |
38 | 56 … | class FunctionRef { |
57 … | + /** | |
58 … | + * A function reference | |
59 … | + * @param {Object} opts | |
60 … | + * @param {*} opts.identifier - the function's identifier | |
61 … | + * @param {ID} opts.actorID - the id of the actor | |
62 … | + * @param {Array} opts.params - the params of the function | |
63 … | + */ | |
39 | 64 … | constructor (opts) { |
40 | 65 … | this.identifier = opts.identifier |
41 | - this.destId = opts.id | |
66 … | + this.actorID = opts.actorID | |
42 | 67 … | this.params = opts.params |
43 | 68 … | this.gas = opts.gas || 0 |
44 | 69 … | } |
45 | 70 … | |
46 | 71 … | encodeCBOR (gen) { |
47 | 72 … | return gen.write(new cbor.Tagged(TAGS.func, [ |
48 | 73 … | this.identifier, |
49 | 74 … | this.params, |
50 | - this.destId, | |
75 … | + this.actorID, | |
51 | 76 … | this.gas |
52 | 77 … | ])) |
53 | 78 … | } |
54 | 79 … | } |
55 | 80 … | |
56 | 81 … | class ModuleRef { |
57 | - constructor (ex, id) { | |
58 | - this.exports = ex | |
82 … | + /** | |
83 … | + * A module reference | |
84 … | + * @param {Object} exports - a map of exported function to params for the funcion if any | |
85 … | + * @param {ID} id - the id of the actor | |
86 … | + */ | |
87 … | + constructor (exports, id) { | |
88 … | + this.exports = exports | |
59 | 89 … | this.id = id |
60 | 90 … | } |
61 | 91 … | |
92 … | + /** | |
93 … | + * return a function refernce given the name of the function | |
94 … | + * @param {string} name | |
95 … | + * @returns {FunctionRef} | |
96 … | + */ | |
62 | 97 … | getFuncRef (name) { |
63 | 98 … | const params = this.exports[name] |
64 | 99 … | |
65 | 100 … | return new FunctionRef({ |
@@ -73,24 +108,11 @@ | ||
73 | 108 … | return gen.write(new cbor.Tagged(TAGS.mod, [this.exports, this.id])) |
74 | 109 … | } |
75 | 110 … | } |
76 | 111 … | |
77 | -class ID { | |
78 | - constructor (id) { | |
79 | - this.id = id | |
80 | - } | |
81 | - | |
82 | - encodeCBOR (gen) { | |
83 | - return gen.write(new cbor.Tagged(TAGS.id, this.id)) | |
84 | - } | |
85 | -} | |
86 | - | |
87 | -/** | |
88 | - * This implements Messages for Primea | |
89 | - * @module primea-message | |
90 | - */ | |
91 | 112 … | class Message extends EventEmitter { |
92 | 113 … | /** |
114 … | + * This implements Messages for Primea | |
93 | 115 … | * @param {Object} opts |
94 | 116 … | * @param {ArrayBuffer} opts.data - the payload of the message |
95 | 117 … | * @param {Array<Object>} opts.caps - an array of capabilities to send in the message |
96 | 118 … | */ |
.travis.yml | ||
---|---|---|
@@ -1,0 +1,24 @@ | ||
1 … | +language: node_js | |
2 … | +node_js: | |
3 … | + - "8" | |
4 … | +env: | |
5 … | + global: | |
6 … | + - CXX=g++-4.8 | |
7 … | + matrix: | |
8 … | + - TEST_SUITE=test | |
9 … | +addons: | |
10 … | + apt: | |
11 … | + sources: | |
12 … | + - ubuntu-toolchain-r-test | |
13 … | + packages: | |
14 … | + - g++-4.8 | |
15 … | +matrix: | |
16 … | + fast_finish: true | |
17 … | + include: | |
18 … | + - os: linux | |
19 … | + node_js: "8" | |
20 … | + env: TEST_SUITE=coveralls | |
21 … | + - os: linux | |
22 … | + node_js: "8" | |
23 … | + env: TEST_SUITE=lint | |
24 … | +script: npm run $TEST_SUITE |
docs/index.md | |||
---|---|---|---|
@@ -1,0 +1,107 @@ | |||
1 … | +<!-- Generated by documentation.js. Update this documentation by updating the source code. --> | ||
2 … | + | ||
3 … | +### Table of Contents | ||
4 … | + | ||
5 … | +- [constructor][1] | ||
6 … | +- [constructor][2] | ||
7 … | +- [constructor][3] | ||
8 … | +- [getFuncRef][4] | ||
9 … | +- [constructor][5] | ||
10 … | + | ||
11 … | +## | ||
12 … | + | ||
13 … | +[index.js:11-18][6] | ||
14 … | + | ||
15 … | +a cbor decoder for the objects | ||
16 … | + | ||
17 … | +Type: [Object][7] | ||
18 … | + | ||
19 … | +## constructor | ||
20 … | + | ||
21 … | +[index.js:47-49][8] | ||
22 … | + | ||
23 … | +an ID | ||
24 … | + | ||
25 … | +**Parameters** | ||
26 … | + | ||
27 … | +- `id` **[Buffer][9]** the id as an buffer | ||
28 … | + | ||
29 … | +## constructor | ||
30 … | + | ||
31 … | +[index.js:64-69][10] | ||
32 … | + | ||
33 … | +A function reference | ||
34 … | + | ||
35 … | +**Parameters** | ||
36 … | + | ||
37 … | +- `opts` **[Object][7]** | ||
38 … | + - `opts.identifier` **any** the function's identifier | ||
39 … | + - `opts.actorID` **ID** the id of the actor | ||
40 … | + - `opts.params` **[Array][11]** the params of the function | ||
41 … | + | ||
42 … | +## constructor | ||
43 … | + | ||
44 … | +[index.js:87-90][12] | ||
45 … | + | ||
46 … | +A module reference | ||
47 … | + | ||
48 … | +**Parameters** | ||
49 … | + | ||
50 … | +- `exports` **[Object][7]** a map of exported function to params for the funcion if any | ||
51 … | +- `id` **ID** the id of the actor | ||
52 … | + | ||
53 … | +## getFuncRef | ||
54 … | + | ||
55 … | +[index.js:97-105][13] | ||
56 … | + | ||
57 … | +return a function refernce given the name of the function | ||
58 … | + | ||
59 … | +**Parameters** | ||
60 … | + | ||
61 … | +- `name` **[string][14]** | ||
62 … | + | ||
63 … | +Returns **FunctionRef** | ||
64 … | + | ||
65 … | +## constructor | ||
66 … | + | ||
67 … | +[index.js:119-133][15] | ||
68 … | + | ||
69 … | +This implements Messages for Primea | ||
70 … | + | ||
71 … | +**Parameters** | ||
72 … | + | ||
73 … | +- `opts` **[Object][7]** | ||
74 … | + - `opts.data` **[ArrayBuffer][16]** the payload of the message | ||
75 … | + - `opts.caps` **[Array][11]<[Object][7]>** an array of capabilities to send in the message | ||
76 … | + | ||
77 … | +[1]: #constructor | ||
78 … | + | ||
79 … | +[2]: #constructor-1 | ||
80 … | + | ||
81 … | +[3]: #constructor-2 | ||
82 … | + | ||
83 … | +[4]: #getfuncref | ||
84 … | + | ||
85 … | +[5]: #constructor-3 | ||
86 … | + | ||
87 … | +[6]: https://github.com/primea/js-primea-objects/blob/136ef4bd7ca697c515688fa0a7b42c49930b5710/index.js#L11-L18 "Source code on GitHub" | ||
88 … | + | ||
89 … | +[7]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object | ||
90 … | + | ||
91 … | +[8]: https://github.com/primea/js-primea-objects/blob/136ef4bd7ca697c515688fa0a7b42c49930b5710/index.js#L47-L49 "Source code on GitHub" | ||
92 … | + | ||
93 … | +[9]: https://nodejs.org/api/buffer.html | ||
94 … | + | ||
95 … | +[10]: https://github.com/primea/js-primea-objects/blob/136ef4bd7ca697c515688fa0a7b42c49930b5710/index.js#L64-L69 "Source code on GitHub" | ||
96 … | + | ||
97 … | +[11]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array | ||
98 … | + | ||
99 … | +[12]: https://github.com/primea/js-primea-objects/blob/136ef4bd7ca697c515688fa0a7b42c49930b5710/index.js#L87-L90 "Source code on GitHub" | ||
100 … | + | ||
101 … | +[13]: https://github.com/primea/js-primea-objects/blob/136ef4bd7ca697c515688fa0a7b42c49930b5710/index.js#L97-L105 "Source code on GitHub" | ||
102 … | + | ||
103 … | +[14]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String | ||
104 … | + | ||
105 … | +[15]: https://github.com/primea/js-primea-objects/blob/136ef4bd7ca697c515688fa0a7b42c49930b5710/index.js#L119-L133 "Source code on GitHub" | ||
106 … | + | ||
107 … | +[16]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer |
Built with git-ssb-web