How to use the is.empty function in is

To help you get started, we’ve selected a few 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 leepowellcouk / mongoose-validator / lib / mongoose-validator.js View on Github external
const getValidatorFn = function getValidatorFn(validator) {
  // Validator has been passed as a function so just return it
  if (is.function(validator)) {
    return validator
  }
  // Validator has been passed as a string (i.e. 'isLength'), try to find the validator is validator.js or custom validators
  if (is.string(validator) && !is.empty(validator)) {
    return validatorjs[validator] || customValidators[validator] || undefined
  }
}
github massgov / mayflower / react / src / components / organisms / FeedbackForm / index.js View on Github external
checkForErrors = () => {
    let hasError = [...this.state.hasError];
    const { radioId, noFeedbackId } = this.props;
    const { feedbackChoice, formSubmitted } = this.state;
    // The user has not selected yes or no.
    if (!hasError.includes(radioId) && feedbackChoice === null) {
      hasError.push(radioId);
    }
    if (hasError.includes(radioId) && !is.nil(feedbackChoice)) {
      hasError = this.removeError(hasError, radioId);
    }
    // The user has selected no but has not typed any feedback.
    if (!hasError.includes(noFeedbackId) && feedbackChoice === false && formSubmitted && is.empty(this.noTextArea.current.value)) {
      hasError.push(noFeedbackId);
    } else if (hasError.includes(noFeedbackId) && feedbackChoice === false && !is.empty(this.noTextArea.current.value)) {
      hasError = this.removeError(hasError, noFeedbackId);
    }
    // If the user changed choices from no to yes, remove the error for no if there was one.
    if (feedbackChoice === true && hasError.includes(noFeedbackId)) {
      hasError = this.removeError(hasError, noFeedbackId);
    }
    // Prevent calling setState too often while typing in textareas.
    if (!is.equal(hasError, this.state.hasError)) {
      this.setState({ hasError });
    }
    return hasError;
  };
  handleSubmit = (e) => {
github segmentio / analytics.js-integrations / integrations / amplitude / lib / index.js View on Github external
Amplitude.prototype.identify = function(identify) {
  this.setDeviceIdFromAnonymousId(identify);

  var id = identify.userId();
  var traits = identify.traits();
  if (id) window.amplitude.getInstance().setUserId(id);

  // map query params from context url if opted in
  var mapQueryParams = this.options.mapQueryParams;
  var query = identify.proxy('context.page.search');
  if (!is.empty(mapQueryParams)) {
    // since we accept any arbitrary property name and we dont have conditional UI components
    // in the app where we can limit users to only add a single mapping, so excuse the temporary jank
    each(function(value, key) {
      traits[key] = query;
    }, mapQueryParams);
  }

  this.setTraits(traits);

  // Set user groups: https://amplitude.zendesk.com/hc/en-us/articles/115001361248#setting-user-groups
  var groups = identify.options(this.name).groups;
  if (groups && is.object(groups)) {
    for (var group in groups) {
      if (groups.hasOwnProperty(group))
        window.amplitude.getInstance().setGroup(group, groups[group]);
    }
github segmentio / analytics.js-integrations / integrations / mixpanel / lib / index.js View on Github external
var query;
  if (props.link_query) {
    query = props.link_query; // DOM query
    delete props.link_query;
    window.mixpanel.track_links(query, track.event(), props);
  } else if (props.form_query) {
    // DOM query
    query = props.form_query;
    delete props.form_query;
    window.mixpanel.track_forms(query, track.event(), props);
  } else {
    window.mixpanel.track(track.event(), props);
  }

  // register super properties if present in context.mixpanel.superProperties
  if (!is.empty(superProps)) {
    window.mixpanel.register(superProps);
  }
};
github massgov / mayflower / react / src / components / organisms / FeedbackForm / index.js View on Github external
checkForErrors = () => {
    let hasError = [...this.state.hasError];
    const { radioId, noFeedbackId } = this.props;
    const { feedbackChoice, formSubmitted } = this.state;
    // The user has not selected yes or no.
    if (!hasError.includes(radioId) && feedbackChoice === null) {
      hasError.push(radioId);
    }
    if (hasError.includes(radioId) && !is.nil(feedbackChoice)) {
      hasError = this.removeError(hasError, radioId);
    }
    // The user has selected no but has not typed any feedback.
    if (!hasError.includes(noFeedbackId) && feedbackChoice === false && formSubmitted && is.empty(this.noTextArea.current.value)) {
      hasError.push(noFeedbackId);
    } else if (hasError.includes(noFeedbackId) && feedbackChoice === false && !is.empty(this.noTextArea.current.value)) {
      hasError = this.removeError(hasError, noFeedbackId);
    }
    // If the user changed choices from no to yes, remove the error for no if there was one.
    if (feedbackChoice === true && hasError.includes(noFeedbackId)) {
      hasError = this.removeError(hasError, noFeedbackId);
    }
    // Prevent calling setState too often while typing in textareas.
    if (!is.equal(hasError, this.state.hasError)) {
      this.setState({ hasError });
    }
    return hasError;
  };
  handleSubmit = (e) => {
github segmentio / analytics.js-integrations / integrations / criteo / lib / index.js View on Github external
Criteo.prototype.page = function(page) {
  var homeUrl = this.options.homeUrl;
  var pageName = (page.name() || '').toLowerCase();
  var path = page.path();
  var url = page.url();
  var event = [{ event: 'viewHome' }];
  var payload = [];
  var supportingPageData = this.options.supportingPageData;
  var properties = page.properties(this.options.supportingPageData);
  var extraData = pick(values(supportingPageData), properties);

  if (!is.empty(extraData)) {
    window.criteo_q.push(extend(extraData, { event: 'setData' }));
  }

  if (url === homeUrl || pageName === 'home' || path === '/') {
    payload = event.concat(this.setExtraData(page));
    window.criteo_q.push.apply(window.criteo_q, payload);
  }
};
github massgov / mayflower / react / src / components / atoms / forms / InputTextFuzzy / index.js View on Github external
handleChange = (e) => {
    e.persist();
    const { value } = e.target;
    if (is.empty(value)) {
      const suggestions = this.optionsToSuggestions(this.props.options);
      if (this.props.renderDefaultSuggestion) {
        this.setState({
          suggestions,
          value: ''
        }, () => {
          if (is.fn(this.props.onChange)) {
            this.props.onChange({ event: e, value, suggestions });
          }
        });
      } else if (is.fn(this.props.onChange)) {
        this.props.onChange({ event: e, value, suggestions });
      }
    } else {
      const suggestions = this.fuse.search(value);
      this.setState({
github massgov / mayflower / react / src / components / atoms / forms / InputCurrency / index.js View on Github external
const handleFocus = () => {
            const inputEl = ref.current;
            if (is.empty(inputEl.value)) {
              inputEl.removeAttribute('placeholder');
            }
          };
github googleapis / google-cloud-node / packages / vision / src / index.js View on Github external
return annotations.map(function(annotation, index) {
          var detectionType = types[index];
          var typeName = typeShortNameToRespName[detectionType];

          if (is.empty(annotation) || annotation.error) {
            var isPlural = typeName.charAt(typeName.length - 1) === 's';
            annotation[typeName] = isPlural ? [] : {};
          }

          return annotation;
        });
      }

is

the definitive JavaScript type testing library

MIT
Latest version published 5 years ago

Package Health Score

71 / 100
Full package analysis