diff options
author | Tyler Schicke <tyler_schicke@brown.edu> | 2019-04-19 23:13:17 -0400 |
---|---|---|
committer | Tyler Schicke <tyler_schicke@brown.edu> | 2019-04-19 23:13:17 -0400 |
commit | e678ac7f21e0c44eaa8ad88577093cdb313e21bb (patch) | |
tree | 9fb0f73365ae427ebbc5c48ca1887394e16fe5bd /src/new_fields/URLField.ts | |
parent | 3e96161afe4f48afa6abd1b2158b5a1c4fe85a32 (diff) |
Deleted more old fields and split new stuff into multiple files
Diffstat (limited to 'src/new_fields/URLField.ts')
-rw-r--r-- | src/new_fields/URLField.ts | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/new_fields/URLField.ts b/src/new_fields/URLField.ts new file mode 100644 index 000000000..d27a2b692 --- /dev/null +++ b/src/new_fields/URLField.ts @@ -0,0 +1,25 @@ +import { Deserializable } from "../client/util/SerializationHelper"; +import { serializable } from "serializr"; +import { ObjectField } from "./Doc"; + +function url() { + return { + serializer: function (value: URL) { + return value.href; + }, + deserializer: function (jsonValue: string, done: (err: any, val: any) => void) { + done(undefined, new URL(jsonValue)); + } + }; +} + +@Deserializable("url") +export class URLField extends ObjectField { + @serializable(url()) + readonly url: URL; + + constructor(url: URL) { + super(); + this.url = url; + } +}
\ No newline at end of file |