expects a list of key, value to work with
357186
def set_items(self, items):
        """"""
        res = []
        max_value = max(sum((rec[1] for rec in items)), 1)
        for key, val in items:
            res.append((key, val, val * 1.0 / max_value))
        self._items = res
588975
function ensureArray(object, key) {
  if (!object[key]) {
    object[key] = [];
  }
  if (!Array.isArray(object[key])) {
    throw new Error("Can't perform array operation on non-array field");
  }
}
815447
def get_item_by_key(passed_list, key, value):
    '''
    
    '''

    if value in [None, '']:
        return

    if type(passed_list) in [QuerySet, PolymorphicQuerySet]:
        sub_list = passed_list.filter(**{key: value})
    else:
        sub_list = [x for x in passed_list if x.get(key) == value]

    if len(sub_list) == 1:
        return sub_list[0]
    return sub_list
397313
def hmget(self, name, keys, *args):
        
        member_encode = self.memberparse.encode
        keys = [k for k in self._parse_values(keys, args)]
        with self.pipe as pipe:
            f = Future()
            res = pipe.hmget(self.redis_key(name),
                             [member_encode(k) for k in keys])

            def cb():
                f.set([self._value_decode(keys[i], v)
                       for i, v in enumerate(res.result)])

            pipe.on_execute(cb)
            return f
618371
def keytechKeyValueObject
      arrayOfKeyValuePairs = []
      keyValueList.each do |key, value|
        arrayOfKeyValuePairs.push ({ Key: key, Value: value })
      end
      arrayOfKeyValuePairs
    end
923989
def []=(key, new_value)
      key.kind_of?(Symbol) ? self[key.to_s]=new_value : super(key, new_value)
    end
218444
function addKeyToList(list, key, object) {
    for (var i = list.length - 1; i >= 0; i--) {
        if (list[i][key] == object[key]) {
            return false;
        }
    }
    list.push(object);
    return true;
}
683065
def iterallvalues(self, key=_absent):
        '''
        
        '''
        if key is not _absent:
            if key in self:
                return iter(self.getlist(key))
            raise KeyError(key)
        return self._items.itervalues()
836425
def append_to_list(self, key, *value, pipeline=False):
        
        if pipeline:
            self._pipeline.rpush(key, *value)
        else:
            self._db.rpush(key, *value)
1162662
def lists(self, column, key=None):
        
        results = self._query.lists(column, key)

        if self._model.has_get_mutator(column):
            if isinstance(results, dict):
                for key, value in results.items():
                    fill = {column: value}

                    results[key] = self._model.new_from_builder(fill).column
            else:
                for i, value in enumerate(results):
                    fill = {column: value}

                    results[i] = self._model.new_from_builder(fill).column

        return results
42419
def items(self):
        ""
        return list(zip(list(self.keys()), list(self.values())))
242083
function listCacheGet(key) {
      var data = this.__data__,
          index = assocIndexOf(data, key);

      return index < 0 ? undefined$1 : data[index][1];
    }
1007108
def set(cls, obj, keys, value, fill_list_value=None):
        
        current = obj
        keys_list = keys.split(".")

        for idx, key in enumerate(keys_list, 1):
            if type(current) == list:
                # Validate this key works with a list.
                try:
                    key = int(key)
                except ValueError:
                    raise cls.Missing(key)

            try:
                # This is the last key, so set the value.
                if idx == len(keys_list):
                    if type(current) == list:
                        safe_list_set(
                            current,
                            key,
                            lambda: copy.copy(fill_list_value),
                            value
                        )
                    else:
                        current[key] = value

                    # done.
                    return

                # More keys left, ensure we have a container for this key.
                if type(key) == int:
                    try:
                        current[key]
                    except IndexError:
                        # Create a list for this key.
                        cnext = container_for_key(keys_list[idx])
                        if type(cnext) == list:
                            def fill_with():
                                return []
                        else:
                            def fill_with():
                                return {}

                        safe_list_set(
                            current,
                            key,
                            fill_with,
                            [] if type(cnext) == list else {}
                        )
                else:
                    if key not in current:
                        # Create a list for this key.
                        current[key] = container_for_key(keys_list[idx])

                # Move on to the next key.
                current = current[key]
            except (IndexError, KeyError, TypeError):
                raise cls.Missing(key)
892990
def get_keys(self, models, key=None):
        
        return list(set(map(lambda value: value.get_attribute(key) if key else value.get_key(), models)))
431278
def getall(self, key, type=None):
        
        values = []
        for k, v in self._items:
            if k == key:
                if type is not None:
                    try:
                        values.append(type(v))
                    except ValueError:
                        pass
                else:
                    values.append(v)
        return values
1332354
def values(self, key=_absent):
        
        if key is not _absent and key in self._map:
            return self.getlist(key)
        return list(self.itervalues())
279713
function hkeys(key, req) {
  var val = this.getKey(key, req);
  if(!val) return [];
  return val.getKeys();
}