From 2b28def2621c55e74298faee6b55e0ceda3fe89a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabio=20Jos=C3=A9?= Date: Fri, 9 Nov 2018 14:18:29 -0200 Subject: [PATCH] Docs: how to use --- README.md | 35 ++++++++++++++++++++++++++++++----- 1 file changed, 30 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index a855602..e2f0720 100644 --- a/README.md +++ b/README.md @@ -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']); + +```