From d324f64bfefe0eda26f782d4bc32f7c4a59b3bcd Mon Sep 17 00:00:00 2001 From: David Date: Fri, 21 Jan 2022 21:21:01 +0000 Subject: [PATCH 1/2] docs: add TS examples for CloudEvent usage Signed-off-by: David --- README.md | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/README.md b/README.md index debc7857..652fbfb5 100644 --- a/README.md +++ b/README.md @@ -132,6 +132,29 @@ const ce = new CloudEvent({...}); const ce2 = ce.cloneWith({extension: "Value"}); ``` +You can create a `CloudEvent` object in many ways, for example: + +```js +import { CloudEvent, CloudEventV1, CloudEventV1Attributes } from "cloudevents"; +const ce: CloudEventV1 = { + specversion: '1.0', + source: '/some/source', + type: 'example', + id: '1234' +}; +const event = new CloudEvent(ce); +const ce2: CloudEventV1Attributes = { + specversion: '1.0', + source: '/some/source', + type: 'example', +}; +const event2 = new CloudEvent(ce2); +const event3 = new CloudEvent({ + source: '/some/source', + type: 'example', +}); +``` + ### Example Applications There are a few trivial example applications in From 3852c0197cd23785c3ad97a4b2769401a815e59b Mon Sep 17 00:00:00 2001 From: David Pereira Date: Wed, 26 Jan 2022 19:39:29 +0000 Subject: [PATCH 2/2] docs: fix wording in README Co-authored-by: Lance Ball Signed-off-by: David --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 652fbfb5..b3b7d810 100644 --- a/README.md +++ b/README.md @@ -132,7 +132,7 @@ const ce = new CloudEvent({...}); const ce2 = ce.cloneWith({extension: "Value"}); ``` -You can create a `CloudEvent` object in many ways, for example: +You can create a `CloudEvent` object in many ways, for example, in TypeScript: ```js import { CloudEvent, CloudEventV1, CloudEventV1Attributes } from "cloudevents";