New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

grunt-sort-json

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

grunt-sort-json - npm Package Compare versions

Comparing version 0.0.2 to 0.0.3

2

package.json
{
"name": "grunt-sort-json",
"version": "0.0.2",
"version": "0.0.3",
"description": "Alphabetizing JSON files. Sort JSON files.",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -6,3 +6,3 @@ 'use strict';

/**
* recursive sorting of object
* recursively sort a given object
*

@@ -17,9 +17,12 @@ * @method recursiveSort

var i;
var attr;
for (i = 0; i < orderedAttributes.length; i++) {
newObject[orderedAttributes[i]] = obj[orderedAttributes[i]];
attr = orderedAttributes[i];
newObject[attr] = obj[attr];
// if it's an object, sort it!
if (typeof obj[orderedAttributes[i]] === 'object') {
newObject[orderedAttributes[i]] = recursiveSort(newObject[orderedAttributes[i]]);
if (typeof obj[attr] === 'object') {
newObject[attr] = recursiveSort(newObject[attr]);
}

@@ -38,6 +41,7 @@ }

function sortFile (file) {
var fileContents = grunt.file.readJSON(file);
var sortedObject = recursiveSort(fileContents);
var object = grunt.file.readJSON(file);
var sortedObject = recursiveSort(object);
grunt.file.write(file, JSON.stringify(sortedObject, null, 4));
grunt.log.writeln('File sorted: ' + file.cyan);
}

@@ -48,3 +52,3 @@

//
grunt.registerMultiTask('sortJSON', 'A grunt task for alphabetizing json files', function () {
grunt.registerMultiTask('sortJSON', 'Alphabetizing JSON files. Sort JSON files.', function () {
this.filesSrc.forEach(function (file) {

@@ -51,0 +55,0 @@ sortFile(file);

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