Socket
Socket
Sign inDemoInstall

101

Package Overview
Dependencies
Maintainers
1
Versions
43
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

101 - npm Package Compare versions

Comparing version 0.17.0 to 0.18.0

index-by.js

4

CHANGELOG.md

@@ -5,2 +5,6 @@ # Change Log

## [0.18.0] - 2015-05-09
### Added
- [`indexBy`](https://github.com/tjmehta/101#indexBy) module
## [0.17.0] - 2015-05-07

@@ -7,0 +11,0 @@ ### Added

2

package.json
{
"name": "101",
"version": "0.17.0",
"version": "0.18.0",
"description": "common javascript utils that can be required selectively that assume es5+",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -338,6 +338,18 @@ ![101](http://i.imgur.com/MFrmMt6.png)

hasKeypaths(obj, ['foo.bar'], false); // true, uses [hasOwnProperty vs in](http://stackoverflow.com/questions/13632999/if-key-in-object-or-ifobject-hasownpropertykey)
// use it with find, findIndex, or filter!
var arr = [obj, { b: 1 }, { c: 1 }];
find(arr, hasProps({ 'foo.bar.qux':1 })); // { foo: { bar: { qux: 1 } } }
find(arr, hasProps(['foo.bar.qux'])); // { foo: { bar: { qux: 1 } } }
find(arr, hasKeypaths({ 'foo.bar.qux':1 })); // { foo: { bar: { qux: 1 } } }
find(arr, hasKeypaths(['foo.bar.qux'])); // { foo: { bar: { qux: 1 } } }
// use it to verify options object has required properties
var opts = {
host: 'localhost',
port: '3333',
user: {
id: 5
}
};
hasKeypaths(opts, ['host', 'port', 'user.id']); // true
```

@@ -373,2 +385,17 @@

## indexBy
Hashes an array of objects based on the value of a provided common key.
Works nicely with `pluck` and `reduce`.
```js
var arr = [
{foo: 'bar'},
{foo: 'qux'}
];
indexBy(arr, 'foo') // {bar: {foo: 'bar'}, qux: {foo: 'qux'}}
// always provide initial value when using with reduce!
arr.reduce(indexBy(pluck('foo')), {}) // {bar: {foo: 'bar'}, qux: {foo: 'qux'}}
```
## instanceOf

@@ -375,0 +402,0 @@

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