From 41f8d76968128659624e599822239ac382968808 Mon Sep 17 00:00:00 2001 From: Faisal Salman Date: Sat, 18 Mar 2023 10:38:03 +0700 Subject: [PATCH] Remove `is()` & `toString()` prototype from `getResult()` data --- src/ua-parser.js | 46 ++++++++++++++++++++++++---------------------- 1 file changed, 24 insertions(+), 22 deletions(-) diff --git a/src/ua-parser.js b/src/ua-parser.js index c017e8c..42ec24f 100755 --- a/src/ua-parser.js +++ b/src/ua-parser.js @@ -886,28 +886,6 @@ function UAParserData () { initialize.call(this, init_props); } - UAParserData.prototype.is = function (strToCheck) { - var is = false; - for (var i in this) { - if (this.hasOwnProperty(i) && !is_ignoreProps[i] && lowerize(this[i], is_ignoreRgx) === lowerize(strToCheck, is_ignoreRgx)) { - is = true; - if (strToCheck != UNDEF_TYPE) break; - } else if (strToCheck == UNDEF_TYPE && is) { - is = !is; - break; - } - } - return is; - }; - UAParserData.prototype.toString = function () { - var str = EMPTY; - for (var i in toString_props) { - if (typeof(this[toString_props[i]]) !== UNDEF_TYPE) { - str += (str ? ' ' : EMPTY) + this[toString_props[i]]; - } - } - return str ? str : UNDEF_TYPE; - }; UAParserData.prototype.withClientHints = function () { // nodejs / non-client-hints browsers @@ -968,6 +946,30 @@ } }); }; + if(itemType != UA_RESULT) { + UAParserData.prototype.is = function (strToCheck) { + var is = false; + for (var i in this) { + if (this.hasOwnProperty(i) && !is_ignoreProps[i] && lowerize(this[i], is_ignoreRgx) === lowerize(strToCheck, is_ignoreRgx)) { + is = true; + if (strToCheck != UNDEF_TYPE) break; + } else if (strToCheck == UNDEF_TYPE && is) { + is = !is; + break; + } + } + return is; + }; + UAParserData.prototype.toString = function () { + var str = EMPTY; + for (var i in toString_props) { + if (typeof(this[toString_props[i]]) !== UNDEF_TYPE) { + str += (str ? ' ' : EMPTY) + this[toString_props[i]]; + } + } + return str ? str : UNDEF_TYPE; + }; + } if (!NAVIGATOR_UADATA) { UAParserData.prototype.then = function (cb) { cb(this);