/
eapostnova
/
2026-1--study--mathmod
Обзор
Документация
Войти
/
eapostnova
/
2026-1--study--mathmod
Код
Запросы
0
Задачи
Пакеты
0
Релизы
6
Аналитика
Безопасность
develop
node_modules/compare-func/index.js
42 строки
770 B
Елизавета Постнова
feat(lab): lab04
24 мар 2026, 02:59
Верифицирован
24 мар 2026, 02:59
7783508
Код
Авторство
О чём код?
'use strict'; var arrayify = require('array-ify'); var dotPropGet = require('dot-prop').get; function compareFunc(prop) { return function(a, b) { var ret = 0; arrayify(prop).some(function(el) { var x; var y; if (typeof el === 'function') { x = el(a); y = el(b); } else if (typeof el === 'string') { x = dotPropGet(a, el); y = dotPropGet(b, el); } else { x = a; y = b; } if (x === y) { ret = 0; return; } if (typeof x === 'string' && typeof y === 'string') { ret = x.localeCompare(y); return ret !== 0; } ret = x < y ? -1 : 1; return true; }); return ret; }; } module.exports = compareFunc;