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

@h4ad/dependency-extractor

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@h4ad/dependency-extractor

🚀 Dependency Extractor

  • 1.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
15
decreased by-65.91%
Maintainers
1
Weekly downloads
 
Created
Source

🚀 Dependency Extractor

Usage   |    Credits

npm package Build Status Downloads Issues Code Coverage Commitizen Friendly Semantic Release

Retrieves the (flat) list of package dependencies from the package manager lock file.

Currently, we support these package managers:

  • npm using (NpmExtractor).

Usage

First, install the library with:

npm i @h4ad/dependency-extractor

Then, you need to read and parse the package-lock.json:

import { NpmExtractor } from '@h4ad/dependency-extractor';
import { readFileSync } from 'fs';

const extractor = new NpmExtractor();
const packageLock = readFileSync('package-lock.json').toString('utf-8');

const dependencyContainer = extractor.parse(packageLock);

Then, you can use the information collected from your dependencies with:

const allDependencies = dependencyContainer.getAllDependencies();
const productionDependencies = dependencyContainer.getProductionDependencies();
const developmentDependencies = dependencyContainer.getDevelopmentDependencies();
const peerDependencies = dependencyContainer.getPeerDependencies();
const optionalDependencies = dependencyContainer.getOptionalDependencies();

const firstDependency = allDependencies[0];

console.log(firstDependency.name);
console.log(firstDependency.version);
console.log(firstDependency.isProduction);
console.log(firstDependency.isDevelopment);
console.log(firstDependency.isOptional);
console.log(firstDependency.isPeer);

Credits

This library was based on npm-dependencies-extractor.

Keywords

FAQs

Package last updated on 04 Dec 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