You're Invited:Meet the Socket Team at RSAC and BSidesSF 2026, March 23–26.RSVP
Socket
Book a DemoSign in
Socket

ptnm

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ptnm

Object Pattern Matching

latest
npmnpm
Version
1.0.0
Version published
Weekly downloads
83
-58.71%
Maintainers
1
Weekly downloads
 
Created
Source

ptnm

Object Pattern Matching

  • zero production dependencies
  • tiny code footprint
  • production battle-tested in Pear

Usage

ptnm matches a pattern object against a message object.

A match succeeds when all enumerable own properties in the pattern exist in the message and are strictly equal, recursively.

Extra properties in the message are ignored.

  • Non-coercive matching (===)
  • Own properties only (non-enumerable/inherited pattern keys ignored)
  • No cycle detection by design - do not pass circular objects

Include

const match = require('ptnm')
import match from 'ptnm'

Basic

match({ a: 1, b: 2 }, { a: 1 }) // true

Nested

match(
    { a: { b: 1, c: 2 } },
    { a: { b: 1 } }
)
// true

Missing or unequal values

match(
    { a: 1 },
    { a: 2 }
)
// false

match(
    {},
    { a: 1 }
)
// false

License

Apache-2.0

FAQs

Package last updated on 21 Jan 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