summaryrefslogtreecommitdiff
path: root/std/encoding/toml.ts
diff options
context:
space:
mode:
authorRauf Islam <31735267+ItsRauf@users.noreply.github.com>2020-08-03 18:17:31 -0400
committerGitHub <noreply@github.com>2020-08-03 18:17:31 -0400
commit40ead6cc98ab1d02c8ca0587d24c218e81aa47b7 (patch)
tree3e8f5d0796d5d9e04c647be90e33ffce3bebe1ef /std/encoding/toml.ts
parent5fc5e7b54a9fba421dfc473016625a4f592403ed (diff)
fix(std/encoding/toml): Add boolean support to stringify (#6941)
Diffstat (limited to 'std/encoding/toml.ts')
-rw-r--r--std/encoding/toml.ts6
1 files changed, 6 insertions, 0 deletions
diff --git a/std/encoding/toml.ts b/std/encoding/toml.ts
index 336af97fb..bd6814ac3 100644
--- a/std/encoding/toml.ts
+++ b/std/encoding/toml.ts
@@ -471,6 +471,8 @@ class Dumper {
out.push(this._strDeclaration([prop], value.toString()));
} else if (typeof value === "number") {
out.push(this._numberDeclaration([prop], value));
+ } else if (typeof value === "boolean") {
+ out.push(this._boolDeclaration([prop], value));
} else if (
value instanceof Array &&
this._isSimplySerializable(value[0])
@@ -504,6 +506,7 @@ class Dumper {
return (
typeof value === "string" ||
typeof value === "number" ||
+ typeof value === "boolean" ||
value instanceof RegExp ||
value instanceof Date ||
value instanceof Array
@@ -538,6 +541,9 @@ class Dumper {
return `${this._declaration(keys)}${value}`;
}
}
+ _boolDeclaration(keys: string[], value: boolean): string {
+ return `${this._declaration(keys)}${value}`;
+ }
_dateDeclaration(keys: string[], value: Date): string {
function dtPad(v: string, lPad = 2): string {
return v.padStart(lPad, "0");