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

comparing-dependencies

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

comparing-dependencies

This library outputs the comparison results of depending libraries as a CSV file.

  • 0.4.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

comparing-dependencies

This is a npm library that imports multiple package.json files and outputs the comparison results of depending libraries as a CSV format string.

libraryprj_01prj_02prj_03
dayjs^1.10.3^1.10.2
moment^2.29.1
react^17.0.2^17.0.2
react-redux^7.2.4
webpack^5.51.1^5.47.1^4.46.0

How to use

$ yarn add comparing-dependencies

API

createCsv(packageJsons: PackageJson[]): string

Note: PackageJson type is declared in type-fest.

Usage

import { createCsv } from 'comparing-dependencies'

const csv = createCsv([
  {
    name: 'prj_01',
    dependencies: {
      react: '^17.0.2',
      dayjs: '^1.10.3',
    },
    devDependencies: {
      webpack: '^5.51.1',
    },
  },
  {
    name: 'prj_02',
    dependencies: {
      react: '^17.0.2',
      dayjs: '^1.10.2',
      react-redux: '^7.2.4',
    },
    devDependencies: {
      webpack: '^5.47.1',
    },
  },
  {
    name: 'prj_03',
    dependencies: {
      moment: '^2.29.1',
      webpack: '^4.46.0',
    },
  },
])

console.log(csv)

// "library","prj_01","prj_02","prj_03"
// "dayjs","^1.10.3","^1.10.2",""
// "moment","","","^2.29.1"
// "react","^17.0.2","^17.0.2",""
// "react-redux","","^7.2.4",""
// "webpack","^5.51.1","^5.47.1","^4.46.0"

Example codes

Replacing package.json files

Place the package.json files that you want to compare under the ./examples/inputs directory. Then, the name field in each package.json will be output as a column name in the CSV.

examples/inputs/
  |- example_package_01.json
  |- example_package_02.json
  |- example_package_03.json

These file names can be anything you want.

Running

$ yarn run-example

Checking the result

The result.csv will be output at the ./examples.

$ open ./examples/result.csv

FAQs

Package last updated on 23 Jun 2022

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