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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@dsqr/aoc-utils

v0.0.1-next.2

Published

Utilities for Advent of Code puzzle solving

Readme

@dsqr/aoc-utils

Lightweight async utilities for reading Advent of Code puzzle input from files, URLs, or AoC servers.

⇁ Installation

| Package Manager | Command | |-----------------|---------| | bun | bun add @dsqr/aoc-utils | | npm | npm install @dsqr/aoc-utils | | pnpm | pnpm add @dsqr/aoc-utils |

⇁ Quick Start

import { forEach, readAocInput } from "@dsqr/aoc-utils"

await forEach(readAocInput(1), (line) => {
  console.log(line)
})

⇁ API Reference

Generators

Async generator that reads a file line-by-line.

import { readFromFile } from "@dsqr/aoc-utils"

for await (const line of readFromFile("./input.txt")) {
  console.log(line)
}

Parameters: | Parameter | Type | Default | Description | |-----------|------|---------|-------------| | path | string | - | Path to the file | | options.skipEmpty | boolean | true | Skip empty lines |

Async generator that fetches a URL and reads it line-by-line.

import { readFromUrl } from "@dsqr/aoc-utils"

for await (const line of readFromUrl("https://example.com/data.txt")) {
  console.log(line)
}

Parameters: | Parameter | Type | Default | Description | |-----------|------|---------|-------------| | url | string | - | URL to fetch | | options.skipEmpty | boolean | true | Skip empty lines |

Async generator that fetches puzzle input from Advent of Code servers.

import { readAocInput } from "@dsqr/aoc-utils"

// Requires AOC_SESSION environment variable
for await (const line of readAocInput(1, 2025)) {
  console.log(line)
}

Setup: Get your session cookie from https://adventofcode.com (DevTools → Cookies → session):

export AOC_SESSION=your_cookie_here

Parameters: | Parameter | Type | Default | Description | |-----------|------|---------|-------------| | day | number | - | Puzzle day (1-25) | | year | number | 2025 | Puzzle year | | options.skipEmpty | boolean | true | Skip empty lines |

Helpers

Process each line from a generator with a callback function.

import { forEach, readAocInput } from "@dsqr/aoc-utils"

await forEach(readAocInput(1), (line, index) => {
  console.log(`Line ${index}: ${line}`)
})

Parameters: | Parameter | Type | Description | |-----------|------|-------------| | generator | AsyncGenerator | The source generator | | callback | (line: string, index: number) => Promise | void | Function called for each line |

Collect all lines from a generator into an array.

import { toArray, readAocInput } from "@dsqr/aoc-utils"

const lines = await toArray(readAocInput(1))
console.log(lines) // string[]

Parameters: | Parameter | Type | Description | |-----------|------|-------------| | generator | AsyncGenerator | The source generator |

Returns: Promise<string[]> - Array of all lines

Get the first line from a generator (useful for single-line inputs).

import { first, readAocInput } from "@dsqr/aoc-utils"

const line = await first(readAocInput(1))
console.log(line) // string

Throws an error if the generator has no lines.

Parameters: | Parameter | Type | Description | |-----------|------|-------------| | generator | AsyncGenerator | The source generator |

Returns: Promise<string> - The first line

Throws: Error - "No lines available in generator"

⇁ CLI

Scaffold a new day:

bun packages/utils/src/cli/aoc-cli.ts scaffold 2

Parameters:

  • day (number) - Day number (1-25)

Creates the directory structure:

src/day-02/
  ├── solution-one.ts
  ├── solution-two.ts
  └── test/
      └── fixtures/

⇁ License

Do whatever you want with it. MIT.