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

txcategorizer

v0.1.0

Published

Parse and categorize Norwegian bank transaction exports (limited support for DNB and Valle) into structured, labeled data.

Readme

txcategorizer

Parse and categorize Norwegian bank transaction exports (limited support for DNB and Valle) into structured, labeled data.

Install

pnpm add txcategorizer

Basic usage

import { processTransactions } from 'txcategorizer';

const result = processTransactions(csvContent, 'dnb');

csvContent can be a string or ArrayBuffer. Valle exports use Windows-1252 encoding — pass the raw ArrayBuffer and the library handles decoding automatically.

// Reading a file in Node.js
import { readFileSync } from 'fs';

const buffer = readFileSync('transactions.csv').buffer;
const result = processTransactions(buffer, 'valle');

Each result item is a Transaction:

type Transaction = {
    date: string; // "2025-12-31"
    amount: number; // negative = expense, positive = income
    merchant: string; // "REMA 1000"
    counterparty?: string; // "Sofie Krukhaug" (for transfers/Vipps)
    category: Category; // "Dagligvare"
    type: TransactionType; // "Varekjøp"
    valuta?: Valuta; // only present for non-NOK transactions
    raw?: string; // original description (debug mode only)
};

Options

All options are optional — the defaults work out of the box.

const result = processTransactions(csvContent, 'dnb', {
    merchantAliases: { rema: 'REMA 1000' },
    categoryKeywords: { Dagligvare: ['rema', 'kiwi', 'extra'] },
    ownAccounts: ['1234 56 78901'],
    cityPrefixes: ['Oslo', 'Bergen'],
    nWordMerchants: { Burger: 2, Salt: 3 },
    corporateSuffixPattern: /\s+(as|asa)\b.*$/i,
    debug: false,
});

| Option | Type | Description | | ------------------------ | ------------------------------------- | ---------------------------------------------------------------------------------------------- | | merchantAliases | Record<string, string> | Normalize raw merchant names. Keys are lowercase prefix matches. | | categoryKeywords | Partial<Record<Category, string[]>> | Keywords (word-boundary matched) mapped to categories. | | ownAccounts | string[] | Account numbers that identify transfers to your own accounts → type becomes Kontoregulering. | | cityPrefixes | string[] | City names that prefix merchant names in card transactions (e.g. "Gjøvik Specsave"). | | nWordMerchants | Record<string, number> | Multi-word merchant names. Key = first word, value = total word count to capture. | | corporateSuffixPattern | RegExp | Pattern to strip from company names (e.g. " As", " Asa"). | | extractionRules | MerchantRule[] | Fully replace the built-in extraction rules with your own. | | debug | boolean | Adds raw field with original description to each transaction. |

Extending defaults

To add entries on top of the defaults rather than replacing them:

import { processTransactions, defaultCityPrefixes, defaultNWordMerchants } from 'txcategorizer';

const result = processTransactions(csvContent, 'dnb', {
    cityPrefixes: [...defaultCityPrefixes, 'Hamar', 'Lillehammer'],
    nWordMerchants: { ...defaultNWordMerchants, Little: 2 },
});

Custom extraction rules

For full control over merchant extraction, provide your own extractionRules. Each rule has a match predicate and an extract function:

import { processTransactions, MerchantRule } from 'txcategorizer';

const myRules: MerchantRule[] = [
    {
        match: ({ type }) => type === 'Varekjøp',
        extract: ({ description }) => ({
            merchant: description.split(/\s+/)[0],
        }),
    },
];

const result = processTransactions(csvContent, 'dnb', {
    extractionRules: myRules,
});

Categories

import { CATEGORIES } from 'txcategorizer';

The 20 built-in categories:

Dagligvare · Mat ute · Hjem · Underholdning · Gaming · Abonnement · Netthandel · Helse · Kosmetikk · Kreditt · Transport · Bil · Bolig · Boutgifter · Forsikring · Overføring · Inntekt · Sparing · Diverse · Annet

Transactions that don't match any keyword fall back to Annet.

Valle encoding

Valle exports CSV files in Windows-1252. Pass the raw buffer and the library handles it:

import { decodeWindows1252 } from 'txcategorizer';

// Or let processTransactions handle it automatically:
const buffer = readFileSync('valle.csv').buffer;
processTransactions(buffer, 'valle'); // decoded internally

Supported banks

| Bank | Format | Encoding | | ----- | ------------------- | ------------ | | DNB | CSV (; delimited) | UTF-8 | | Valle | CSV (; delimited) | Windows-1252 |

Testing

pnpm test
pnpm test:watch

The tests and the documentation was drafted with the help of an LLM (Claude)