How to use the is.nil 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 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 });
    }
github leepowellcouk / mongoose-validator / lib / mongoose-validator.js View on Github external
return function validator(val) {
    const validatorArgs = [val].concat(args)
    if ((passIfEmpty && (is.empty(val) || is.nil(val))) || is.undef(val)) {
      return true
    }
    return fn.apply(this, validatorArgs)
  }
}
github GitbookIO / markup-it / src / html / serializeTag.js View on Github external
return attrs.reduce((output, value, key) => {
        if (is.undef(value) || is.nil(value)) {
            return output;
        } else if (is.equal(value, '')) {
            return `${output} ${key}`;
        }
        return `${output} ${key}="${escape(value)}"`;
    }, '');
}
github googleapis / nodejs-bigquery / src / index.ts View on Github external
function convert(schemaField, value) {
    if (is.nil(value)) {
      return value;
    }

    switch (schemaField.type) {
      case 'BOOLEAN':
      case 'BOOL': {
        value = value.toLowerCase() === 'true';
        break;
      }
      case 'BYTES': {
        value = Buffer.from(value, 'base64');
        break;
      }
      case 'FLOAT':
      case 'FLOAT64': {
        value = parseFloat(value);
github firebase / firebase-tools / src / firestore / encodeFirestoreValue.js View on Github external
}
    if (is.array(val)) {
      var encodedElements = [];
      for (var i = 0; i < val.length; ++i) {
        var enc = encodeHelper(val[i]);
        if (enc) {
          encodedElements.push(enc);
        }
      }
      return {
        arrayValue: {
          values: encodedElements,
        },
      };
    }
    if (is.nil(val)) {
      return {
        nullValue: "NULL_VALUE",
      };
    }
    if (is.instanceof(val, Buffer) || is.instanceof(val, Uint8Array)) {
      return {
        bytesValue: val,
      };
    }
    if (isPlainObject(val)) {
      return {
        mapValue: {
          fields: encodeFirestoreValue(val),
        },
      };
    }
github googleapis / google-cloud-node / packages / datastore / src / entity.js View on Github external
function encodeValue(value) {
  var valueProto = {};

  if (is.boolean(value)) {
    valueProto.booleanValue = value;
    return valueProto;
  }

  if (is.nil(value)) {
    valueProto.nullValue = 0;
    return valueProto;
  }

  if (is.number(value)) {
    if (value % 1 === 0) {
      value = new entity.Int(value);
    } else {
      value = new entity.Double(value);
    }
  }

  if (isDsInt(value)) {
    valueProto.integerValue = value.value;
    return valueProto;
  }
github googleapis / google-cloud-node / packages / bigquery / src / index.js View on Github external
function convert(schemaField, value) {
    if (is.nil(value)) {
      return value;
    }

    switch (schemaField.type) {
      case 'BOOLEAN':
      case 'BOOL': {
        value = value.toLowerCase() === 'true';
        break;
      }
      case 'BYTES': {
        value = new Buffer(value, 'base64');
        break;
      }
      case 'FLOAT':
      case 'FLOAT64': {
        value = parseFloat(value);

is

the definitive JavaScript type testing library

MIT
Latest version published 5 years ago

Package Health Score

71 / 100
Full package analysis