A version of `connectionFromArray` that takes a promised array, and returns a
    promised connection.
768301
def connection_from_promised_list(data_promise, args=None, **kwargs):
    '''
    
    '''
    return data_promise.then(lambda data: connection_from_list(data, args, **kwargs))
146173
function chunkArray(myArray, chunk_size){
    var results = [];

    while (myArray.length) {
      results.push(myArray.splice(0, chunk_size));
    }

    return results;
  }
1188969
def network_from_array(self, array):
        
        if len(array.shape) == 2:
            array = np.array(array, ndmin=3).transpose([1, 2, 0])
        teneto.utils.check_TemporalNetwork_input(array, 'array')
        uvals = np.unique(array)
        if len(uvals) == 2 and 1 in uvals and 0 in uvals:
            i, j, t = np.where(array == 1)
            self.network = pd.DataFrame(data={'i': i, 'j': j, 't': t})
        else:
            i, j, t = np.where(array != 0)
            w = array[array != 0]
            self.network = pd.DataFrame(
                data={'i': i, 'j': j, 't': t, 'weight': w})
        self.N = int(array.shape[0])
        self.T = int(array.shape[-1])
        self._update_network()
498312
def from_array(array):
        
        if array is None or not array:
            return None
        # end if
        assert_type_or_raise(array, dict, parameter_name="array")

        data = {}
        data['url'] = u(array.get('url'))
        data['has_custom_certificate'] = bool(array.get('has_custom_certificate'))
        data['pending_update_count'] = int(array.get('pending_update_count'))
        data['last_error_date'] = int(array.get('last_error_date')) if array.get('last_error_date') is not None else None
        data['last_error_message'] = u(array.get('last_error_message')) if array.get('last_error_message') is not None else None
        data['max_connections'] = int(array.get('max_connections')) if array.get('max_connections') is not None else None
        data['allowed_updates'] = WebhookInfo._builtin_from_array_list(required_type=unicode_type, value=array.get('allowed_updates'), list_level=1) if array.get('allowed_updates') is not None else None
        data['_raw'] = array
        return WebhookInfo(**data)
632007
function (arr, handler) {
        var tmp = when.defer();
        var index = -1;
        var results = [];

        var doNext = function () {
            try {
                index++;

                if (index > arr.length) {
                    tmp.resolve(results);
                }

                var file = arr[index];
                var promise = handler(file);
                if (promise) {
                    when(promise).then(function (result) {
                        results.push(result);
                        process.nextTick(doNext);
                    }, function () {
                        process.nextTick(doNext);
                    });
//                    when(promise).ensure(function () {
//                        process.nextTick(doNext);
//                    });
                }
                else {
                    //logger.log('skipping bad promise');
                    process.nextTick(doNext);
                }
            }
            catch (ex) {
                logger.error("pdas error: " + ex);
            }
        };

        process.nextTick(doNext);

        return tmp.promise;
    }
462113
function arraySafeConcat(arr, arg) {
  var result = arrayClone(arr), len = result.length, arr2;
  arr2 = isArray(arg) ? arg : [arg];
  result.length += arr2.length;
  forEach(arr2, function(el, i) {
    result[len + i] = el;
  });
  return result;
}
624770
function() {
    var me = this;
    var connectionOptions = me._connectionOptions;

    return promised(function(cb) {
      if (me.isConnected || me.status === 'connecting') {
        return cb(new Error('Broker client already connected or connecting.'));
      }

      if (!me.mqttClient) {
        var mqttClient = new PahoMQTT.Client(
          connectionOptions.host,
          connectionOptions.port,
          connectionOptions.path,
          connectionOptions.clientId
        );

        _registerPahoClientEventListeners(me, mqttClient);
        me.mqttClient = mqttClient;
      }

      me.status = 'connecting';
      me.emit('connecting');

      me.mqttClient.connect(
        merge(_getPahoCallbacks(cb), {
          cleanSession: connectionOptions.clean,
          keepAliveInterval: connectionOptions.keepAliveInterval,
          reconnect: connectionOptions.reconnect,
          useSSL: connectionOptions.useSSL
        })
      );
    }).then(function(connectResponse) {
      if (me.enableSubscriptionSyncEvents) {
        me.initSubscriptionSyncEvents();
      }

      return connectResponse;
    });
  }
