Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

propprop

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

propprop

Just a helper for plucking a property out of an object.

  • 0.3.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
14K
decreased by-62.72%
Maintainers
1
Weekly downloads
 
Created
Source

propprop

pluck a property out of an object.

Before
var friendsAsJavaScriptLibraries = [
  {
    name: 'passy.js',
    hobby: 'clay'
  },
  {
    name: 'sindre.js',
    vehicle: 'unicorn taxi'
  },
  {
    name: 'addy.js',
    invented: 'google *'
  }
];

var names = friendsAsJavaScriptLibraries.map(function (item) {
  return item.name;
});
After
var friendsAsJavaScriptLibraries = [ /* ... */ ];

var names = friendsAsJavaScriptLibraries.map(prop('name'));

The benefit is more noticeable when you're using multiple Array.prototype methods to shape your objects:

var friendsAsJavaScriptLibraries = [ /* ... */ ];
var urls;

if (friendsAsJavaScriptLibraries.every(prop('name'))) {
  urls = friendsAsJavaScriptLibraries
    .map(function (item) {
      item.url = 'https://github.com/magical-library-land/' + item.name;
      return item;
    })
    .map(prop('url'));
}

Why?

Perhaps you're already using Lo-Dash, Underscore.js, or another utility library. This should not supplement those libraries, and definitely cannot replace. This is better suited towards applications that don't want to carry the weight and/or functionality of such libraries, and just want something simple and modular.

Install

prop can be used in the browser or within your Node.js apps.

Browser
$ bower install --save propprop
<script src="bower_components/propprop/browser.js"></script>
Node.js
$ npm install --save propprop
var prop = require('propprop');

License

MIT © Stephen Sawchuk

Keywords

FAQs

Package last updated on 12 Jul 2016

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc