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

read-pkg

Package Overview
Dependencies
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

read-pkg - npm Package Compare versions

Comparing version 6.0.0 to 7.0.0

10

index.d.ts

@@ -32,13 +32,13 @@ import * as typeFest from 'type-fest';

```
import {readPackageAsync} from 'read-pkg';
import {readPackage} from 'read-pkg';
console.log(await readPackageAsync());
console.log(await readPackage());
//=> {name: 'read-pkg', …}
console.log(await readPackageAsync({cwd: 'some-other-directory'});
console.log(await readPackage({cwd: 'some-other-directory'});
//=> {name: 'unicorn', …}
```
*/
export function readPackageAsync(options?: NormalizeOptions): Promise<NormalizedPackageJson>;
export function readPackageAsync(options: Options): Promise<PackageJson>;
export function readPackage(options?: NormalizeOptions): Promise<NormalizedPackageJson>;
export function readPackage(options: Options): Promise<PackageJson>;

@@ -45,0 +45,0 @@ /**

@@ -1,9 +0,10 @@

import fs, {promises as fsAsync} from 'fs';
import path from 'path';
import process from 'node:process';
import fs, {promises as fsPromises} from 'node:fs';
import path from 'node:path';
import parseJson from 'parse-json';
import normalizePackageData from 'normalize-package-data';
export async function readPackageAsync({cwd = process.cwd(), normalize = true} = {}) {
export async function readPackage({cwd = process.cwd(), normalize = true} = {}) {
const filePath = path.resolve(cwd, 'package.json');
const json = parseJson(await fsAsync.readFile(filePath, 'utf8'));
const json = parseJson(await fsPromises.readFile(filePath, 'utf8'));

@@ -10,0 +11,0 @@ if (normalize) {

{
"name": "read-pkg",
"version": "6.0.0",
"version": "7.0.0",
"description": "Read a package.json file",

@@ -16,3 +16,3 @@ "license": "MIT",

"engines": {
"node": ">=12"
"node": ">=12.20"
},

@@ -38,11 +38,11 @@ "scripts": {

"dependencies": {
"@types/normalize-package-data": "^2.4.0",
"@types/normalize-package-data": "^2.4.1",
"normalize-package-data": "^3.0.2",
"parse-json": "^5.2.0",
"type-fest": "^1.0.1"
"type-fest": "^2.0.0"
},
"devDependencies": {
"ava": "^3.15.0",
"tsd": "^0.14.0",
"xo": "^0.38.2"
"tsd": "^0.17.0",
"xo": "^0.44.0"
},

@@ -49,0 +49,0 @@ "xo": {

@@ -19,8 +19,8 @@ # read-pkg

```js
import {readPackageAsync} from 'read-pkg';
import {readPackage} from 'read-pkg';
console.log(await readPkg());
console.log(await readPackage());
//=> {name: 'read-pkg', …}
console.log(await readPkg({cwd: 'some-other-directory'}));
console.log(await readPackage({cwd: 'some-other-directory'}));
//=> {name: 'unicorn', …}

@@ -31,3 +31,3 @@ ```

### readPackageAsync(options?)
### readPackage(options?)

@@ -34,0 +34,0 @@ Returns a `Promise<object>` with the parsed JSON.

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