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

@openreachtech/mentsu-field-path-value-extractor

v1.1.1

Published

Mentsu field path value extractor

Readme

@openreachtech/mentsu-field-path-value-extractor

Extract values from a nested object using delimited field paths.

Overview

FieldPathValueExtractor reads values out of a nested object (or array) by a single string field path such as 'CustomerProfile.lastName'. The path is split by a configurable delimiter (. by default) and traversed segment by segment.

  • Missing segments resolve to null instead of throwing.
  • A fallback default value can be supplied per lookup.
  • #buildClue() exposes the extractor as a proxy for property-style access, and #bulkExtract() resolves many paths at once into a plain object.

Installation

Requires Node.js 20.x (the version the CI builds against).

npm install @openreachtech/mentsu-field-path-value-extractor

It is an ES module ("type": "module"); import it with ESM import syntax.

Usage

Property access with a clue proxy

import { FieldPathValueExtractor } from '@openreachtech/mentsu-field-path-value-extractor'

const alphaExtractor = FieldPathValueExtractor.create({
  root: {
    id: 100001,
    CustomerProfile: {
      lastName: 'Doe',
      firstName: 'John',
    },
    CustomerPayments: [
      {
        CustomerPaymentPaidValue: {
          CoinType: {
            name: 'Bitcoin',
          },
        },
      },
    ],
  },
})

const alphaClue = alphaExtractor.buildClue()

// Property access with a delimited field path.
alphaClue['CustomerProfile.lastName'] // 'Doe'
alphaClue['CustomerPayments.0.CustomerPaymentPaidValue.CoinType.name'] // 'Bitcoin'

// A missing path resolves to null.
alphaClue['CustomerProfile.birthdate'] // null

// Call form with a fallback default value.
alphaClue('CustomerProfile.middleName', 'N/A') // 'N/A'

Extracting many paths at once

import { FieldPathValueExtractor } from '@openreachtech/mentsu-field-path-value-extractor'

const betaExtractor = FieldPathValueExtractor.create({
  root: {
    id: 100001,
    CustomerProfile: {
      lastName: 'Doe',
      firstName: 'John',
    },
  },
})

const betaExtractedValues = betaExtractor.bulkExtract({
  lookup: {
    customerId: 'id',
    lastName: 'CustomerProfile.lastName',
    middleName: ['CustomerProfile.middleName', 'N/A'], // tuple form: [fieldPath, defaultValue]
  },
})

// {
//   customerId: 100001,
//   lastName: 'Doe',
//   middleName: 'N/A',
// }

Using a custom delimiter

import { FieldPathValueExtractor } from '@openreachtech/mentsu-field-path-value-extractor'

const gammaExtractor = FieldPathValueExtractor.create({
  root: {
    CustomerProfile: {
      lastName: 'Smith',
    },
  },
  delimiter: ':',
})

const gammaClue = gammaExtractor.buildClue()

gammaClue['CustomerProfile:lastName'] // 'Smith'

API

Class members are written with the following notation.

| notation | members | | :-- | :-- | | #instanceProperty | instance property | | #instanceMethod() | instance method | | #get:instanceGetter | instance getter | | #set:instanceSetter | instance setter | | .staticProperty | static property | | .staticMethod() | static method | | .get:staticGetter | static getter | | .set:staticSetter | static setter |

FieldPathValueExtractor

Class for extracting a value from an object using a delimited field path.

.create()

Factory method. Creates an instance.

Parameters (single object argument):

| key | type | required | description | | :-- | :-- | :-- | :-- | | root | object | yes | The source object (or array) to extract values from. | | delimiter | string | no | The field path delimiter. Defaults to '.'. |

Returns: a FieldPathValueExtractor instance.

#extractFieldPathValue()

Extracts a single value from root using a delimited field path.

Parameters (single object argument):

| key | type | required | description | | :-- | :-- | :-- | :-- | | fieldPath | string | yes | The delimited field path to resolve against root. |

Returns: the value at the path, or null when any segment is missing.

#buildClue()

Builds a proxy that resolves delimited field paths against root.

Takes no arguments. Returns a proxy that supports two access styles:

  • Property access — clue['a.b.c'] returns the value at the path, or null when any segment is missing.
  • Function call — clue('a.b.c', defaultValue) returns the value at the path, or defaultValue (default null) when the resolved value is nullish.

#bulkExtract()

Extracts multiple values at once from a lookup map.

Parameters (single object argument):

| key | type | required | description | | :-- | :-- | :-- | :-- | | lookup | Record<string, string \| [string, *]> | yes | A map whose keys are output keys. Each value is either a field path string, or a [fieldPath, defaultValue] tuple. |

Returns: an object with the same keys as lookup. Each key is mapped to the extracted value, or to the tuple's defaultValue when the extracted value is nullish.

Contribution

Bug reports, feature requests, and code contributions are welcome.

Feel free to contact us through GitHub Issues.

git clone https://github.com/openreachtech/mentsu-field-path-value-extractor.git
cd mentsu-field-path-value-extractor
npm install
npm run lint
npm test

License

This project is released under the MIT License.

For more details, please see in the LICENSE file.

Developer

Open Reach Tech Inc.

Copyright

© 2026 Open Reach Tech Inc.