Transform any value into a readable stream.

@param {String | Number | Boolean | Promises} value
@param {Boolean?} objectMode
@param {Stream?} readable
@return {Stream}
@api public
173113
function morph (value, input) {
  const result = input || readable()
  const cb = map[type(value)] || end
  cb(result, value)
  return new Proxy(result, {
    get(target, key, receiver) {
      if (key !== 'pipe') return target[key]
      return function (dest) {
        pump(result, dest)
        return dest
      }
    }
  })
}
957414
function transform(value, options) {
  options = options || {};

  return traverse(value, {
    beforeObject: function(v) {
      if (options.removeFormats &&
          typeof v.format === 'string' &&
          typeof v.type === 'string' &&
          v.type !== 'string') {
        delete v.format;
      }

      return v;
    },
    afterObject: function(v) {
      if (options.convertRefs &&
          typeof v.type === 'string' &&
          constants.notModel.indexOf(v.type) < 0) {
        return { $ref: v.type };
      }

      return v;
    },
  });
}
611529
function byValue(object, value) {
  var key

  for (key in object) {
    if (object[key] === value) {
      return key
    }
  }

  /* istanbul ignore next */
  return null
}
1226852
@SuppressWarnings("unchecked")
	public static Map<String, Object> toNullableMap(Object value) {
		if (value == null)
			return null;

		Class<?> valueClass = value.getClass();
		if (valueClass.isPrimitive())
			return null;

		if (value instanceof Map<?, ?>)
			return mapToMap((Map<Object, Object>) value);

		if (valueClass.isArray())
			return arrayToMap((Object[]) value);

		if (value instanceof Collection<?>)
			return listToMap((Collection<Object>) value);

		try {
			return mapper.convertValue(value, typeRef);
		} catch (Exception ex) {
			return null;
		}
	}
531281
function(value, space) {
    /*
      ObjectIds are serialized as @@id
      DBRefs are serialized as @@collection@id or @@collection@@id, depending on whether id is an objectid
      string values starting @ @ are prepended with ::
    */
    return JSON.stringify(value, function(k,v) {
      if (v && typeof v === 'object') {
        //we have to do it like this to avoid toString being call internally
        var copy = new v.constructor();
        for (var prop in v) {
          if (!v.hasOwnProperty(prop)) continue;
          var val = v[prop]
          if (val instanceof ObjectID) {
              val = "@@" + val;
          } else if (val instanceof DBRef) {
            if (val.oid instanceof ObjectID)
              val = '@@' + val.namespace + '@@' + val.oid;
            else
              val = '@@' + val.namespace + '@' + val.oid;
          } else {
            if (typeof val == 'string' && (val.slice(0,2) == '@@')) {
             val = '::' + val;
            }
          }
          copy[prop] = val;
        }
        return copy;
      }
      return v;
    }, space);
  }
387622
function ( value ) {
            var result = false;
    
            switch ( this.type(value) ) {
                case 'Object':
                    result = true;
                    for ( var key in value ) {
                        result = false;
                        break;
                    }
                    break;
                case 'Array':
                    result = value.length === 0;
                    break;
                case 'Null':
                    result = true;
                    break;
                case 'Undefined':
                    result = true;
                    break;
                case 'String':
                    result = '' === value;
                    break;
            }
    
            return result;
        }
955419
function putItem(value) {
  return new Promise((resolve, reject) => {
    return instance.pkgs.then(db => {
      const obj = db.transaction(db.name, 'readwrite')
        .objectStore(db.name);
      const req = obj.put(value);
      req.onerror = event => reject(event);
      req.onsuccess = () => resolve();
    });
  });
}
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');
          }
      }
    }
