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

request-prop

v2.1.1

Published

Abstracted way of extracting props from an object

Readme

Code

See the code at github repo

Installation

npm i request-prop --save

Contribute

Contributions are welcome, you can get up and running by cloning the project and running following command in the CLI

Assuming that you have node and npm installed

npm i || npm install

Usage

Retrieving props from the objects in the array and building new array with

var requestProp = require('request-prop');

const exampleComplexArrayFromSomeNetworkRequest = [
  { Id: '4466t-5564edd-444yyhh88-55ffcjkhh', Name: 'Michael Jackson (the coder one)', Age: 26, FavLang: 'JavaScript' },
  { Id: '4466t-5564edd-444yyhh88-77rr212ss', Name: 'Harry Potter', Age: 15, FavLang: 'Java' },
  { Id: '4466t-5564edd-444yyhh88-bbxbmmcee', Name: 'Marry Poppins', Age: 46, FavLang: 'Python' },
  { Id: '4466t-5564edd-444yyhh88-596ss2q35', Name: 'John Doe', Age: 24, FavLang: 'Rust' },
];

const newArrayWithDesiredProps = requestProp(
  exampleComplexArrayFromSomeNetworkRequest, // The raw array to extract data from
  ['Id', 'FavLang']
);

// Returns [{Id: '.....', FavLang: '....'}, {...}, {...}, {...}]

Renaming props, changing case style or making it more descriptive

const newArrayRenamedProps = requestProp(
  exampleComplexArrayFromSomeNetworkRequest,
  // The left side of the colon has to match the original name
  ['Id:id', 'FavLang:favLang'] // I'm a camel case lover
);

// Returns [{id: '.....', favLang: '.....'}, {...}, {...}, {...}]

Extracting data out of object itself, instead of array

const extractDataOutOfObject = requestProp(
  { Id: '...', Name: '....' },
  ['Id: myId', 'Name: myName']
);

Using modifiers third optional parameter

const modifiedProps = requestProp(
  exampleComplexArrayFromSomeNetworkRequest,
  // To use it in modifiers, it has to exist in the requested props first.
  ['Age'],
  // Has to match the original prop name not the modified name
  [
    {
      props: ['Age'],
      computedName: 'age', // It will override the prop name in the object
      operator: age => age + 10
    }
  ]
);

// Return [{age: 36}, {...}, {...}, {...}];

Using modifiers that operates on multiple prop

const person = {
  day: '11',
  month: '06',
  year: '1996'
}

requestProp(
  person,
  ['day: DAY', 'month: MONTH', 'year: YEAR'],
  [
    {
      props: ['day', 'month', 'year'], // These prop names need to match requestedProps
      computedName: 'birthday',
      operator: (d, m, y) => `${d}/${m}/${y}`
    }
  ]
) // Returns -> { DAY: '11', MONTH: '06', birthday: '11/06/1996', YEAR: '1996' }

Modifying single element and renaming it

const obj = {
  name: 'Jane',
  favLang: 'JavaScript',
};

const retrunValue = requestProp(
  obj
  ['favLang'],
  [
    {
      props: ['favLang'],
      computedName: 'getFavLang',
      operator: f => () => `My fav lang is ${f}`
    }
  ]
)

// Calling it returnValue.getFavLang() => 'My fav lang is JavaScript'

Including only desired props

You may want to use props, but not include them in the returned object in such case prepend props with !

const person = {
  name: 'Jane',
  lastname: 'Doe',
  age: 26
};

requestProp(
  person,
  // Appending `!` will exclude them from the returned object
  ['!name', '!lastname'],
  [
    {
      props: ['name', 'lastname'],
      computedName: 'fullname',
      operator: (name, lastname) => `${name} ${lastname}`
    }
  ]
)

// { fullname: 'Jane Doe' } // Doesn't include name and lastname props
// Due to exclamation mark

Using custom rename indication character

// The default is `:` but you are able to change
// by simply providing a character as last character
const customRenameIndicator = requestProp(
  {Name: 'Jane', Lastname: 'Doe'},
  ['Name@name', 'Lastname@lastname'],
  [], // Empty modifications array, to get the last foruth optional
  '@' // Providing the custom rename indication character
);