apply type to the single value
559744
def _type_single(self, value, _type):
        '  '
        if value is None or _type in (None, NoneType):
            # don't convert null values
            # default type is the original type if none set
            pass
        elif isinstance(value, _type):  # or values already of correct type
            # normalize all dates to epochs
            value = dt2ts(value) if _type in [datetime, date] else value
        else:
            if _type in (datetime, date):
                # normalize all dates to epochs
                value = dt2ts(value)
            elif _type in (unicode, str):
                # make sure all string types are properly unicoded
                value = to_encoding(value)
            else:
                try:
                    value = _type(value)
                except Exception:
                    value = to_encoding(value)
                    logger.error("typecast failed: %s(value=%s)" % (
                        _type.__name__, value))
                    raise
        return value
647709
function (value, type) {
    type = type || 'smart';

    switch (type) {
      case 'boolean':
      case 'bool':
        if (typeof value !== 'string') {
          value = !!value;
        } else {
          value = ['null', 'undefined', '0', 'false'].indexOf(value) === -1;
        }

        break;

      case 'string':
      case 'text':
        value = this.cast(value, 'boolean') ? value + '' : null
        break;

      case 'date':
      case 'datetime':
        value = new Date(value);
        break;

      case 'int':
      case 'integer':
      case 'number':
        value = ~~value;
        break;

      case 'float':
        value = parseFloat(value);
        break;

      case 'smart':
        value = this.cast(value, this.detect(value));
        break;

      default:
        throw new Error('Expected valid casting type.');
    }

    return value;
  }
829784
def type(self, value):
        

        self._type = None
        if value is None:
            return

        value = value.upper()
        if value in MOC_TYPES:
            self._type = value
        else:
            raise ValueError('MOC type must be one of ' + ', '.join(MOC_TYPES))
1348056
function (type) {
            var ret = null, meth;
            if (isString(type)) {
                ret = this._static.CAST_TYPES[type] || this._super(arguments);
            } else if (type === String) {
                meth += "CHAR";
            } else if (type === Number) {
                meth += "DECIMAL";
            } else if (type === DateTime) {
                meth += "DATETIME";
            } else if (type === Year) {
                meth += "Year";
            } else if (type === Time) {
                meth += "DATETIME";
            } else if (type === Double) {
                meth += "DECIMAL";
            } else {
                ret = this._super(arguments);
            }
            return ret;
        }
713719
def _ValidateValue(value, type_check):
  """"""
  if inspect.isclass(type_check):
    return isinstance(value, type_check)
  if isinstance(type_check, tuple):
    return _ValidateTuple(value, type_check)
  elif callable(type_check):
    return type_check(value)
  else:
    raise TypeError("Invalid type check '%s'" % repr(type_check))
1351205
def wrap(self, value):
        ''' '''
        self.validate_wrap(value)
        return self.computed_type.wrap(value)
797296
def _cast_output_to_type(value, typ):
    ''''''
    if typ == 'b':
        return bool(value)
    if typ == 'i':
        return int(value)
    return value
543114
function(type, value) {
    if (type.name === 'String') {
      // crop strings at 10k characters
      if (value.length > 10000) {
        value = value.slice(0, 10000);
      }
    }
    type.values.pushSome(value);
  }
1032707
def expand_single_values(var, scans):
        """"""
        if scans.size == 1:
            return var
        else:
            expanded = np.repeat(var, scans)
            expanded.attrs = var.attrs
            expanded.rename({expanded.dims[0]: 'y'})
            return expanded
1227398
def type_cast_value(self, ctx, value):
        
        if self.type.is_composite:
            if self.nargs <= 1:
                raise TypeError('Attempted to invoke composite type '
                                'but nargs has been set to %s.  This is '
                                'not supported; nargs needs to be set to '
                                'a fixed value > 1.' % self.nargs)
            if self.multiple:
                return tuple(self.type(x or (), self, ctx) for x in value or ())
            return self.type(value or (), self, ctx)

        def _convert(value, level):
            if level == 0:
                return self.type(value, self, ctx)
            return tuple(_convert(x, level - 1) for x in value or ())
        return _convert(value, (self.nargs != 1) + bool(self.multiple))
1269961
function parseValueOfType(value, type, options) {
  switch (type) {
    case String:
      return { value }

    case Number:
    case 'Integer':
    case Integer:
      // The global isFinite() function determines
      // whether the passed value is a finite number.
      // If  needed, the parameter is first converted to a number.
      if (!isFinite(value)) {
        return { error: 'invalid' }
      }
      if (type === Integer && !isInteger(value)) {
        return { error: 'invalid' }
      }
      // Convert strings to numbers.
      // Just an additional feature.
      // Won't happen when called from `readXlsx()`.
      if (typeof value === 'string') {
        value = parseFloat(value)
      }
      return { value }

    case 'URL':
    case URL:
      if (!isURL(value)) {
        return { error: 'invalid' }
      }
      return { value }

    case 'Email':
    case Email:
      if (!isEmail(value)) {
        return { error: 'invalid' }
      }
      return { value }

    case Date:
      // XLSX has no specific format for dates.
      // Sometimes a date can be heuristically detected.
      // https://github.com/catamphetamine/read-excel-file/issues/3#issuecomment-395770777
      if (value instanceof Date) {
        return { value }
      }
      if (typeof value === 'number') {
        if (!isFinite(value)) {
          return { error: 'invalid' }
        }
        value = parseInt(value)
        const date = parseDate(value, options.properties)
        if (!date) {
          return { error: 'invalid' }
        }
        return { value: date }
      }
      return { error: 'invalid' }

    case Boolean:
      if (typeof value === 'boolean') {
        return { value }
      }
      return { error: 'invalid' }

    default:
      throw new Error(`Unknown schema type: ${type && type.name || type}`)
  }
}
938800
function type (value) {
  const proto = toString.call(value)
  return proto.substring(8, proto.length - 1)
}
608202
function getType (val) {
  if (val === null) {
    return 'null'
  } else if (val === void 0) {
    return 'undefined'
  }
  return Object.prototype.toString.call(val)
    .replace(/^\[.+\s(.+?)]$/, '$1')
    .toLowerCase()
}
800767
def kind(self, value):
        
        if value == self._defaults['kind'] and 'kind' in self._values:
            del self._values['kind']
        else:
            self._values['kind'] = value
215512
def convert(self, value, _type):
        
        return self.type_convertors.get(_type, lambda x: x)(value)
1182002
def type(self, value):
        
        if value not in list(defines.Types.values()):
            raise AttributeError
        self._type = value
717545
def apply(self, search, field, value):
        """"""
        return search.query(
            self.query_type(  # pylint: disable=not-callable
                **{
                    field: {
                        self.operator: self.get_value_query(value)
                    }
                }
            )
        )