From e94ddeaca1e75ecc8f54ebcb3df222965e3635d1 Mon Sep 17 00:00:00 2001 From: Gar Date: Tue, 28 Sep 2021 10:05:08 -0700 Subject: deps: @npmcli/arborist@2.9.0 * fix: avoid infinite loops in peer dep replacements * fix: use Intl.Collator for string sorting when available * feat(vuln): expose isDirect --- .../@isaacs/string-locale-compare/index.js | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 node_modules/@isaacs/string-locale-compare/index.js (limited to 'node_modules/@isaacs/string-locale-compare/index.js') diff --git a/node_modules/@isaacs/string-locale-compare/index.js b/node_modules/@isaacs/string-locale-compare/index.js new file mode 100644 index 000000000..a6cec27ef --- /dev/null +++ b/node_modules/@isaacs/string-locale-compare/index.js @@ -0,0 +1,22 @@ +const hasIntl = typeof Intl === 'object' && !!Intl +const Collator = hasIntl && Intl.Collator +const cache = new Map() + +const collatorCompare = locale => { + const collator = new Collator(locale) + return (a, b) => collator.compare(a, b) +} + +const localeCompare = locale => (a, b) => a.localeCompare(b, locale) + +module.exports = locale => { + if (!locale || typeof locale !== 'string') + throw new TypeError('locale required') + + if (cache.has(locale)) + return cache.get(locale) + + const compare = hasIntl ? collatorCompare(locale) : localeCompare(locale) + cache.set(locale, compare) + return compare +} -- cgit v1.2.3