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

@rghm/s3-replica

v0.1.3

Published

A utility to replicate objects from a source S3 bucket to a destination bucket using AWS SDK v3. It supports:

Readme

S3 Replica Module

A utility to replicate objects from a source S3 bucket to a destination bucket using AWS SDK v3. It supports:

  • Checkpoint
  • Starting replication from a specific key
  • Stopping after a certain key
  • Optional logging

Note: This package is intended for small-scale replication between S3 buckets. It is not optimized for large-scale transfers. For replicating a large number of objects efficiently, consider using tools like s5cmd.


Logic Overview

  1. Initialization

    • Creates S3 clients for both source and destination using the provided configurations.
    • Tracks the last synced item (lastSyncedItem) and the checkpoint counter.
  2. Checkpoint

    • Maintains an anchor file (__REPLICA_ANCHOR__) in the destination bucket to store the last successfully replicated key.

    • Updates the checkpoint after processing a configurable number of objects (checkpointInterval).

    • If ensureCheckpointExists is true (default), the module verifies that the checkpoint file exists in the source bucket.

      • Fails fast if the checkpoint is missing to prevent accidentally starting replication from the wrong point, especially when dealing with large files.
  3. Replication Process

    • Fetches objects from the source bucket page by page using paginateListObjectsV2.

    • Processes each page sequentially:

      • Downloads each object from the source bucket.
      • Uploads it to the destination bucket.
      • Updates the checkpoint.
    • Starts copying from the key specified in startAfter.

      • If the starting file does not exist, the behavior depends on ensureCheckpointExists: it either starts from the first available object or fails immediately.
    • Stops replication if a stopAfter key is reached.

    • Logs progress using the provided logger or console.log.

  4. Fault Handling

    • Stops immediately on errors (no retries).
    • Ensures checkpoint consistency across restarts by comparing with the anchor key in the destination bucket.

Configuration Options (ReplicaOptions)

| Option | Type | Default | Description | | ------------------------ | --------------------------- | ------------- | --------------------------------------------------------------------------- | | sourceConfig | S3ClientConfig | — | AWS SDK configuration for the source bucket. | | destConfig | S3ClientConfig | — | AWS SDK configuration for the destination bucket. | | sourceBucket | string | — | Name of the source bucket to replicate from. | | destBucket | string | — | Name of the destination bucket to replicate to. | | startAfter | string | "" | Key to start replication after (exclusive). | | stopAfter | string? | — | Optional key at which replication should stop (inclusive). | | logger | (...args: any[]) => void? | console.log | Optional custom logger function. | | ensureCheckpointExists | boolean? | true | Fail immediately if the checkpoint key does not exist in the source bucket. | | checkpointInterval | number? | 50 | Number of objects processed before saving the checkpoint. Max: 1000. |