UNPKG

locutus

Version:

Locutus other languages' standard libraries to JavaScript for fun and educational purposes

27 lines (26 loc) 1.23 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.strnatcasecmp = strnatcasecmp; const _phpCastString_ts_1 = require("../_helpers/_phpCastString.js"); const strnatcmp_ts_1 = require("../strings/strnatcmp.js"); function strnatcasecmp(...providedArgs) { // discuss at: https://locutus.io/php/strnatcasecmp/ // parity verified: PHP 8.3 // original by: Martin Pool // reimplemented by: Pierre-Luc Paour // reimplemented by: Kristof Coomans (SCK-CEN (Belgian Nucleair Research Centre)) // reimplemented by: Brett Zamir (https://brett-zamir.me) // bugfixed by: Kevin van Zonneveld (https://kvz.io) // input by: Devan Penner-Woelk // improved by: Kevin van Zonneveld (https://kvz.io) // reimplemented by: Rafał Kukawski // example 1: strnatcasecmp(10, 1) // returns 1: 1 // example 2: strnatcasecmp('1', '10') // returns 2: -1 if (providedArgs.length !== 2) { return null; } const [a, b] = providedArgs; return (0, strnatcmp_ts_1.strnatcmp)((0, _phpCastString_ts_1._phpCastString)(a).toLowerCase(), (0, _phpCastString_ts_1._phpCastString)(b).toLowerCase()); }