mirror of
https://github.com/fluencelabs/js-libp2p-utils
synced 2025-04-25 14:12:15 +00:00
15 lines
388 B
JavaScript
15 lines
388 B
JavaScript
'use strict'
|
|
|
|
/**
|
|
* Verify if two arrays of non primitive types with the "equals" function are equal.
|
|
* Compatible with multiaddr, peer-id and Buffer.
|
|
* @param {Array<*>} a
|
|
* @param {Array<*>} b
|
|
* @returns {boolean}
|
|
*/
|
|
function arrayEquals (a, b) {
|
|
return a.length === b.length && b.sort() && a.sort().every((item, index) => b[index].equals(item))
|
|
}
|
|
|
|
module.exports = arrayEquals
|