mirror of
https://github.com/react/react-native-devtools-frontend.git
synced 2026-10-02 18:11:04 +08:00
R=alexrudenko@chromium.org Bug: None Change-Id: I1f8dcaa62c6d5e90f37c34db1fd8fb2ed1a7369c Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/5666839 Reviewed-by: Alex Rudenko <alexrudenko@chromium.org> Commit-Queue: Alex Rudenko <alexrudenko@chromium.org> Auto-Submit: Simon Zünd <szuend@chromium.org>
35 lines
811 B
JavaScript
35 lines
811 B
JavaScript
"use strict";
|
|
|
|
var sort = require("./prototypes/array").sort;
|
|
var slice = require("./prototypes/array").slice;
|
|
|
|
/**
|
|
* @private
|
|
*/
|
|
function comparator(a, b) {
|
|
// uuid, won't ever be equal
|
|
var aCall = a.getCall(0);
|
|
var bCall = b.getCall(0);
|
|
var aId = (aCall && aCall.callId) || -1;
|
|
var bId = (bCall && bCall.callId) || -1;
|
|
|
|
return aId < bId ? -1 : 1;
|
|
}
|
|
|
|
/**
|
|
* A Sinon proxy object (fake, spy, stub)
|
|
* @typedef {object} SinonProxy
|
|
* @property {Function} getCall - A method that can return the first call
|
|
*/
|
|
|
|
/**
|
|
* Sorts an array of SinonProxy instances (fake, spy, stub) by their first call
|
|
* @param {SinonProxy[] | SinonProxy} spies
|
|
* @returns {SinonProxy[]}
|
|
*/
|
|
function orderByFirstCall(spies) {
|
|
return sort(slice(spies), comparator);
|
|
}
|
|
|
|
module.exports = orderByFirstCall;
|