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

match-sorter

Package Overview
Dependencies
Maintainers
1
Versions
46
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

match-sorter - npm Package Compare versions

Comparing version 1.1.0 to 1.2.0

19

dist/index.js

@@ -74,3 +74,4 @@ (function (global, factory) {

var newRank = getMatchRanking(item[key], value);
var itemValue = getItemValue(item, key);
var newRank = getMatchRanking(itemValue, value);
if (newRank > rank) {

@@ -214,3 +215,19 @@ rank = newRank;

/**
* Gets value for key in item at arbitrarily nested keypath
* @param {Object} item - the item
* @param {Object} key - the potentially nested keypath
* @return {String} - the value at nested keypath
*/
function getItemValue(item, key) {
var isNested = key.indexOf('.') !== -1;
if (!isNested) {
return item[key];
}
return key.split('.').reduce(function (itemObj, nestedKey) {
return itemObj[nestedKey];
}, item);
}
module.exports = exports.default; // CommonJS compat
});

2

package.json
{
"name": "match-sorter",
"version": "1.1.0",
"version": "1.2.0",
"description": "Simple, expected, and deterministic best-match sorting of an array in JavaScript",

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

# match-sorter
Simple, expected, and deterministic best-match sorting of an array in JavaScript
Simple, expected, and deterministic best-match sorting of an array in JavaScript. **[Demo](https://jsbin.com/vewoka/edit?js,output)**

@@ -12,3 +12,3 @@ [![Build Status][build-badge]][build]

[![All Contributors](https://img.shields.io/badge/all_contributors-1-orange.svg?style=flat-square)](#contributors)
[![All Contributors](https://img.shields.io/badge/all_contributors-2-orange.svg?style=flat-square)](#contributors)
[![PRs Welcome][prs-badge]][prs]

@@ -113,4 +113,4 @@ [![Donate][donate-badge]][donate]

<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
| [<img src="https://avatars.githubusercontent.com/u/1500684?v=3" width="100px;"/><br /><sub>Kent C. Dodds</sub>](https://kentcdodds.com)<br />[💻](https://github.com/kentcdodds/match-sorter/commits?author=kentcdodds) [📖](https://github.com/kentcdodds/match-sorter/commits?author=kentcdodds) 🚇 [⚠️](https://github.com/kentcdodds/match-sorter/commits?author=kentcdodds) |
| :---: |
| [<img src="https://avatars.githubusercontent.com/u/1500684?v=3" width="100px;"/><br /><sub>Kent C. Dodds</sub>](https://kentcdodds.com)<br />[💻](https://github.com/kentcdodds/match-sorter/commits?author=kentcdodds) [📖](https://github.com/kentcdodds/match-sorter/commits?author=kentcdodds) 🚇 [⚠️](https://github.com/kentcdodds/match-sorter/commits?author=kentcdodds) | [<img src="https://avatars.githubusercontent.com/u/8263298?v=3" width="100px;"/><br /><sub>Conor Hastings</sub>](http://conorhastings.com)<br />[💻](https://github.com/kentcdodds/match-sorter/commits?author=conorhastings) |
| :---: | :---: |
<!-- ALL-CONTRIBUTORS-LIST:END -->

@@ -117,0 +117,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