New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

porter2

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

porter2

Fastest JavaScript implementation of the porter2 stemmer

latest
Source
npmnpm
Version
1.1.0
Version published
Weekly downloads
9.3K
41.53%
Maintainers
1
Weekly downloads
 
Created
Source

porter2   npm CI

Fast JavaScript implementation of the porter2 English stemming algorithm.

$ npm install porter2

Usage

The package is simple: it has no dependencies and exports a single function named stem.

Import using CommonJS:

const { stem } = require('porter2')

Or, import using EcmaScript Modules (through interoperability with CommonJS):

import { stem } from 'porter2'

Use the stemmer:

const word = stem('animadversion')
console.log(word) //=> animadvers

This stemmer expects a lowercase English word.

The code is compatible with ES5. TypeScript type declarations are included.

Benchmarks

On my machine, the 29.4k test suite executes in ~5.25ms (~5.6M/s throughput) in a hot loop (~31ms for the first run).

Here is a comparison with some other libraries (you probably should take it with a little grain of salt):

librarythroughput (node)throughput (bun)
porter2 1.0.35621 kops/s6780 kops/s
stemr 1.0.0840 kops/s920 kops/s
wink-porter2-stemmer 1 2.0.1340 kops/s420 kops/s

Here are libraries that implement the older porter version 1 (note the behavior is not identical):

librarythroughput (node)throughput (bun)
porter-stemmer-js 2 1.1.23280 kops/s3373 kops/s
stemmer 3 2.0.12100 kops/s1549 kops/s
@stdlib/nlp-porter-stemmer 0.2.21712 kops/s1604 kops/s
porter-stemmer 0.9.1951 kops/s1264 kops/s

The benchmark code is in bench/run.mjs. This was tested with Node.js v22.14.0 and bun v1.2.10 on Zen 3 (4.5 GHz boosted).

Footnotes

  • wink-porter2-stemmer is 99.97% porter2 compliant (fails on ' cases only)

  • That one has similar goals and, surprisingly, was published just 3 days before this package! (And after the author started working on porter2.js.)

  • ESM only

Keywords

stemmer

FAQs

Package last updated on 26 Mar 2026

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts