Socket
Socket
Sign inDemoInstall

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 1.1.0 to 2.0.0

21

index.js
'use strict';
var path = require('path');
var loadJsonFile = require('load-json-file');
var normalizePackageData = require('normalize-package-data');
var pathType = require('path-type');
const path = require('path');
const loadJsonFile = require('load-json-file');
const pathType = require('path-type');
module.exports = function (fp, opts) {
module.exports = (fp, opts) => {
if (typeof fp !== 'string') {

@@ -16,3 +15,3 @@ opts = fp;

return pathType.dir(fp)
.then(function (isDir) {
.then(isDir => {
if (isDir) {

@@ -24,5 +23,5 @@ fp = path.join(fp, 'package.json');

})
.then(function (x) {
.then(x => {
if (opts.normalize !== false) {
normalizePackageData(x);
require('normalize-package-data')(x);
}

@@ -34,3 +33,3 @@

module.exports.sync = function (fp, opts) {
module.exports.sync = (fp, opts) => {
if (typeof fp !== 'string') {

@@ -44,6 +43,6 @@ opts = fp;

var x = loadJsonFile.sync(fp);
const x = loadJsonFile.sync(fp);
if (opts.normalize !== false) {
normalizePackageData(x);
require('normalize-package-data')(x);
}

@@ -50,0 +49,0 @@

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

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

"engines": {
"node": ">=0.10.0"
"node": ">=4"
},

@@ -35,5 +35,5 @@ "scripts": {

"dependencies": {
"load-json-file": "^1.0.0",
"load-json-file": "^2.0.0",
"normalize-package-data": "^2.3.2",
"path-type": "^1.0.0"
"path-type": "^2.0.0"
},

@@ -43,3 +43,6 @@ "devDependencies": {

"xo": "*"
},
"xo": {
"esnext": true
}
}

@@ -24,5 +24,5 @@ # read-pkg [![Build Status](https://travis-ci.org/sindresorhus/read-pkg.svg?branch=master)](https://travis-ci.org/sindresorhus/read-pkg)

```js
var readPkg = require('read-pkg');
const readPkg = require('read-pkg');
readPkg().then(function (pkg) {
readPkg().then(pkg => {
console.log(pkg);

@@ -32,3 +32,3 @@ //=> {name: 'read-pkg', ...}

readPkg(__dirname).then(function (pkg) {
readPkg(__dirname).then(pkg => {
console.log(pkg);

@@ -38,3 +38,3 @@ //=> {name: 'read-pkg', ...}

readPkg(path.join('unicorn', 'package.json')).then(function (pkg) {
readPkg(path.join('unicorn', 'package.json')).then(pkg => {
console.log(pkg);

@@ -50,3 +50,3 @@ //=> {name: 'read-pkg', ...}

Returns a promise that resolves to the parsed JSON.
Returns a `Promise` for the parsed JSON.

@@ -59,3 +59,3 @@ ### readPkg.sync([path], [options])

Type: `string`
Type: `string`<br>
Default: `.`

@@ -69,3 +69,3 @@

Type: `boolean`
Type: `boolean`<br>
Default: `true`

@@ -85,2 +85,2 @@

MIT © [Sindre Sorhus](http://sindresorhus.com)
MIT © [Sindre Sorhus](https://sindresorhus.com)
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