From 69741bf33fb8cd9e9b7da5fb936fa86e6df5cb25 Mon Sep 17 00:00:00 2001 From: Victor Saa Date: Wed, 19 Jun 2024 12:24:41 -0500 Subject: [PATCH] Support inverted media queries --- lib/create-sort.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/lib/create-sort.js b/lib/create-sort.js index 88bcaa5..b4a6d2d 100644 --- a/lib/create-sort.js +++ b/lib/create-sort.js @@ -89,12 +89,14 @@ function _testQuery(doubleTestTrue, doubleTestFalse, singleTest) { * @return {boolean} */ return function (query) { - if (doubleTestTrue.test(query)) { - return true; - } else if (doubleTestFalse.test(query)) { - return false; - } - return singleTest.test(query); + let result; + + if (doubleTestTrue.test(query)) result = true; + else if (doubleTestFalse.test(query)) result = false; + else result = singleTest.test(query); + + /** Not keyword inverts the whole query */ + return query.includes('not') ? !result : result; }; }