How to use the is.null 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 googleapis / nodejs-spanner / src / codec.ts View on Github external
function decodeValue_(decoded, type) {
    if (is.null(decoded)) {
      return null;
    }
    switch (type.code) {
      case 'BYTES':
        decoded = Buffer.from(decoded, 'base64');
        break;
      case 'FLOAT64':
        decoded = new codec.Float(decoded);
        break;
      case 'INT64':
        decoded = new codec.Int(decoded);
        break;
      case 'TIMESTAMP':  // falls through
      case 'DATE':
        decoded = new Date(decoded);
        break;
github googleapis / nodejs-spanner / src / row-builder.ts View on Github external
static merge(type, head, tail) {
    const code = type.code;
    head = RowBuilder.getValue(head);
    tail = RowBuilder.getValue(tail);
    const isMergeable = !is.null(head) && !is.null(tail) && code !== 'FLOAT64';
    const merged: Array<{}> = [];
    let mergedItems;
    if (code === 'ARRAY') {
      const arrayType = type.arrayElementType;
      mergedItems = RowBuilder.merge(arrayType, head.pop(), tail.shift());
      merged.push(head.concat(mergedItems).concat(tail));
    } else if (code === 'STRUCT') {
      const structType = type.structType.fields[head.length - 1].type;
      mergedItems = RowBuilder.merge(structType, head.pop(), tail.shift());
      merged.push(head.concat(mergedItems).concat(tail));
    } else if (isMergeable) {
      merged.push(head + tail);
    } else {
      merged.push(head, tail);
    }
    // Filter out empty strings.
github googleapis / nodejs-datastore / src / entity.ts View on Github external
export function encodeValue(value?: any): ValueProto {
    const valueProto: ValueProto = {};

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

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

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

    if (isDsInt(value)) {
      valueProto.integerValue = (value as Int).value;
      return valueProto;
    }
github GitbookIO / markup-it / syntaxes / html / rule.js View on Github external
function attrsToString(attrs) {
    var output = '', value;

    for (var key in attrs) {
        value = attrs[key];
        if (is.undefined(value) || is.null(value)) {
            continue;
        }

        if (is.string(value) && !value) {
            output += ' ' + key;
        } else {
            output += ' ' + key + '=' + JSON.stringify(value);
        }
    }

    return output;
}
github googleapis / nodejs-spanner / src / codec.ts View on Github external
};
    });

    return {
      type: 'struct',
      fields,
    };
  }

  if (is.array(field)) {
    let child;

    for (let i = 0; i < field.length; i++) {
      child = field[i];

      if (!is.null(child)) {
        break;
      }
    }

    return {
      type: 'array',
      child: getType(child),
    };
  }

  return 'unspecified';
}
github googleapis / nodejs-logging / src / common.ts View on Github external
encodeValue_(value: {}) {
    let convertedValue;

    if (is.null(value)) {
      convertedValue = {
        nullValue: 0,
      };
    } else if (is.number(value)) {
      convertedValue = {
        numberValue: value,
      };
    } else if (is.string(value)) {
      convertedValue = {
        stringValue: value,
      };
    } else if (is.boolean(value)) {
      convertedValue = {
        boolValue: value,
      };
    } else if (Buffer.isBuffer(value)) {

is

the definitive JavaScript type testing library

MIT
Latest version published 5 years ago

Package Health Score

71 / 100
Full package analysis