Docs: how to use

Signed-off-by: Fabio José <fabiojose@gmail.com>
This commit is contained in:
Fabio José 2018-11-09 14:18:29 -02:00
parent b79703fd00
commit 8e2b7e159b
1 changed files with 30 additions and 5 deletions

View File

@ -8,6 +8,8 @@ Javascript SDK for CloudEvents
├── lib
│   ├── cloudevent.js
│   ├── jsonformatter.js
│   ├── format
│   │   └── json_0_1.js
│   ├── spec_0_1.js
│   └── spec_0_2.js
├── LICENSE
@ -19,13 +21,36 @@ Javascript SDK for CloudEvents
```
* `index.js`: exports the Cloudevent class
* `index.js`: library exports
* `lib/cloudevent.js`: implementation of Cloudevent class
* `lib/cloudevent.js`: implementation of Cloudevent, an interface
* `lib/jsonformatter.js`: implementation for JSON formatting [json-format](https://github.com/cloudevents/spec/blob/v0.1/json-format.md)
* `lib/format/json_0_1.js`: implementation for JSON formatting [version 0.1](https://github.com/cloudevents/spec/blob/v0.1/json-format.md)
* `lib/spec_0_1.js`: implementation for spec version 0.1
* `lib/spec_0_1.js`: implementation for spec [version 0.1](https://github.com/cloudevents/spec/blob/v0.1/spec.md)
* `lib/spec_0_2.js`: implementation for spec version 0.2
* `lib/spec_0_2.js`: implementation for spec [version 0.2](https://github.com/cloudevents/spec/blob/master/spec.md)
* `test/cloudevent_spec_0_1.js`: unit testing for spec 0.1
* `test/cloudevent_spec_0_2.js`: unit testing for spec 0.2
# How to use
```js
/*
* Constructs a default instance with:
* - Spec 0.1
* - JSON Format 0.1
*/
var cloudevent01 = new Cloudevent();
/*
* Constructs an instance with:
* - Spec 0.2
* - JSON Format 0.1
*/
var cloudevent02 = new Cloudevent(Cloudevent.specs['0.2']);
```