var debug = require('debug')('mongodb-schema:stream'); 
extracts a Javascript string from a BSON type to compute unique values.

@param {Any} value     value to be converted to a string
@return {String}       converted value
345813
function(value) {
  if (value && value._bsontype) {
    if (_.includes([ 'Decimal128', 'Long' ], value._bsontype)) {
      return value.toString();
    }
    if (_.includes([ 'Double', 'Int32' ], value._bsontype)) {
      return String(value.value);
    }
  }
  if (_.isString(value)) {
    return value;
  }
  return String(value);
}
57716
function(value) {
        switch (values.typeOf(value)) {
            case 'Null':
                return { type: 'NullLiteral' };

            case 'Boolean':
                return { type: 'BooleanLiteral', value: value };

            case 'Number':
                if (value !== value) {
                    return { type: 'NaNLiteral' };
                } else if (value === Infinity) {
                    return { type: 'InfinityLiteral', negative: false };
                } else if (value === -Infinity) {
                    return { type: 'InfinityLiteral', negative: true };
                } else {
                    return { type: 'NumberLiteral', value: value };
                }
                break;   // silence ESLint

            case 'String':
                return { type: 'StringLiteral', value: value };

            case 'RegExp':
                return {
                    type: 'RegExpLiteral',
                    pattern: value.source,
                    flags: value.toString().match(/\/(\w*)$/)[1]
                };

            case 'Date':
                return { type: 'MomentLiteral', value: value.valueOf() };

            case 'Duration':
                return { type: 'DurationLiteral', value: value.valueOf() };

            case 'Filter':
                return { type: 'FilterLiteral', ast: value.ast, source: value.source };

            case 'Array':
                return { type: 'ArrayLiteral', elements: _.map(value, values.toAST) };

            case 'Object':
                return {
                    type: 'ObjectLiteral',
                    properties: _.map(value, function(value, key) {
                        return {
                            type: 'ObjectProperty',
                            key: values.toAST(key),
                            value: values.toAST(value)
                        };
                    })
                };
        }
    }
874690
private String parseValue(String fieldType, Object value) {
		if (TypeConver.isBasicType(fieldType)) {
			if (value != null) {
				return value.toString();
			} else {
				return null;
			}
		}
		return null;
	}
181921
function (value) {

      if(value === undefined) return null;

      if(value instanceof Date) {
         return value;
      }

      var date = null, replace, regex, a = 0, length = helpers.date.regex.length;

      value = value.toString();

      for(a; a < length; a++) {
         regex = helpers.date.regex[a];

         if(value.match(regex.test)) {

            if(regex.replace.indexOf("-") > -1){
               replace = value.replace(regex.test, regex.replace).split("-");
               date = new Date(parseInt(replace[0]), parseInt(--replace[1]), parseInt(replace[2]));
            }
            else {
               replace = parseInt(value.replace(regex.test, regex.replace));
               date = new Date(replace);
            }

            break;
         }
      }

      return date;
   }
866907
function(value)
			{
				switch (typeof value)
				{
					case "number":
					case "boolean":
						return value + "";
					case "string":
						return "\"" + value + "\"";
					default:
						if (value === undefined)
							return "undefined";
						if (value === null)
							return "null";
						var hash = value[_HASH_KEY];
						if (!hash)
							hash = value[_HASH_KEY] = "#" + (++_hashCount);
						return hash;
				}
			}
167258
function getGraphQLValue(value) {
      if ("string" === typeof value) {
        value = JSON.stringify(value);
      } else if (Array.isArray(value)) {
        value = value.map(item => {
            return getGraphQLValue(item);
            }).join();
        value = `[${value}]`;
      } else if ("object" === typeof value) {
      /*if (value.toSource)
            value = value.toSource().slice(2,-2);
        else*/
            value = objectToString(value);
            //console.error("No toSource!!",value);
      }
      return value;
}
801217
function getValueToValidate (schema, value) {
  // Is the value empty?
  if (value === undefined || value === "" ||
    (schema.type === "object" && _.isObject(value) && _.isEmpty(value))) {

    // It's blank, so return the default/example value (if there is one)
    if (schema.default !== undefined) {
      value = schema.default;
    }
    else if (schema.example !== undefined) {
      value = schema.example;
    }
  }

  // Special case for Buffers
  if (value && value.type === "Buffer" && _.isArray(value.data)) {
    value = new Buffer(value.data);
  }

  // It's not empty, so return the existing value
  return value;
}
806206
function stringToHex(value) {
  const val = value == null ? '' : value;

  let hex = '';
  let tmp = '';

  for (let i = 0; i < val.length; i++) {
    // Convert to Hex and Ensure it's in 2 digit sets
    tmp = ('0000' + val.charCodeAt(i).toString(16)).slice(-2);
    hex += '' + tmp;
  }

  return hex;
}
324458
function(value)
	{
		var keys = this.getKeys(value);
		var output = null;
		var i;
		var len = keys.length;

		// array
		if ( value instanceof Array )
			/*( 1 == len && '0' == keys[0] )
			||
			( len > 1 && this.reduceArray(keys, function(v,w){return Math.floor(v+w);}, 0) == len * (len - 1) / 2) )*/
		{
			output = [];
			for ( i = 0; i < len; i++ )
			{
				output.push(this.dump(value[keys[i]]));
			}

			return '['+output.join(', ')+']';
		}

		// mapping
		output = [];
		for ( i = 0; i < len; i++ )
		{
			output.push(this.dump(keys[i])+': '+this.dump(value[keys[i]]));
		}

		return '{ '+output.join(', ')+' }';
	}
