How to use the ix/asynciterable/asynciterablex.AsyncIterableX.from function in ix

To help you get started, we’ve selected a few ix examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github neo-one-suite / neo-one / packages / neo-one-node-vm / src / stackItem / StackItemIterator.js View on Github external
values(): StackItemEnumerator<> {
    const iterable = AsyncIterableX.from(this.enumerator).pipe(
      map(({ value }) => ({ value })),
    );

    return new StackItemEnumerator(this._getIterator(iterable));
  }
}
github neo-one-suite / neo-one / packages / neo-one-node-vm / src / stackItem / StackItemIterator.js View on Github external
keys(): StackItemEnumerator<> {
    const iterable = AsyncIterableX.from(this.enumerator).pipe(
      map(({ key }) => ({ value: key })),
    );

    return new StackItemEnumerator(this._getIterator(iterable));
  }
github neo-one-suite / neo-one / packages / neo-one-node-protocol / src / consensus / Consensus.js View on Github external
async _start(options: InternalOptions): Promise {
    this._monitor.log({
      name: 'neo_consensus_start',
      message: 'Consensus started.',
      level: 'verbose',
    });
    const initialResult = await initializeNewConsensus({
      blockchain: this._node.blockchain,
      publicKey: options.publicKey,
      consensusContext: this._consensusContext,
    });

    await AsyncIterableX.from((this._queue: $FlowFixMe))
      .pipe(
        scan(async (context: Context, event: Event) => {
          let result;
          switch (event.type) {
            case 'handlePersistBlock':
              result = await handlePersistBlock({
                blockchain: this._node.blockchain,
                publicKey: options.publicKey,
                consensusContext: this._consensusContext,
              });
              break;
            case 'handleConsensusPayload':
              result = await handleConsensusPayload({
                context,
                node: this._node,
                privateKey: options.privateKey,
github neo-one-suite / neo-one / migrate / neo-one-client / src / Client.js View on Github external
      this._getAllStorage(hash).then(res => AsyncIterableX.from(res)),
    ).pipe(flatten());
github neo-one-suite / neo-one / migrate / neo-one-client / src / Client.js View on Github external
iterStorage(hash: Hash160Like): AsyncIterable {
    return AsyncIterableX.from(
      this._getAllStorage(hash).then(res => AsyncIterableX.from(res)),
    ).pipe(flatten());
  }
github neo-one-suite / neo-one / migrate / neo-one-client / src / Client.js View on Github external
iterActions(filterIn?: GetActionsFilter): AsyncIterable {
    const filter = filterIn || {};
    return AsyncIterableX.from(
      this.iterBlocks({
        indexStart: filter.blockIndexStart,
        indexStop: filter.blockIndexStop,
      }),
    ).pipe(
      flatMap(async block => {
        const actions = await this._getActions({
          blockIndexStart: block.index,
          transactionIndexStart:
            block.index === filter.blockIndexStart
              ? filter.transactionIndexStart
              : undefined,
          indexStart:
            block.index === filter.blockIndexStart
              ? filter.indexStart
              : undefined,
github neo-one-suite / neo-one / migrate / neo-one-client / src / createSmartContract.js View on Github external
smartContract.iterEvents = (
      actionFilter?: ActionFilter,
    ): AsyncIterable =>
      AsyncIterableX.from(smartContract.iterActions(actionFilter)).pipe(
        map(action => {
          if (action.type === 'Log') {
            return (null: $FlowFixMe);
          }

          if (action.args.length === 0) {
            throw new NotificationMissingEventError(action);
          }
          const event = client.parameters.toString(action.args[0]);

          return {
            name: event,
            parameters: getParametersObject({
              client,
              abiParameters: events[event].parameters,
              parameters: action.args.slice(1),