10 examples of 'typescript boolean to string' in JavaScript

Every line of 'typescript boolean to string' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
21function boolToString(value) {
22 if (value) {
23 return 'true';
24 } else if (value === false) {
25 return 'false';
26 }
27 return 'null';
28}
28function boolToString(bool_value) {
29 return bool_value ? TRUE_STRING_VALUE : FALSE_STRING_VALUE;
30}
70function getBooleanString(value) {
71 if (value === 'false' || !value) {
72 return 'false';
73 }
74
75 return 'true';
76}
52export function bool(value: boolean): string {
53 return value ? 'T' : 'F';
54}
160function stringToBoolean(string){
161 switch(angular.isString(string) ? string.toLowerCase() : null){
162 case 'true': case 'yes': case '1': return true;
163 case 'false': case 'no': case '0': case null: return false;
164 default: return Boolean(string);
165 }
166}
131function booleanFromExpression(node: ts.Expression): boolean | undefined {
132 switch (node.kind) {
133 case ts.SyntaxKind.TrueKeyword:
134 return true;
135 case ts.SyntaxKind.FalseKeyword:
136 return false;
137 default:
138 return undefined;
139 }
140}
18function boolToString(boolValue) {
19 return boolValue === '1' ? 'Yes' : 'No';
20}
69boolean(node, jsonSchema, xsd) {
70 var booleanSchema = new JsonSchemaFile({});
71 booleanSchema.type = jsonSchemaTypes.BOOLEAN;
72
73 var integerSchema = new JsonSchemaFile({});
74 integerSchema.type = jsonSchemaTypes.INTEGER;
75 integerSchema.maximum = 1;
76 integerSchema.minimum = 0;
77
78 jsonSchema.oneOf.push(booleanSchema);
79 jsonSchema.oneOf.push(integerSchema);
80 return true;
81}
111isBooleanType() {
112 return (this.type.flags & ts.TypeFlags.Boolean) !== 0;
113}
106function stringToBoolean(str, defaultValue) {
107 if (typeof str === 'number')
108 str = str.toString();
109 return !str ? (defaultValue ? true : false)
110 : str.toLowerCase() === 'false' ? false
111 : /^\d+$/.test(str) ? (parseInt(str) ? true : false)
112 : true;
113}

Related snippets