Skip to content

Commit fb3dc6d

Browse files
committed
squash: add a cloneWith method to add new items to a cloudevent
Signed-off-by: Lucas Holmquist <[email protected]>
1 parent 1abf8dc commit fb3dc6d

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/event/cloudevent.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,8 @@ export class CloudEvent implements CloudEventV1, CloudEventV03 {
100100
}
101101

102102
this.validate();
103+
104+
Object.freeze(this);
103105
}
104106

105107
get time(): string | Date {
@@ -167,4 +169,8 @@ export class CloudEvent implements CloudEventV1, CloudEventV03 {
167169
}
168170
}
169171
}
172+
173+
public cloneWith(options?: any): CloudEvent {
174+
return new CloudEvent(Object.assign({}, this.toJSON(), options));
175+
}
170176
}

0 commit comments

Comments
 (0)