<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def construct_format(f, type_map=CONSTRUCT_CODE):
 """ Formats for binary-parser library. """

  formatted = ""
  if type_map.get(f.type_id, None):
    return "%s('%s')" % (type_map.get(f.type_id), f.identifier)
  elif f.type_id == 'string' and f.options.get('size', None):
    return "string('%s', { length: %d })" % (f.identifier, f.options['size'].value)
  elif f.type_id == 'string':
    return "string('%s', { greedy: true })" % (f.identifier)
  elif f.type_id == 'array':
    fill = f.options['fill'].value
    f_ = copy.copy(f)
    f_.type_id = fill
    size = f.options.get('size', None)
    size_fn = f.options.get('size_fn', None)
    field_type = type_map.get(f_.type_id, None)
    if field_type is None:
      field_type = "%s.prototype.parser" % f_.type_id
    else:
      field_type = "'%s'" % field_type
    if size is not None:
      d = { "'uint16'" : "'uint16le'", "'uint32'" : "'uint32le'", "'uint64'" : "'uint16le'",
            "'int16'" : "'int16le'", "'int32'" : "'int32le'", "'int64'" : "'int16le'" }
      field_type_arr = d.get(field_type, field_type)
      return "array('%s', { length: %d, type: %s })" % (f.identifier, size.value, field_type_arr)
    elif f.options.get('size_fn') is not None:
      return "array('%s', { type: %s, length: '%s' })" % (f_.identifier, field_type, size_fn.value)
    else:
      return "array('%s', { type: %s, readUntil: 'eof' })" % (f_.identifier, field_type)
  else:
    return "nest('%s', { type: %s.prototype.parser })" % (f.identifier, f.type_id)
  return formatted