BlueGit

blue-star danique-bot

Files

danique-bot / node_modules / fast-json-stable-stringify / test / cmp.js

cmp.js

Import template
timfa Tim · pushed by timfa · 4 years ago
c788ad20 History
cmp.js 350 B Download Raw
1'use strict';
2
3var test = require('tape');
4var stringify = require('../');
5
6test('custom comparison function', function (t) {
7 t.plan(1);
8 var obj = { c: 8, b: [{z:6,y:5,x:4},7], a: 3 };
9 var s = stringify(obj, function (a, b) {
10 return a.key < b.key ? 1 : -1;
11 });
12 t.equal(s, '{"c":8,"b":[{"z":6,"y":5,"x":4},7],"a":3}');
13});