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

sort-keys

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sort-keys - npm Package Compare versions

Comparing version 1.1.1 to 1.1.2

13

index.js

@@ -17,7 +17,18 @@ 'use strict';

var deep = opts.deep;
var seenInput = [];
var seenOutput = [];
var sortKeys = function (x) {
var seenIndex = seenInput.indexOf(x);
if (seenIndex !== -1) {
return seenOutput[seenIndex];
}
var ret = {};
var keys = Object.keys(x).sort(opts.compare);
seenInput.push(x);
seenOutput.push(ret);
for (var i = 0; i < keys.length; i++) {

@@ -27,3 +38,3 @@ var key = keys[i];

ret[key] = deep && val !== x && isPlainObj(val) ? sortKeys(val) : val;
ret[key] = deep && isPlainObj(val) ? sortKeys(val) : val;
}

@@ -30,0 +41,0 @@

11

package.json
{
"name": "sort-keys",
"version": "1.1.1",
"version": "1.1.2",
"description": "Sort the keys of an object",

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

"scripts": {
"test": "mocha"
"test": "xo && mocha"
},

@@ -23,7 +23,7 @@ "files": [

"keywords": [
"sort",
"object",
"keys",
"obj",
"keys",
"key",
"sort",
"stable",

@@ -39,4 +39,5 @@ "deterministic",

"devDependencies": {
"mocha": "*"
"mocha": "*",
"xo": "*"
}
}

@@ -18,3 +18,3 @@ # sort-keys [![Build Status](https://travis-ci.org/sindresorhus/sort-keys.svg?branch=master)](https://travis-ci.org/sindresorhus/sort-keys)

```js
var sortKeys = require('sort-keys');
const sortKeys = require('sort-keys');

@@ -28,5 +28,3 @@ sortKeys({c: 0, a: 0, b: 0});

sortKeys({c: 0, a: 0, b: 0}, {
compare: function (a, b) {
return -a.localeCompare(b);
}
compare: (a, b) => -a.localeCompare(b)
});

@@ -45,4 +43,3 @@ //=> {c: 0, b: 0, a: 0}

*Required*
Type: `object`
Type: `Object`

@@ -59,3 +56,3 @@ #### options

Type: `function`
Type: `Function`

@@ -67,2 +64,2 @@ [Compare function.](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort)

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