Booleans.toBoolean()

Convert the given string value to a boolean.

This machine specifically converts the strings 'true' and '1' to the boolean `true`, and the strings 'false', '0' and '' (the empty string) to the boolean `false`. All other string values will trigger an error. To simply determine whether a given string is "truthy", use the `Is truthy?` machine.

Usage

Hover over inputs/exits for more info.

var Booleans = require('machinepack-booleans');


// Convert the given string value to a boolean.

Booleans.toBoolean({

string: 'foo',

}).execSync();

Inputs

string required

The string to convert to a boolean.

'foo'

Exits

error

An unexpected error occurred.

success

OK.

true