Framework for working with Advent of Code in typescript

Usage no npm install needed!

<script type="module">
  import aocf from '';


Advent of Code Framework (aocf)

Framework for working with Advent of Code in typescript


Can be used to structure puzzles as classes

import {AoC} from 'aocf'

export class AoC2020Day1 extends AoC {
    partA(input: string):number {
        return 95;

    partB(input: string): number {
        return 105;

// Download data using a $AOC_SESSION and run against your input
// 2020-12-01: 0.934ms - Duration that the solution run in
// 2020-12-01.Question#1 95 // Answer to Q1
// 2020-12-01.Question#2 105 // Answer to Q2

Or used as a script format

import {AoC} from 'aocf'

const aoc = AoC.create(2020, 1)
const input = await aoc.input

Or as a combination

import {AoC} from 'aocf'

const aoc = AoC.create(2020, 1);

aoc.partA = (d) => {
  let total = 0;
  for (const line of d.split('\n')) total++;
  return total;


All answers and input can be export into a JSON file for sharing

import '@blacha/advent-of-code-2020';
const data = await AoC.export(2020);
writeFileSync(`./aoc-${data.user}-${data.year}.json`, JSON.stringify(data, null, 2));


export interface AoCJsonData {
    /** Github username for where the puzzle data came from */
    user: string;
    /** Advent of code year */ 
    year: number;

    puzzles: {
        /** Raw puzzle input */
        input: string;
        /** Answers for the day */
        answers: { a: string | number, b: string | number}


Session and data storage locations can be configured with a .aocrc or environment variables

AOC_USER=blacha # github user name
AOC_DATA_PATH=. # Store the .aoc-data folder in the same folder as your .aocrc
export AOC_SESSION=YourAoCSession