npm module: asynchronous boolean logic and If-Then-Else branching