How to use the boolean function in boolean

To help you get started, we’ve selected a few boolean examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github LearningLocker / learninglocker / lib / connections / nodemailer.js View on Github external
import boolean from 'boolean';
import defaultTo from 'lodash/defaultTo';
import logger from 'lib/logger';
import nodemailer from 'nodemailer';

const smtpConfig = {
  host: process.env.SMTP_HOST,
  port: process.env.SMTP_PORT,
  secure: boolean(defaultTo(process.env.SMTP_SECURED, false)),
  ignoreTLS: boolean(defaultTo(process.env.SMTP_IGNORE_TLS, false)),
  requireTLS: boolean(defaultTo(process.env.SMTP_REQUIRE_TLS, false))
};

// Placed like this since the boolean set default can be hard to read in an if condition.
const sendAuthRequest = boolean(defaultTo(process.env.SMTP_AUTH_REQUEST, true));

// Do not want the auth object in the smtpConfig object if sendAuthRequest is false, default is true.
if (sendAuthRequest) {
  Object.assign(smtpConfig, {
    auth: {
      user: process.env.SMTP_USER,
      pass: process.env.SMTP_PASS
    }
  });
}

let mailer; //eslint-disable-line

if (process.env.TESTING) {
  mailer = {
    sendMail: (opts) => {
github gajus / slonik / src / config.js View on Github external
// @flow

/* eslint-disable no-process-env */

import boolean from 'boolean';

export const SLONIK_LOG_STACK_TRACE = boolean(process.env.SLONIK_LOG_STACK_TRACE);
export const SLONIK_LOG_VALUES = boolean(process.env.SLONIK_LOG_VALUES);
github gajus / roarr / src / config.js View on Github external
// @flow

/* eslint-disable no-process-env */

import parseBoolean from 'boolean';

const ROARR_BUFFER_SIZE = process.env.ROARR_BUFFER_SIZE === undefined ? 0 : parseInt(process.env.ROARR_BUFFER_SIZE, 10);
const ROARR_LOG = parseBoolean(process.env.ROARR_LOG) === true;
const ROARR_STREAM = (process.env.ROARR_STREAM || 'STDOUT').toUpperCase();

if (ROARR_STREAM !== 'STDOUT' && ROARR_STREAM !== 'STDERR') {
  throw new Error('Unexpected ROARR_STREAM value.');
}

if (isNaN(ROARR_BUFFER_SIZE)) {
  throw new TypeError('Unexpected ROARR_BUFFER_SIZE value.');
}

export {
  ROARR_BUFFER_SIZE,
  ROARR_LOG,
  ROARR_STREAM
};
github LearningLocker / learninglocker / lib / connections / nodemailer.js View on Github external
import boolean from 'boolean';
import defaultTo from 'lodash/defaultTo';
import logger from 'lib/logger';
import nodemailer from 'nodemailer';

const smtpConfig = {
  host: process.env.SMTP_HOST,
  port: process.env.SMTP_PORT,
  secure: boolean(defaultTo(process.env.SMTP_SECURED, false)),
  ignoreTLS: boolean(defaultTo(process.env.SMTP_IGNORE_TLS, false)),
  requireTLS: boolean(defaultTo(process.env.SMTP_REQUIRE_TLS, false))
};

// Placed like this since the boolean set default can be hard to read in an if condition.
const sendAuthRequest = boolean(defaultTo(process.env.SMTP_AUTH_REQUEST, true));

// Do not want the auth object in the smtpConfig object if sendAuthRequest is false, default is true.
if (sendAuthRequest) {
  Object.assign(smtpConfig, {
    auth: {
      user: process.env.SMTP_USER,
      pass: process.env.SMTP_PASS
    }
  });
}
github relax / relax / lib / shared / screens / admin / shared / components / input-options / checkbox / index.jsx View on Github external
toggle (event) {
    event.preventDefault();
    const {disabled, onChange, value} = this.props;

    if (!disabled && onChange) {
      onChange(!boolean(value));
    }
  }
github LearningLocker / learninglocker / ui / src / containers / DashboardSharing / index.js View on Github external
handleFilterRequiredChange: ({ updateSelectedSharable }) => (value) => {
    updateSelectedSharable([{
      path: 'filterRequired',
      value: boolean(value)
    }]);
  },
  onChangeTimezone: ({ model, organisationModel, updateSelectedSharable }) => (value) => {
github LearningLocker / learninglocker / api / src / routes / HttpRoutes.js View on Github external
preDelete: (req, res, next) => {
    if (!boolean(get(process.env, 'ENABLE_STATEMENT_DELETION', true))) {
      return res.send('Statement deletions not enabled for this instance', 405);
    }
    if (!req.params.id) {
      return res.send('No ID sent', 400);
    }
    next();
    return;
  },
  preUpdate: (req, res) => res.sendStatus(405),
github LearningLocker / learninglocker / ui / src / config.js View on Github external
import boolean from 'boolean';
import defaultTo from 'lodash/defaultTo';

const title = 'Learning Locker';
const description = 'The open source learning record store';
const isProduction = process.env.NODE_ENV === 'production';
const host = process.env.UI_HOST || '127.0.0.1';
const enableFrameguard = boolean(defaultTo(process.env.ENABLE_FRAMEGUARD, true));
const port = parseInt(process.env.UI_PORT || process.env.PORT, 10);
const devPort = 3131;
const assetPort = isProduction ? port : devPort;

let assetPath = '';
if (!isProduction) {
  assetPath += `//${host}:${assetPort}`;
}
assetPath += '/';

export default {
  host,
  port,
  devPort,
  assetPath,
  apiHost: process.env.API_HOST || '127.0.0.1',
github relax / relax / lib / shared / screens / admin / shared / components / input-options / checkbox / index.jsx View on Github external
render () {
    const {disabled, value, white} = this.props;
    const checkboxValue = boolean(value);

    return (
      <span disabled="">
        {checkboxValue &amp;&amp; <i></i>}
      </span>
    );
  }
}
github LearningLocker / learninglocker / api / src / routes / HttpRoutes.js View on Github external
router.get(routes.GOOGLE_AUTH, (req, res) => {
  const enabled = boolean(process.env.GOOGLE_ENABLED);
  jsonSuccess(res)({ enabled });
});

boolean

boolean converts lots of things to boolean.

MIT
Latest version published 2 years ago

Package Health Score

71 / 100
Full package analysis

Popular boolean functions