Cleanup Option result value handling (#731)

This commit is contained in:
Jaco Greeff
2019-02-22 09:58:24 +01:00
committed by GitHub
parent d8db0f9b78
commit f8bd74ee85
2 changed files with 4 additions and 2 deletions
+2
View File
@@ -35,6 +35,8 @@ export default class Option<T extends Codec> extends Base<T> implements Codec {
return isNull(value) || isUndefined(value) || value instanceof Null
? new Null()
: (
// don't re-create when the type is correct - it could be derived from the base
// and at the same time since it exists, no need to have additional overhead
value instanceof Type
? value
: new Type(value)