Remove undefined and null values
428513
function(content, undefinedOnly) {
    var k, v;
    for (k in content) {
      v = content[k];
      if (v && typeof v === 'object') {
        content[k] = module.exports.clean(v, undefinedOnly);
        continue;
      }
      if (typeof v === 'undefined') {
        delete content[k];
      }
      if (!undefinedOnly && v === null) {
        delete content[k];
      }
    }
    return content;
  }
562583
function cleanItem3(value, parent) {

        var newvalue = null;

        if (Array.isArray(value)) {
            newvalue = [];

            var isAllNumbers = (value.length > 0);
            var isAllStrings = (value.length > 0)
            value.forEach(function (item) {
                if (typeof item !== 'number')
                    isAllNumbers = false;

                if (typeof item !== 'string')
                    isAllStrings = false;
            })

            if (isAllNumbers)
                return [cleanItem3(value[0], parent)];

            if (isAllStrings) {
                var enumKey = "Enum" + getTypeFromKey(parent);
                var hash = value.join("!");
                if (hash in enumFromHash)
                    enumKey = enumFromHash[hash]
                else {
                    var found = true;
                    value.forEach(function (key) {
                        if (!(key in enumFromKey)) found = false;
                    })

                    if (found) {
                        enumKey = enumFromKey[value[0]];
                    } else {
                        enums[enumKey] = value;
                        enumFromHash[hash] = enumKey;

                        value.forEach(function (key) {
                            enumFromKey[key] = "Enum" + getTypeFromKey(parent);
                        })
                    }
                }
                return [enumKey];
            }

            value.forEach(function (item) {
                newvalue.push(cleanItem3(item, parent));
            })

            return newvalue;
        }

        if ((typeof value !== "object") || (value == null)) {
            switch (typeof value) {
                case 'string':
                    if (isId(value)) return 'ID';
                    if (isUser(value)) return 'UserId';
                    if (isUserOrgPrefix(value)) return 'UserOrOrgIdPrefixed';
                    if (ids[value] == "orgs") return 'OrgId';
                    if (ids[value] == "roles") return 'EnumConfigRole';
                    if (value in enumDefaultKeys.values) return enumDefaultKeys.values[value];
                    if (ids[value]) return ids[value] + "Id";
                    return 'String';
                case 'number':
                    if (value > 1300000000 && value < 1700000000)
                        return value % 1 == 0 ? 'Date' : 'Time'
                    return value % 1 == 0 ? 'Int' : 'Float'
                case 'boolean':
                    return 'Boolean';
                default:
                    return value == null ? 'NULL' : value;
            }
        }

        var newvalue = {};

        Object.keys(value).forEach(function (key) {
            newvalue[key] = cleanItem3(value[key], parent + key.substr(0, 1).toUpperCase() + key.substr(1));
        });

        return newvalue;
    }
533903
function removeAll(object, keys) {
  forValueInArray(keys, unset)

  function unset(key) {
    object[key] = undefined
  }
}
1357303
function stringifyValue(value, replacer, space, indent) {
  // boolean, null, number, string, or date
  if (typeof value === 'boolean' || value instanceof Boolean ||
      value === null ||
      typeof value === 'number' || value instanceof Number ||
      typeof value === 'string' || value instanceof String ||
      value instanceof Date) {
    return JSON.stringify(value);
  }

  // lossless number, the secret ingredient :)
  if (value && value.isLosslessNumber) {
    return value.value;
  }

  // array
  if (Array.isArray(value)) {
    return stringifyArray(value, replacer, space, indent);
  }

  // object (test lastly!)
  if (value && typeof value === 'object') {
    return stringifyObject(value, replacer, space, indent);
  }

  return undefined;
}
263102
public function nulls() {
		$prefix = '';
		$tables = $this->_getTables($prefix);

		$todo = [];

		$db = $this->_getConnection();

		$this->out('Checking for tables that need updating:', 1, static::VERBOSE);
		foreach ($tables as $table) {
			// Structure
			$sql = 'DESCRIBE ' . $table['table_name'] . ';';
			$this->out('- ' . $sql, 1, static::VERBOSE);
			/** @var \Traversable $res */
			$res = $db->query($sql);
			$fields = (new Collection($res))->toArray();

			$fieldList = [];
			foreach ($fields as $field) {
				$name = $field['Field'];
				if ($name === 'id' || substr($name, -3) === '_id') {
					continue;
				}

				$type = $field['Type'];
				$null = $field['Null'];

				if (preg_match('/^tinyint\([\d]\)/', $type)) {
					if ($null === 'YES' || $field['Default'] !== null) {
						continue;
					}

					$todo[] = 'ALTER TABLE' . ' ' . $table['table_name'] . ' CHANGE `' . $name . '` `' . $name . '` ' . $type . ' NOT NULL DEFAULT \'0\';';

					continue;
				}

				if (!in_array($type, ['longtext', 'mediumtext', 'text']) && !preg_match('/^(varchar|char)\(/', $type)) {
					continue;
				}
				if ($type === 'varchar(36)' || $type === 'char(36)') {
					continue;
				}

				$fieldList[] = $field['Field'];

				if ($null === 'YES' || $field['Default'] !== null) {
					continue;
				}

				// We need to migrate sth
				if (!in_array($type, ['longtext', 'mediumtext', 'text'])) {
					$todo[] = 'ALTER TABLE' . ' ' . $table['table_name'] . ' CHANGE `' . $name . '` `' . $name . '` ' . $type . ' NOT NULL DEFAULT \'\';';
				} else {
					$todo[] = 'ALTER TABLE' . ' ' . $table['table_name'] . ' CHANGE `' . $name . '` `' . $name . '` ' . $type . ' DEFAULT NULL;';
				}
			}
		}

		if (!$todo) {
			$this->out('Nothing to do :)');
			return;
		}

		$this->out(count($todo) . ' tables/fields need updating.');
		if (!$this->param('dry-run')) {
			$continue = $this->in('Continue?', ['y', 'n'], 'y');
			if ($continue !== 'y') {
				$this->abort('Aborted!');
			}
		}
		$sql = implode(PHP_EOL, $todo);
		if (!$this->param('dry-run')) {
			$this->out($sql);
			return;
		}

		$db->query($sql);
		$this->out('Done :)');
	}
