Create an object from a list of `[key, val]` pairs.
163437
function objectFromPairs(pairs) {
  var result = {};

  for (let i = 0, len = pairs.length; i < len; i++) {
    let pair = pairs[i];
    result[pair[0]] = pair[1];
  }

  return result;
}
1029756
def list2dict(list_of_options):
    """"""
    d = {}
    for key, value in list_of_options:
        d[key] = value
    return d
419915
def dumpable_obj(obj):
    ''' '''

    if isinstance(obj, list):
        _return_list = []
        for item in obj:
            if isinstance(item, list):
                _return_list.append(dumpable_obj(item))
            elif isinstance(item, set):
                _return_list.append(list(item))
            elif isinstance(item, dict):
                _return_list.append(dumpable_obj(item))
            else:
                try:
                    json.dumps(item)
                    _return_list.append(item)
                except:
                    _return_list.append(str(type(item)))
        return _return_list
    elif isinstance(obj, set):
        return list(obj)
    elif isinstance(obj, dict):
        _return_obj = {}
        for key, item in obj.items():
            if isinstance(item, list):
                _return_obj[key] = dumpable_obj(item)
            elif isinstance(item, set):
                _return_obj[key] = list(item)
            elif isinstance(item, dict):
                _return_obj[key] = dumpable_obj(item)
            else:
                try:
                    json.dumps(item)
                    _return_obj[key] = item
                except:
                    _return_obj[key] = str(type(item))
        return _return_obj
    else:
        try:
            json.dumps(obj)
            return obj
        except:
            return str(type(obj))
266021
def from_dict(cls, obj_dict: Dict[str, Any]) -> "IterationRecord":
        """"""
        obj = cls()
        for key, item in obj_dict.items():
            obj.__dict__[key] = item

        return obj
1120348
def pks_from_objects(self, objects):
        
        return {o.pk if isinstance(o, Model) else o for o in objects}
348006
def dict2kvlist(o):
    '''
    
    '''
    return chain.from_iterable((k, v) for k, v in o.items())
173077
def from_val(val_schema):
    """"""
    definition = getattr(val_schema, "definition", val_schema) if isinstance(
        val_schema, BaseSchema) else val_schema
    if isinstance(definition, dict):
        return _dict_to_teleport(definition)

    if isinstance(definition, list):
        # teleport only supports a single type by default
        if len(definition) == 1:
            return {"Array": from_val(definition[0])}

    if definition in VAL_PRIMITIVES:
        return VAL_PRIMITIVES[definition]

    raise SerializationError(
        "Serializing %r not (yet) supported." % definition)
391241
def from_dict(cls, label=None, label2=None, icon=None, thumbnail=None,
                  path=None, selected=None, info=None, properties=None,
                  context_menu=None, replace_context_menu=False,
                  is_playable=None, info_type='video', stream_info=None):
        '''
        '''
        listitem = cls(label, label2, icon, thumbnail, path)

        if selected is not None:
            listitem.select(selected)

        if info:
            listitem.set_info(info_type, info)

        if is_playable:
            listitem.set_is_playable(True)

        if properties:
            # Need to support existing tuples, but prefer to have a dict for
            # properties.
            if hasattr(properties, 'items'):
                properties = properties.items()
            for key, val in properties:
                listitem.set_property(key, val)

        if stream_info:
            for stream_type, stream_values in stream_info.items():
                listitem.add_stream_info(stream_type, stream_values)

        if context_menu:
            listitem.add_context_menu_items(context_menu, replace_context_menu)

        return listitem
1346542
def from_array(cls, arr):
        """"""
        return cls().with_columns([(f, arr[f]) for f in arr.dtype.names])
207470
def from_list(cls, database, key, data, clear=False):
        
        lst = cls(database, key)
        if clear:
            lst.clear()
        lst.extend(data)
        return lst
142321
function propertyValuePairsToObject(pairs) {
  var values = {}

  pairs.forEach(function(pair) {
    values[pair[0]] = pair[1]
  })

  return values
}
1130163
def from_raw(self, rval: RawValue, jptr: JSONPointer = "") -> Value:
        """"""
        def convert(val):
            if isinstance(val, list):
                res = ArrayValue([convert(x) for x in val])
            elif isinstance(val, dict):
                res = ObjectValue({x: convert(val[x]) for x in val})
            else:
                res = val
            return res
        return convert(rval)
1077140
def object_to_items(data_structure):
    """"""
    items = []
    # Get all items from dict
    try:
        items = list(data_structure.__dict__.items())
    except:
        pass
    # Get all slots
    hierarchy = [data_structure]
    try:
        hierarchy += inspect.getmro(data_structure)
    except:
        pass
    slots = []
    try:
        for b in hierarchy:
            try:
                slots += b.__slots__
            except:  # pragma: no cover
                pass
    except:  # pragma: no cover
        pass
    # Get attrs from slots
    for x in slots:
        items.append((x, getattr(data_structure, x)))
    return items
1328680
def _from_dict(cls, _dict):
        """"""
        args = {}
        if 'key' in _dict:
            args['key'] = Key._from_dict(_dict.get('key'))
        if 'value' in _dict:
            args['value'] = Value._from_dict(_dict.get('value'))
        return cls(**args)
1259243
function ( obj, target ) {
            var result = [];
            for ( var n in obj ) {
                result.push( target === 'key' ? n : obj[n] );
            }
    
            return result;
        }
1116129
def _fromset(cls, values, key=None):
        """"""
        sorted_set = object.__new__(cls)
        sorted_set._set = values  # pylint: disable=protected-access
        sorted_set.__init__(key=key)
        return sorted_set
845329
def _extract_key_value(obj):
    """"""
    key = None; value = None

    # Parse a Value object, which includes Properties
    if isinstance(obj, Value):
        key = _construct_new_key(obj.name, obj.units)
        value = []
        if obj.scalars:
            value = [(val.value if isinstance(val, Scalar) else val)
                     for val in obj.scalars]
        elif obj.vectors and len(obj.vectors) == 1:
            value = [(val.value if isinstance(val, Scalar) else val)
                     for val in obj.vectors[0]]
        if len(value) == 1:
            value = value[0]
        elif len(value) == 0:
            value = None

    # If there is a process step, pul out its name as the value
    # TODO: resolve duplicates
    if isinstance(obj, ProcessStep):
        key = "Processing"
        value = obj.name
        
    return key, value