diff options
Diffstat (limited to 'js/src/Ice/IdentityUtil.js')
-rw-r--r-- | js/src/Ice/IdentityUtil.js | 59 |
1 files changed, 24 insertions, 35 deletions
diff --git a/js/src/Ice/IdentityUtil.js b/js/src/Ice/IdentityUtil.js index 87ee2c1b55e..1d5b79a4a51 100644 --- a/js/src/Ice/IdentityUtil.js +++ b/js/src/Ice/IdentityUtil.js @@ -7,12 +7,12 @@ // // ********************************************************************** -var Ice = require("../Ice/ModuleRegistry").Ice; +const Ice = require("../Ice/ModuleRegistry").Ice; Ice.__M.require(module, [ "../Ice/StringUtil", "../Ice/Identity", "../Ice/LocalException"]); -var StringUtil = Ice.StringUtil; -var Identity = Ice.Identity; -var IdentityParseException = Ice.IdentityParseException; +const StringUtil = Ice.StringUtil; +const Identity = Ice.Identity; +const IdentityParseException = Ice.IdentityParseException; /** * Converts a string to an object identity. @@ -23,17 +23,17 @@ var IdentityParseException = Ice.IdentityParseException; **/ Ice.stringToIdentity = function(s) { - var ident = new Identity(); + const ident = new Identity(); // // Find unescaped separator; note that the string may contain an escaped // backslash before the separator. // - var slash = -1; - var pos = 0; + let slash = -1; + let pos = 0; while((pos = s.indexOf('/', pos)) !== -1) { - var escapes = 0; + let escapes = 0; while(pos - escapes > 0 && s.charAt(pos - escapes - 1) == '\\') { escapes++; @@ -53,9 +53,7 @@ Ice.stringToIdentity = function(s) // // Extra unescaped slash found. // - var ex = new IdentityParseException(); - ex.str = "unescaped backslash in identity `" + s + "'"; - throw ex; + throw new IdentityParseException(`unescaped backslash in identity \`${s}'`); } } pos++; @@ -70,9 +68,7 @@ Ice.stringToIdentity = function(s) } catch(e) { - var ex = new IdentityParseException(); - ex.str = "invalid identity name `" + s + "': " + ex.toString(); - throw ex; + throw new IdentityParseException(`invalid identity name \`${s}': ${e.toString()}`); } } else @@ -83,9 +79,7 @@ Ice.stringToIdentity = function(s) } catch(e) { - var ex = new IdentityParseException(); - ex.str = "invalid category in identity `" + s + "': " + ex.toString(); - throw ex; + throw new IdentityParseException(`invalid category in identity \`${s}': ${e.toString()}`); } if(slash + 1 < s.length) { @@ -95,9 +89,7 @@ Ice.stringToIdentity = function(s) } catch(e) { - var ex = new IdentityParseException(); - ex.str = "invalid name in identity `" + s + "': " + ex.toString(); - throw ex; + throw new IdentityParseException(`invalid name in identity \`${s}': ${e.toString()}`); } } else @@ -157,14 +149,10 @@ Ice.proxyIdentityCompare = function(lhs, rhs) } else { - var lhsIdentity = lhs.ice_getIdentity(); - var rhsIdentity = rhs.ice_getIdentity(); - var n; - if((n = lhsIdentity.name.localeCompare(rhsIdentity.name)) !== 0) - { - return n; - } - return lhsIdentity.category.localeCompare(rhsIdentity.category); + const lhsIdentity = lhs.ice_getIdentity(); + const rhsIdentity = rhs.ice_getIdentity(); + const n = lhsIdentity.name.localeCompare(rhsIdentity.name); + return (n !== 0) ? n : lhsIdentity.category.localeCompare(rhsIdentity.category); } }; @@ -197,20 +185,21 @@ Ice.proxyIdentityAndFacetCompare = function(lhs, rhs) } else { - var lhsIdentity = lhs.ice_getIdentity(); - var rhsIdentity = rhs.ice_getIdentity(); - var n; - if((n = lhsIdentity.name.localeCompare(rhsIdentity.name)) !== 0) + const lhsIdentity = lhs.ice_getIdentity(); + const rhsIdentity = rhs.ice_getIdentity(); + let n = lhsIdentity.name.localeCompare(rhsIdentity.name); + if(n !== 0) { return n; } - if((n = lhsIdentity.category.localeCompare(rhsIdentity.category)) !== 0) + n = lhsIdentity.category.localeCompare(rhsIdentity.category); + if(n !== 0) { return n; } - var lhsFacet = lhs.ice_getFacet(); - var rhsFacet = rhs.ice_getFacet(); + const lhsFacet = lhs.ice_getFacet(); + const rhsFacet = rhs.ice_getFacet(); if(lhsFacet === null && rhsFacet === null) { return 0; |