1140705
function encoder(value) {
	var transcoderDoc;
	if (typeof value === 'string' || value instanceof String) {
		transcoderDoc = { value: new Buffer(value), flags: 0 };
	} else if (value instanceof Buffer) {
		transcoderDoc = { value: value, flags: 4 };
	} else {
		if (value.value && value.flags) {
			if (typeof value.value === 'string' || value.value instanceof String) {
				transcoderDoc = { value: new Buffer(value.value), flags: value.flags };
			} else if (value.value instanceof Buffer) {
				transcoderDoc = { value: value.value, flags: value.flags };
			} else {
				transcoderDoc = { value: new Buffer(JSON.stringify(value.value)), flags: value.flags };
			}
		} else {
			try {
				transcoderDoc = { value: new Buffer(JSON.stringify(value)), flags: 2 };
			} catch (error) {
				// TODO: NEED BETTER ERROR HANDLING HERE
				return;
			}
		}
	}

	return transcoderDoc;
}
1229355
function ValueToString(value) {
    if (value && typeof value === "object" && value.constructor === Array) {
      return JSON.stringify(value);
    }

    if (value && typeof value === "object" && value.constructor === Object) {
      return JSON.stringify(value);
    }

    /**
     * seeing some really weird cases where the above fail but "" + value
     * returns '[object Object]'
     */
    if (value && typeof value === "object") {
      return JSON.stringify(value);
    }

    if (value === null || typeof value === "undefined") {
      return "";
    }

    if (typeof value === "boolean") {
      if (value) {
        return "true";
      } else {
        return "false";
      }
    }

    if (typeof value === "number" && isFinite(value)) {
      return value.toString();
    }

    if (!!(value && value.constructor && value.call && value.apply)) {
      return value.toString();
    }

    return "" + value;
  }
979559
def readOne(stream, validate=False, transform=True, ignoreUnreadable=False,
            allowQP=False):
    
    return next(readComponents(stream, validate, transform, ignoreUnreadable,
                               allowQP))
1139904
private JsonElement toElement(final Object value) {

		if (value != null) {

			if (value instanceof String) {

				return new JsonPrimitive((String)value);

			} else if (value instanceof Number) {

				return new JsonPrimitive((Number)value);

			} else if (value instanceof Boolean) {

				return new JsonPrimitive((Boolean)value);

			} else if (value.getClass().isArray()) {

				final JsonArray arr   = new JsonArray();
				final Object[] values = (Object[])value;

				for (final Object v : values) {
					arr.add(toElement(v));
				}

				return arr;

			} else {

				return new JsonPrimitive(value.toString());
			}
		}

		return JsonNull.INSTANCE;
	}
712993
function toObject(value) {
      if (lodash.support.unindexedChars && isString(value)) {
        var index = -1,
            length = value.length,
            result = Object(value);

        while (++index < length) {
          result[index] = value.charAt(index);
        }
        return result;
      }
      return isObject(value) ? value : Object(value);
    }
645093
function( value ) {
      var result = (value === undefined || value === null || value === "" || (value.hasOwnProperty("length") && value.length == 0));

      return result;
    }
544055
function promise (input, value) {
  value.then(val => {
    morph(val, input)
  }, reason => {
    input.emit('error', reason)
  })
}
926717
protected static Object toSafeJsonValue(Object value) {
        if (value == null) {
            return null;
        } else {
            if (value instanceof Boolean || value instanceof String || value instanceof Number) {
                return value;
            }
            if (value instanceof Iterable) {
                Iterable iterable = (Iterable) value;
                List answer = new ArrayList<>();
                for (Object item : iterable) {
                    Object itemJson = toSafeJsonValue(item);
                    if (itemJson != null) {
                        answer.add(itemJson);
                    }
                }
                return answer;
            }
            if (value instanceof ProjectProvider) {
                ProjectProvider projectProvider = (ProjectProvider) value;
                return projectProvider.getType();
            }
            if (value instanceof ProjectType) {
                ProjectType projectType = (ProjectType) value;
                return projectType.getType();
            }
            if (value instanceof StackFacet) {
                StackFacet stackFacet = (StackFacet) value;
                Stack stack = stackFacet.getStack();
                if (stack != null) {
                    return stack.getName();
                } else {
                    return null;
                }
            }
            value = Proxies.unwrap(value);
            if (value instanceof ProjectProvider) {
                ProjectProvider projectProvider = (ProjectProvider) value;
                return projectProvider.getType();
            }
            if (value instanceof ProjectType) {
                ProjectType projectType = (ProjectType) value;
                return projectType.getType();
            }
            if (value instanceof StackFacet) {
                StackFacet stackFacet = (StackFacet) value;
                Stack stack = stackFacet.getStack();
                if (stack != null) {
                    return stack.getName();
                } else {
                    return null;
                }
            }
            if (isJsonObject(value)) {
                return value;
            }
            return value.toString();
        }
    }
543299
function readObjectValue(object) {
	let result = ''

	if (typeof object === 'string' || object instanceof String) {
		result = object
	} else if (typeof object === 'number' || object instanceof Number) {
		result = object.toString()
	} else if (object) {
		Object.keys(object).forEach(key => {
			result += key + ': ' + object[key] + '\t'
		})
	}

	if (!result.length) {
		result = 'Not Specified'
	}

	return result.replace(new RegExp('"', 'g'), '""')
}