485133
function resolveValues ( values ) {

	if ( Array.isArray(values) ) {
		return values;
	}

	return values.split(' ')
		.map(( value ) => {
			return value.trim();
		})
		.filter(( value ) => {
			return value !== '';
		});

}
457919
def strip_empty_values(obj):
    """"""
    if isinstance(obj, dict):
        new_obj = {}
        for key, val in obj.items():
            new_val = strip_empty_values(val)
            if new_val is not None:
                new_obj[key] = new_val
        return new_obj or None
    elif isinstance(obj, (list, tuple, set)):
        new_obj = []
        for val in obj:
            new_val = strip_empty_values(val)
            if new_val is not None:
                new_obj.append(new_val)
        return type(obj)(new_obj) or None
    elif obj or obj is False or obj == 0:
        return obj
    else:
        return None
36488
protected function filterEmpty()
    {
        $vars = $this->toArray();
        foreach ($vars as $name => $value) {
            if (!strlen($value)) {
                unset($this->{$name});
            }
        }
    }
973865
function(value, defaultValue) {
      var result = value === undefined || value === null ? defaultValue : value;

      return result;
    }
70174
function undefinedOrNullToEmptyArray(valueToConvert) {
    if (_.isUndefined(valueToConvert) || _.isNull(valueToConvert)) {
      valueToConvert = [];
    }
    return valueToConvert;
  }
1365261
function omit(array, exp) {

  if(!isArray(array) || isUndefined(exp)) {
    return array;
  }

  return array.filter(function(elm) {
    return (isObject(elm) || isFunction(exp))
      ? !$parse(exp)(elm)
      : elm !== exp;
  });
}
1007318
function clean(obj) {
  var ret = {};

  // Remove traits/properties that are already represented
  // outside of the data container
  // TODO: Refactor into `omit` call
  var excludeKeys = ['id', 'name', 'firstName', 'lastName'];
  each(excludeKeys, function(omitKey) {
    clear(obj, omitKey);
  });

  // Flatten nested hierarchy, preserving arrays
  obj = flatten(obj);

  // Discard nulls, represent arrays as comma-separated strings
  // FIXME: This also discards `undefined`s. Is that OK?
  for (var key in obj) {
    if (has.call(obj, key)) {
      var val = obj[key];
      if (val == null) {
        continue;
      }

      if (is.array(val)) {
        ret[key] = val.toString();
        continue;
      }

      ret[key] = val;
    }
  }

  return ret;
}
886498
def nullify(function):
    ""
    def wrapper(*args, **kwargs):
        value = function(*args, **kwargs)
        if(type(value) == list and len(value) == 0):
            return None
        return value
    return wrapper
294380
function findValue (arr, value) {
	value = purifyValue(value);

	for (var i = arr.length - 1; i >= 0; i--) {
		if (arr[i].val === value) {
			return arr[i].pos;
		};

		if (i === 0) {
			return -1;
		};
	};
}
256145
function remove(/* values... */) {
  var values = this.values
  var index = arguments.length
  var position

  while (index--) {
    position = values.indexOf(arguments[index])

    if (position !== -1) {
      values.splice(position, 1)
    }
  }

  return this
}
21503
function(value) {

		var reason = null;

		if (typeof(value) == 'undefined') {

			reason = "Undefined is not a valid value";

		} else if (value == null && !this._is_nullable) {

			reason = "Cannot assign null to non-nullable field";

		}

		return reason;

	}
667877
def p_ConstValue_null(p):
  """"""
  p[0] = model.Value(type=model.Value.NULL, value=p[1])