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

tarry

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tarry - npm Package Compare versions

Comparing version 0.2.0 to 0.2.1

13

index.d.ts

@@ -130,1 +130,14 @@ /**

export declare function assign<T, U, V, W>(target: T, source1: U, source2: V, source3: W): T & U & V & W;
/**
Merge each item in items that shares the same identifier.
mergeBy([
{id: 1, firstname: 'Chris'},
{id: 1, lastname: 'Brown'},
{id: 2, firstname: 'Lionel'},
]) => [
{id: 1, firstname: 'Chris', lastname: 'Brown'},
{id: 2, firstname: 'Lionel'},
]
*/
export declare function mergeBy<T>(items: T[], idKey?: string): T[];

@@ -236,1 +236,31 @@ /**

exports.assign = assign;
/**
Merge each item in items that shares the same identifier.
mergeBy([
{id: 1, firstname: 'Chris'},
{id: 1, lastname: 'Brown'},
{id: 2, firstname: 'Lionel'},
]) => [
{id: 1, firstname: 'Chris', lastname: 'Brown'},
{id: 2, firstname: 'Lionel'},
]
*/
function mergeBy(items, idKey) {
if (idKey === void 0) { idKey = 'id'; }
var mergedItems = [];
// mergedItemsMapping is a helper that maps from ids to the matching object,
// which is also stored in the mergedItems array
var mergedItemsMapping = {};
items.forEach(function (item) {
var id = item[idKey];
var mergedItem = mergedItemsMapping[id];
if (mergedItem === undefined) {
mergedItem = mergedItemsMapping[id] = {};
mergedItems.push(mergedItem);
}
assign(mergedItem, item);
});
return mergedItems;
}
exports.mergeBy = mergeBy;

2

package.json
{
"name": "tarry",
"version": "0.2.0",
"version": "0.2.1",
"description": "Utility library for manipulating JavaScript Arrays",

@@ -5,0 +5,0 @@ "keywords": [

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