835937
public static String typeString(Object value) {
        return null == value || Primitive.NULL == value
            ? "null"
            : value instanceof Primitive
                ? ((Primitive) value).getType().getSimpleName()
                : typeString(value.getClass());
    }
832776
function (value, node) {
        var i, el;
        var valid = (typeof value === "object" && value instanceof Array);
        if (valid) {
            var pos = 0;
            for (i = 0; i < node.elements.length; i++) {
                el = node.elements[i];
                var found = 0;
                while (found < el.arity[1] && pos < value.length) {
                    if (!this.exec_spec(value[pos], el.element))  /*  RECURSION  */
                        break;
                    found++;
                    pos++;
                }
                if (found < el.arity[0]) {
                    valid = false;
                    break;
                }
            }
            if (pos < value.length)
                valid = false;
        }
        return valid;
    }
759984
function (value, node) {
        var i, el;
        var valid = (typeof value === "object");
        var fields = {};
        if (valid) {
            /*  pass 1: ensure that all mandatory fields exist
                and determine map of valid fields for pass 2  */
            for (i = 0; i < node.elements.length; i++) {
                el = node.elements[i];
                fields[el.key] = el.element;
                if (   el.arity[0] > 0
                    && (   (el.key === "@" && _cs.keysof(value).length === 0)
                        || (el.key !== "@" && typeof value[el.key] === "undefined"))) {
                    valid = false;
                    break;
                }
            }
        }
        if (valid) {
            /*  pass 2: ensure that no unknown fields exist
                and that all existing fields are valid  */
            for (var field in value) {
                if (   !Object.hasOwnProperty.call(value, field)
                    || !Object.propertyIsEnumerable.call(value, field)
                    || field === "constructor"
                    || field === "prototype"                          )
                    continue;
                if (   typeof fields[field] !== "undefined"
                    && this.exec_spec(value[field], fields[field])) /*  RECURSION  */
                    continue;
                if (   typeof fields["@"] !== "undefined"
                    && this.exec_spec(value[field], fields["@"]))   /*  RECURSION  */
                    continue;
                valid = false;
                break;
            }
        }
        return valid;
    }
1089457
public static String toJsonString(Object value) {
        if (value == null) {
            return "null";
        }
        else if (value.getClass().equals(String.class)) {
            return "\"" + StringUtils.jsonEncoding(value.toString()) + "\"";
        }
        // else it's a RawJson, Boolean or Number so no escaping or quotes
        else {
            return value.toString();
        }
    }
1152832
function handleFieldValue (value) {
      if (!(value instanceof Buffer || typeof value === 'string')) {
        if (is(value).a(Object)) {
          if (value instanceof fs.FileReadStream) {
            return value
          } else {
            return Unirest.serializers.json(value)
          }
        } else {
          return value.toString()
        }
      } else return value
    }
809312
function(value) {
      switch (typeof value) {
        case 'undefined':
          return this.undefined;
        case 'string':
          return this.string;
        case 'number':
          if (value % 1 === 0) {
            return this.integer;
          } else {
            return this.double;
          }
          break;
        case 'boolean':
          return this.boolean;
        case 'function':
          return this["function"];
        default:
          if (value === null) {
            return this["null"];
          } else if (value instanceof Date) {
            return this.datetime;
          } else if (value instanceof Array) {
            return this.array;
          } else if (Buffer.isBuffer(value)) {
            throw new TypeError("Value cannot be a buffer");
          } else if (value instanceof Object) {
            return this.object;
          } else {
            throw new TypeError('Value must either be a string, integer, double, boolean, date, array, object or function');
          }
      }
    }
956328
function ( value ) {
            var result = Object.prototype.toString.call( value );
            result = result.match( /^\[\W*object\W+([a-zA-Z]+)\W*\]$/ );
    
            if ( result && result.length > 1 ) {
                result = result[1];
            }
    
            if ( result === 'String' ) {
                if ( $B.color.is(value) ) {
                    result = 'Color';
                }
            } else if ( result === 'Number' ) {
                if ( isNaN(value) ) {
                    result = 'NaN';
                }
            } else if ( result === 'Object' ) {
                if ( this.isUndefined(value) ) {
                    result = 'Undefined';
                } else if ( this.isNull(value) ) {
                    result = 'Null';
                } else if ( this.isElement(value) ) {
                    result = 'Element';
                }
            } else {
                if ( this.isElement(value) ) {
                    result = 'Element';
                }
            }
    
            return result;
        }
308201
public static String toJson(Object value) {
        if (value instanceof String) {
            return '"' + (String) value + '"';
        } else if (value instanceof Collection) {
            return "[" + toJsonCollection((Collection) value) + "]";
        } else {
            throw new IllegalArgumentException("Unable to convert " + value + " to JSON");
        }
    }