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

sort-package-json

Package Overview
Dependencies
Maintainers
1
Versions
97
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sort-package-json - npm Package Compare versions

Comparing version 1.32.3 to 1.33.0

23

index.js

@@ -154,3 +154,3 @@ #!/usr/bin/env node

const sortOrder = fields.map(({ key }) => key)
const defaultSortOrder = fields.map(({ key }) => key)

@@ -174,2 +174,11 @@ function editStringJSON(json, over) {

const isPrivateKey = key => key[0] === '_'
const partition = (array, predicate) =>
array.reduce(
(result, value) => {
result[predicate(value) ? 0 : 1].push(value)
return result
},
[[], []],
)
function sortPackageJson(jsonIsh, options = {}) {

@@ -179,4 +188,12 @@ return editStringJSON(

onObject(json => {
const newJson = sortObjectKeys(json, options.sortOrder || sortOrder)
let sortOrder = options.sortOrder ? options.sortOrder : defaultSortOrder
if (Array.isArray(sortOrder)) {
const keys = Object.keys(json)
const [privateKeys, publicKeys] = partition(keys, isPrivateKey)
sortOrder = [...sortOrder, ...publicKeys.sort(), ...privateKeys.sort()]
}
const newJson = sortObjectKeys(json, sortOrder)
for (const { key, over } of fields) {

@@ -193,3 +210,3 @@ if (over && newJson[key]) newJson[key] = over(newJson[key])

module.exports.sortPackageJson = sortPackageJson
module.exports.sortOrder = sortOrder
module.exports.sortOrder = defaultSortOrder

@@ -196,0 +213,0 @@ if (require.main === module) {

2

package.json
{
"name": "sort-package-json",
"version": "1.32.3",
"version": "1.33.0",
"description": "Sort an Object or package.json based on the well-known package.json keys",

@@ -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