Created
October 24, 2018 16:05
-
-
Save alizhdanov/8216849363ec57b9c697b0ccfeb01020 to your computer and use it in GitHub Desktop.
GraphQL Boolean serialization
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function serializeBoolean(value) { | |
if (typeof value === 'boolean') { | |
return value; | |
} | |
if (isFinite(value)) { | |
return value !== 0; | |
} | |
throw new TypeError( | |
`Boolean cannot represent a non boolean value: ${inspect(value)}`, | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment