Socket
Socket
Sign inDemoInstall

stable

Package Overview
Dependencies
0
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.1.0 to 0.1.1

2

package.json
{
"name": "stable",
"version": "0.1.0",
"version": "0.1.1",
"description": "A stable array sort for JavaScript",

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

@@ -1,6 +0,6 @@

## Stable
## Stable [![Build Status](https://secure.travis-ci.org/Two-Screen/stable.png)](http://travis-ci.org/Two-Screen/stable)
A stable array sort, because `Array#sort()` is not guaranteed stable.
MIT-licensed.
MIT licensed.

@@ -19,16 +19,16 @@ ### From the browser

var stable = require('stable');
var stable = require("stable");
#### Usage
The default sort is, as with `Array#sort`, in lexical order
The default sort is, as with `Array#sort`, lexicographical:
stable(["foo", "bar"]) -> ["bar", "foo"]
stable([1, 5, 10]) -> [1, 10, 5]
stable(["foo", "bar"]); // => ["bar", "foo"]
stable([10, 1, 5]); // => [1, 10, 5]
A comparator function can be specified:
function cmp(a, b) { return a > b };
stable([1, 5, 10], cmp) -> [1, 5, 10]
function cmp(a, b) { return a > b }
var res = stable([10, 1, 5], cmp); // -> [1, 5, 10]
Unlike `Array#sort`, sorting is *NOT* performed in-place.
Unlike `Array#sort`, sorting is **NOT** performed in-place.

@@ -5,3 +5,3 @@ (function() {

// This is an implementation of merge sort, without recursion.
// © 2012 Stéphan Kochen, Angry Bytes. MIT-licensed.
// © 2012 Stéphan Kochen, Angry Bytes. MIT licensed.

@@ -20,7 +20,4 @@ var stable = function(arr, comp) {

for (chk = 1; chk < len; chk *= 2) {
console.log("before " + chk + " " + JSON.stringify(arr));
arr = pass(arr, comp, chk);
}
console.log("result " + JSON.stringify(arr));
console.log('');
return arr;

@@ -81,3 +78,3 @@ };

// Export use CommonJS or to the window.
// Export using CommonJS or to the window.
if (typeof(module) !== 'undefined') {

@@ -84,0 +81,0 @@ module.exports = stable;

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc