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

alphabetize-object

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

alphabetize-object - npm Package Compare versions

Comparing version 1.0.0 to 2.0.0

README.md

6

index.js
'use strict';
const alphabetizeObjectKeys = function (object, opts) {
const alphabetizeObject = function (object, opts) {
opts = opts || {};

@@ -24,3 +24,3 @@ const keys = [];

if (typeof dest[key] === 'object') {
dest[key] = alphabetizeObjectKeys(dest[key], opts);
dest[key] = alphabetizeObject(dest[key], opts);
}

@@ -35,2 +35,2 @@ }

module.exports = alphabetizeObjectKeys;
module.exports = alphabetizeObject;
{
"name": "alphabetize-object",
"version": "1.0.0",
"version": "2.0.0",
"description": "alphabetize keys in an object",

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

'use strict';
const alphabetizeObjectKeys = require('./index');
const alphabetizeObject = require('./index');
const assert = require('assert');
describe('alphabetizeObjectKeys', function () {
describe('alphabetizeObject', function () {
it('should sort a generic object', function () {

@@ -14,3 +14,3 @@ const object = {

};
const newObj = alphabetizeObjectKeys(object);
const newObj = alphabetizeObject(object);
assert.deepEqual(newObj, {

@@ -35,3 +35,3 @@ a: 3,

};
const newObj = alphabetizeObjectKeys(object, { recursive: true });
const newObj = alphabetizeObject(object, { recursive: true });
assert.deepEqual(newObj, {

@@ -48,2 +48,67 @@ a: 3,

});
it('should leave the original object alone', function () {
const object = {
b: 1,
d: 2,
a: 3,
c: 4
};
const newObj = alphabetizeObject(object);
assert.deepEqual(newObj, {
b: 1,
d: 2,
a: 3,
c: 4
});
});
it('should leave modify the original object if inPlace is true', function () {
const object = {
b: 1,
d: 2,
a: 3,
c: 4
};
const newObj = alphabetizeObject(object, { inPlace: true });
assert.deepEqual(object, {
a: 3,
b: 1,
c: 4,
d: 2
});
});
it('should be case sensitive', function () {
const object = {
b: 1,
B: 2,
a: 3,
A: 4
};
const newObj = alphabetizeObject(object);
assert.deepEqual(newObj, {
A: 4,
B: 2,
a: 3,
b: 1
});
});
it('should be case insensitive if caseInsensitive is true', function () {
const object = {
B: 1,
b: 2,
a: 3,
A: 4
};
const newObj = alphabetizeObject(object, { caseInsensitive: true });
assert.deepEqual(newObj, {
A: 4,
a: 3,
B: 1,
b: 2
});
});
});
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