npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@cfxdevkit/executor

v2.0.10

Published

Generic background job runner with queues and scheduler.

Readme

@cfxdevkit/executor

Scope: Generic execution primitives for keeper / off-chain automation systems.

Responsibilities

  • Job queue interface (pluggable backends via createTaskQueue)
  • Retry with exponential backoff policies (via RetryPolicy and ExecuteOptions)
  • Gas-aware transaction submission (via gasPrice, maxFeePerGas, maxPriorityFeePerGas in ExecutionContext)
  • Idempotency support (via idempotencyKey in ExecuteOptions)
  • Distributed locking (via withLock)
  • Periodic polling (via createPoller)

Domain-specific automation strategies (DCA, limit orders, etc.) live in @cfxdevkit/automation and consume this package.

Installation

npm install @cfxdevkit/executor

Sub-paths

| Sub-path | Exports | |----------|---------| | . | 16 symbols |


.

Types

export interface ExecutionContext {
  chainId: number;
  blockNumber: number;
  timestamp: number;
  gasPrice?: bigint;
  maxFeePerGas?: bigint;
  maxPriorityFeePerGas?: bigint;
}

export interface RetryPolicy {
  maxRetries: number;
  baseDelayMs: number;
}

export interface ExecuteOptions extends RetryPolicy {
  idempotencyKey?: string;
  context?: Partial<ExecutionContext>;
  timeoutMs?: number;
  labels?: Record<string, string>;
}

export interface BatchOptions extends ExecuteOptions {
  concurrency?: number;
}

export interface TaskQueueOptions extends BatchOptions {
  name?: string;
  persistent?: boolean;
  priorityFn?: (a: ExecutionTask<any>, b: ExecutionTask<any>) => number;
}

export interface PollerContext {
  lastExecutionTime: number;
  consecutiveFailures: number;
}

export type ExecutionTask<T> = (context: ExecutionContext) => Promise<T> | T;

export type ExecutionResult<T> = {
  success: boolean;
  value?: T;
  error?: Error;
  attempts: number;
};

export type PollerTask = (context: PollerContext) => Promise<void> | void;

export interface Poller {
  start(): void;
  stop(): void;
  isRunning: boolean;
}

Functions

export declare function execute<T>(
  task: ExecutionTask<T>,
  options?: ExecuteOptions
): Promise<ExecutionResult<T>>;

export declare function executeBatch<T>(
  tasks: ReadonlyArray<ExecutionTask<T>>,
  options?: BatchOptions
): Promise<Array<ExecutionResult<T>>>;

export declare function createTaskQueue(
  options?: TaskQueueOptions
): {
  enqueue<T>(task: ExecutionTask<T>, options?: ExecuteOptions): Promise<ExecutionResult<T>>;
  start(): void;
  stop(): void;
  isRunning: boolean;
};

export declare function createPoller(
  task: PollerTask,
  intervalMs: number
): Poller;

export declare function withLock<T>(
  key: string,
  task: () => Promise<T> | T
): Promise<T>;

export declare const __packageName: "@cfxdevkit/executor";

Usage

Single execution with retry and idempotency

import { execute } from '@cfxdevkit/executor';

const result = await execute(
  async (ctx) => {
    // Perform on-chain operation using ctx.gasPrice, etc.
    return 'success';
  },
  {
    maxRetries: 3,
    baseDelayMs: 500,
    idempotencyKey: 'tx-0x123',
    context: { chainId: 1, blockNumber: 18000000 }
  }
);

Batch execution

import { executeBatch } from '@cfxdevkit/executor';

const results = await executeBatch(
  [
    async (ctx) => task1(ctx),
    async (ctx) => task2(ctx),
  ],
  { maxRetries: 2, context: { chainId: 1 } }
);

Task queue with concurrency control

import { createTaskQueue } from '@cfxdevkit/executor';

const queue = createTaskQueue({
  concurrency: 5,
  maxRetries: 3,
  baseDelayMs: 250,
  name: 'automation-queue'
});

queue.start();

await queue.enqueue(async (ctx) => {
  // Enqueued task
});

// Later...
queue.stop();

Poller for periodic checks

import { createPoller } from '@cfxdevkit/executor';

const poller = createPoller(
  async (ctx) => {
    // Check condition every 10s; ctx.lastExecutionTime and ctx.consecutiveFailures available
  },
  10_000
);

poller.start();
// poller.stop();

Distributed locking

import { withLock } from '@cfxdevkit/executor';

const result = await withLock('dca:account-0x...', async () => {
  // Critical section — only one instance runs at a time
});

API Reference

See API.md for the full public surface.

Tier

Tier 0 — framework — Must not runtime-import from any higher tier.