source: frontend/node_modules/@sinonjs/commons/lib/order-by-first-call.js

Last change on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 13 days ago

Fix frontend appearance

  • Property mode set to 100644
File size: 817 bytes
Line 
1"use strict";
2
3var sort = require("./prototypes/array").sort;
4var slice = require("./prototypes/array").slice;
5
6/**
7 * @private
8 */
9function comparator(a, b) {
10 // uuid, won't ever be equal
11 var aCall = a.getCall(0);
12 var bCall = b.getCall(0);
13 var aId = (aCall && aCall.callId) || -1;
14 var bId = (bCall && bCall.callId) || -1;
15
16 return aId < bId ? -1 : 1;
17}
18
19/**
20 * A Sinon proxy object (fake, spy, stub)
21 *
22 * @typedef {object} SinonProxy
23 * @property {Function} getCall - A method that can return the first call
24 */
25
26/**
27 * Sorts an array of SinonProxy instances (fake, spy, stub) by their first call
28 *
29 * @param {SinonProxy[] | SinonProxy} spies
30 * @returns {SinonProxy[]}
31 */
32function orderByFirstCall(spies) {
33 return sort(slice(spies), comparator);
34}
35
36module.exports = orderByFirstCall;
Note: See TracBrowser for help on using the repository browser.