Skip to content

Commit

Permalink
[Tests] key ordering is reversed in node 11+
Browse files Browse the repository at this point in the history
  • Loading branch information
ljharb committed Dec 17, 2024
1 parent 5dbd6c8 commit 7034a17
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion test/space.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
var test = require('tape');
var stringify = require('../');

// @ts-expect-error node ensures this will never fail
var isNode10OrLess = parseInt(process.version.match(/^v(\d+)\./)[1], 10) <= 10;

test('space parameter', function (t) {
t.plan(1);
var obj = { one: 1, two: 2 };
Expand Down Expand Up @@ -76,7 +79,7 @@ test('space parameter, on a cmp function', function (t) {
var obj = { one: 1, two: 2 };
/** @type {import('..').Comparator & import('../').StableStringifyOptions} */
var cmp = function (a, b) {
return a < b ? 1 : -1;
return (a < b ? 1 : -1) * (isNode10OrLess ? -1 : 1);
};

t.equal(
Expand Down

0 comments on commit 7034a17

Please sign in to comment.