How to use asyncjs-util - 8 common examples

To help you get started, we’ve selected a few asyncjs-util 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 alexbosworth / balanceofsatoshis / lnd / authenticated_lnd.js View on Github external
return new Promise((resolve, reject) => {
    return asyncAuto({
      // Credentials
      credentials: cbk => lndCredentials({logger, node}, cbk),

      // Lnd
      lnd: ['credentials', ({credentials}, cbk) => {
        return cbk(null, authenticatedLndGrpc({
          cert: credentials.cert,
          macaroon: credentials.macaroon,
          socket: credentials.socket,
        }));
      }],
    },
    returnResult({reject, resolve, of: 'lnd'}, cbk));
  });
};
github submarineswaps / swaps-service / pool / get_detected_swaps.js View on Github external
},
      cbk);
    }],

    // Final swaps result 
    swaps: [
      'attempt',
      'claim',
      'funding',
      'refund',
      ({attempt, claim, funding, refund}, cbk) =>
    {
      return cbk(null, {attempt, claim, funding, refund});
    }],
  },
  returnResult({of: 'swaps'}, cbk));
};
github submarineswaps / swaps-service / scan / detect_swaps.js View on Github external
}

      return setJsonInCache({
        key,
        type,
        cache: 'memory',
        ms: cacheSwapsMs,
        value: swaps,
      },
      cbk);
    }],

    // Final swaps result
    detectedSwaps: ['swaps', ({swaps}, cbk) => cbk(null, {swaps})],
  },
  returnResult({of: 'detectedSwaps'}, cbk));
};
github submarineswaps / swaps-service / blocks / get_block_placement.js View on Github external
},
      cbk);
    }],

    // Final block placement info
    blockPlacement: ['getCached', 'getFresh', ({getCached, getFresh}, cbk) => {
      const block = getFresh || getCached;

      return cbk(null, {
        created_at: block.created_at,
        current_confirmation_count: block.current_confirmation_count,
        previous_block: block.previous_block,
      });
    }],
  },
  returnResult({of: 'blockPlacement'}, cbk));
};
github alexbosworth / balanceofsatoshis / swaps / get_swap_service.js View on Github external
// Get network
      getNetwork: ['lnd', ({lnd}, cbk) => getNetwork({lnd}, cbk)],

      // Swap service
      service: ['getNetwork', ({getNetwork}, cbk) => {
        const {network} = getNetwork;

        try {
          return cbk(null, lightningLabsSwapService({network}));
        } catch (err) {
          return cbk([400, 'FailedToFindSupportedSwapService', {err}]);
        }
      }],
    },
    returnResult({reject, resolve, of: 'service'}));
  });
};
github alexbosworth / balanceofsatoshis / telegram / pay_command.js View on Github external
break;
        }

        // Report unanticipated errors
        if (!text) {
          return returnResult({reject, resolve, of: 'getPayment'}, cbk)(err);
        }

        sendMessage({id, key, request, text}, err => {});

        return returnResult({reject, resolve, of: 'getPayment'}, cbk)(null, {
          getPayment: {tokens: 0},
        });
      }

      return returnResult({reject, resolve, of: 'getPayment'}, cbk)(err, res);
    });
  });
github submarineswaps / swaps-service / chain / get_utxo.js View on Github external
utxo: ['getBlock', 'getUtxo', ({getBlock, getUtxo}, cbk) => {
        if (!getUtxo.utxo) {
          return cbk(null, {});
        }

        const utxo = {
          block: getBlock || undefined,
          conf_count: getUtxo.utxo.conf_count || undefined,
          output_script: getUtxo.utxo.output_script,
          tokens: getUtxo.utxo.tokens,
        };

        return cbk(null, {utxo});
      }],
    },
    returnResult({reject, resolve, of: 'utxo'}, cbk));
  });
};
github alexbosworth / balanceofsatoshis / nodes / decrypt_saved_macaroons.js View on Github external
}

        return asyncMap(decrypt, ({credentials, macaroon, node}, cbk) => {
          return putSavedCredentials({
            fs,
            macaroon,
            node,
            cert: credentials.cert,
            socket: credentials.socket,
          },
          cbk);
        },
        cbk);
      }],
    },
    returnResult({reject, resolve}));
  });
};

asyncjs-util

Asyncjs Utilities

MIT
Latest version published 1 year ago

Package Health Score

45 / 100
Full package analysis

Popular asyncjs-util functions