313679
public function connectionFromPromisedArray($dataPromise, $args = [])
    {
        $this->checkPromise($dataPromise);

        return $dataPromise->then(function ($data) use ($args) {
            return $this->connectionFromArray($data, $args);
        });
    }
702803
function (connection, attempt) {
  var clonedAttempt = EJSON.clone(attempt);
  clonedAttempt.connection = connection;
  return clonedAttempt;
}
59427
function () {
            this.__ending = true;
            var conn, fQueue = this.__freeObjects, count = this.count, ps = [];
            while ((conn = this.__freeObjects.dequeue()) !== undefined) {
                ps.push(this.closeConnection(conn));
            }
            var inUse = this.__inUseObjects;
            for (var i = inUse.length - 1; i >= 0; i--) {
                ps.push(this.closeConnection(inUse[i]));
            }
            this.__inUseObjects.length = 0;
            return new PromiseList(ps).promise();
        }
733288
def connection_from_list(data, args=None, **kwargs):
    '''
    
    '''
    _len = len(data)
    return connection_from_list_slice(
        data,
        args,
        slice_start=0,
        list_length=_len,
        list_slice_length=_len,
        **kwargs
    )
46744
@SuppressWarnings("unchecked")
	@Contract(pure = true)
	@NotNull
	public static <T> Promise<T[]> toArray(@NotNull Class<T> type, @NotNull Promise<? extends T> promise1) {
		return promise1.map(value -> {
			@NotNull T[] array = (T[]) Array.newInstance(type, 1);
			array[0] = value;
			return array;
		});
	}
998960
@SuppressWarnings("unchecked")
  public T[] pollToArray(T[] array) {
    int currentIndex = 0;
    LinkedElement<T> current = null;

    if (array.length == 0) {
      return array;
    }
    if (array.length > size) {
      array = (T[]) java.lang.reflect.Array.newInstance(array.getClass()
          .getComponentType(), size);
    }
    // do fast polling if the entire set needs to be fetched
    if (array.length == size) {
      for (int i = 0; i < entries.length; i++) {
        current = entries[i];
        while (current != null) {
          array[currentIndex++] = current.element;
          current = current.next;
        }
      }
      this.clear();
      return array;
    }

    boolean done = false;
    int currentBucketIndex = 0;

    while (!done) {
      current = entries[currentBucketIndex];
      while (current != null) {
        array[currentIndex++] = current.element;
        current = current.next;
        entries[currentBucketIndex] = current;
        size--;
        modification++;
        if (currentIndex == array.length) {
          done = true;
          break;
        }
      }
      currentBucketIndex++;
    }
    shrinkIfNecessary();
    return array;
  }
124928
def from_array(array):
        
        if array is None or not array:
            return None
        # end if
        assert_type_or_raise(array, dict, parameter_name="array")
        from pytgbot.api_types.receivable.passport import EncryptedCredentials
        from pytgbot.api_types.receivable.passport import EncryptedPassportElement
        

        data = {}
        data['data'] = EncryptedPassportElement.from_array_list(array.get('data'), list_level=1)
        data['credentials'] = EncryptedCredentials.from_array(array.get('credentials'))
        data['_raw'] = array
        return PassportData(**data)
1141219
def from_array(array):
        
        if array is None or not array:
            return None
        # end if
        assert_type_or_raise(array, dict, parameter_name="array")

        from ..receivable.media import Location
        from ..receivable.peer import User

        data = {}
        data['result_id'] = u(array.get('result_id'))
        data['from_peer'] = User.from_array(array.get('from'))
        data['query'] = u(array.get('query'))
        data['location'] = Location.from_array(array.get('location')) if array.get('location') is not None else None
        data['inline_message_id'] = u(array.get('inline_message_id')) if array.get('inline_message_id') is not None else None
        data['_raw'] = array
        return ChosenInlineResult(**data)
715515
def get_array(array, **kw):
    
    for name, value in kw.items():
        array = array[array[name] == value]
    return array
304581
def from_array(array):
        
        if array is None or not array:
            return None
        # end if
        assert_type_or_raise(array, dict, parameter_name="array")

        data = {}
        data['migrate_to_chat_id'] = int(array.get('migrate_to_chat_id')) if array.get('migrate_to_chat_id') is not None else None
        data['retry_after'] = int(array.get('retry_after')) if array.get('retry_after') is not None else None
        data['_raw'] = array
        return ResponseParameters(**data)