How to use the @sindresorhus/is.emptyStringOrWhitespace function in @sindresorhus/is

To help you get started, we’ve selected a few @sindresorhus/is 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 forwardemail / email-templates / src / index.js View on Github external
// but we really don't need to support cid
      // 
      message.text = htmlToText.fromString(
        message.html,
        this.config.htmlToText
      );

    // if we only want a text-based version of the email
    if (this.config.textOnly) delete message.html;

    // if no subject, html, or text content exists then we should
    // throw an error that says at least one must be found
    // otherwise the email would be blank (defeats purpose of email-templates)
    if (
      (!is.string(message.subject) ||
        is.emptyStringOrWhitespace(message.subject)) &&
      (!is.string(message.text) || is.emptyStringOrWhitespace(message.text)) &&
      (!is.string(message.html) || is.emptyStringOrWhitespace(message.html)) &&
      _.isArray(message.attachments) &&
      _.isEmpty(message.attachments)
    )
      throw new Error(
        `No content was passed for subject, html, text, nor attachments message props. Check that the files for the template "${template}" exist.`
      );

    return message;
  }
github forwardemail / email-templates / src / index.js View on Github external
// 
      message.text = htmlToText.fromString(
        message.html,
        this.config.htmlToText
      );

    // if we only want a text-based version of the email
    if (this.config.textOnly) delete message.html;

    // if no subject, html, or text content exists then we should
    // throw an error that says at least one must be found
    // otherwise the email would be blank (defeats purpose of email-templates)
    if (
      (!is.string(message.subject) ||
        is.emptyStringOrWhitespace(message.subject)) &&
      (!is.string(message.text) || is.emptyStringOrWhitespace(message.text)) &&
      (!is.string(message.html) || is.emptyStringOrWhitespace(message.html)) &&
      _.isArray(message.attachments) &&
      _.isEmpty(message.attachments)
    )
      throw new Error(
        `No content was passed for subject, html, text, nor attachments message props. Check that the files for the template "${template}" exist.`
      );

    return message;
  }
github forwardemail / email-templates / src / index.js View on Github external
message.text = htmlToText.fromString(
        message.html,
        this.config.htmlToText
      );

    // if we only want a text-based version of the email
    if (this.config.textOnly) delete message.html;

    // if no subject, html, or text content exists then we should
    // throw an error that says at least one must be found
    // otherwise the email would be blank (defeats purpose of email-templates)
    if (
      (!is.string(message.subject) ||
        is.emptyStringOrWhitespace(message.subject)) &&
      (!is.string(message.text) || is.emptyStringOrWhitespace(message.text)) &&
      (!is.string(message.html) || is.emptyStringOrWhitespace(message.html)) &&
      _.isArray(message.attachments) &&
      _.isEmpty(message.attachments)
    )
      throw new Error(
        `No content was passed for subject, html, text, nor attachments message props. Check that the files for the template "${template}" exist.`
      );

    return message;
  }