UNPKG

36.7 kBSource Map (JSON)View Raw
1{"version":3,"sources":["../src/utils.js"],"names":["unhomoglyph","require","module","exports","encodeParams","params","qs","key","hasOwnProperty","encodeURIComponent","substring","encodeUri","pathTemplate","variables","replace","map","array","fn","results","Array","length","i","filter","push","keys","obj","values","forEach","findElement","reverse","removeElement","removed","splice","isFunction","value","Object","prototype","toString","call","isArray","Boolean","constructor","checkObjectHasKeys","Error","checkObjectHasNoAdditionalKeys","allowedKeys","indexOf","deepCopy","JSON","parse","deepCompare","x","y","isNaN","RegExp","Date","p","extend","target","arguments","source","propName","runPolyfills","fun","TypeError","t","len","res","thisArg","val","callback","T","k","undefined","O","A","kValue","mappedValue","inherits","ctor","superCtor","create","Temp","hasOwn","Properties","prop","super_","enumerable","writable","configurable","isNumber","isFinite","removeHiddenChars","str","normalize","removeHiddenCharsRegex","escapeRegExp","string","globToRegexp","glob","extended","pat","match","p1","p2","offset","first","second"],"mappings":"AAAA;;;;;;;;;;;;;;;AAeA;AACA;;;;;;;;;;;;;;;;;;;AAKA,IAAMA,cAAcC,QAAQ,aAAR,CAApB;;AAEA;;;;;;AAMAC,OAAOC,OAAP,CAAeC,YAAf,GAA8B,UAASC,MAAT,EAAiB;AAC3C,QAAIC,KAAK,EAAT;AACA,SAAK,IAAMC,GAAX,IAAkBF,MAAlB,EAA0B;AACtB,YAAI,CAACA,OAAOG,cAAP,CAAsBD,GAAtB,CAAL,EAAiC;AAC7B;AACH;AACDD,cAAM,MAAMG,mBAAmBF,GAAnB,CAAN,GAAgC,GAAhC,GACEE,mBAAmBJ,OAAOE,GAAP,CAAnB,CADR;AAEH;AACD,WAAOD,GAAGI,SAAH,CAAa,CAAb,CAAP;AACH,CAVD;;AAYA;;;;;;;;AAQAR,OAAOC,OAAP,CAAeQ,SAAf,GAA2B,UAASC,YAAT,EAAuBC,SAAvB,EAAkC;AACzD,SAAK,IAAMN,GAAX,IAAkBM,SAAlB,EAA6B;AACzB,YAAI,CAACA,UAAUL,cAAV,CAA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ltd\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\"use strict\";\n/**\n * This is an internal module.\n * @module utils\n */\n\nconst unhomoglyph = require('unhomoglyph');\n\n/**\n * Encode a dictionary of query parameters.\n * @param {Object} params A dict of key/values to encode e.g.\n * {\"foo\": \"bar\", \"baz\": \"taz\"}\n * @return {string} The encoded string e.g. foo=bar&baz=taz\n */\nmodule.exports.encodeParams = function(params) {\n let qs = \"\";\n for (const key in params) {\n if (!params.hasOwnProperty(key)) {\n continue;\n }\n qs += \"&\" + encodeURIComponent(key) + \"=\" +\n encodeURIComponent(params[key]);\n }\n return qs.substring(1);\n};\n\n/**\n * Encodes a URI according to a set of template variables. Variables will be\n * passed through encodeURIComponent.\n * @param {string} pathTemplate The path with template variables e.g. '/foo/$bar'.\n * @param {Object} variables The key/value pairs to replace the template\n * variables with. E.g. { \"$bar\": \"baz\" }.\n * @return {string} The result of replacing all template variables e.g. '/foo/baz'.\n */\nmodule.exports.encodeUri = function(pathTemplate, variables) {\n for (const key in variables) {\n if (!variables.hasOwnProperty(key)) {\n continue;\n }\n pathTemplate = pathTemplate.replace(\n key, encodeURIComponent(variables[key]),\n );\n }\n return pathTemplate;\n};\n\n/**\n * Applies a map function to the given array.\n * @param {Array} array The array to apply the function to.\n * @param {Function} fn The function that will be invoked for each element in\n * the array with the signature <code>fn(element){...}</code>\n * @return {Array} A new array with the results of the function.\n */\nmodule.exports.map = function(array, fn) {\n const results = new Array(array.length);\n for (let i = 0; i < array.length; i++) {\n results[i] = fn(array[i]);\n }\n return results;\n};\n\n/**\n * Applies a filter function to the given array.\n * @param {Array} array The array to apply the function to.\n * @param {Function} fn The function that will be invoked for each element in\n * the array. It should return true to keep the element. The function signature\n * looks like <code>fn(element, index, array){...}</code>.\n * @return {Array} A new array with the results of the function.\n */\nmodule.exports.filter = function(array, fn) {\n const results = [];\n for (let i = 0; i < array.length; i++) {\n if (fn(array[i], i, array)) {\n results.push(array[i]);\n }\n }\n return results;\n};\n\n/**\n * Get the keys for an object. Same as <code>Object.keys()</code>.\n * @param {Object} obj The object to get the keys for.\n * @return {string[]} The keys of the object.\n */\nmodule.exports.keys = function(obj) {\n const keys = [];\n for (const key in obj) {\n if (!obj.hasOwnProperty(key)) {\n continue;\n }\n keys.push(key);\n }\n return keys;\n};\n\n/**\n * Get the values for an object.\n * @param {Object} obj The object to get the values for.\n * @return {Array<*>} The values of the object.\n */\nmodule.exports.values = function(obj) {\n const values = [];\n for (const key in obj) {\n if (!obj.hasOwnProperty(key)) {\n continue;\n }\n values.push(obj[key]);\n }\n return values;\n};\n\n/**\n * Invoke a function for each item in the array.\n * @param {Array} array The array.\n * @param {Function} fn The function to invoke for each element. Has the\n * function signature <code>fn(element, index)</code>.\n */\nmodule.exports.forEach = function(array, fn) {\n for (let i = 0; i < array.length; i++) {\n fn(array[i], i);\n }\n};\n\n/**\n * The findElement() method returns a value in the array, if an element in the array\n * satisfies (returns true) the provided testing function. Otherwise undefined\n * is returned.\n * @param {Array} array The array.\n * @param {Function} fn Function to execute on each value in the array, with the\n * function signature <code>fn(element, index, array)</code>\n * @param {boolean} reverse True to search in reverse order.\n * @return {*} The first value in the array which returns <code>true</code> for\n * the given function.\n */\nmodule.exports.findElement = function(array, fn, reverse) {\n let i;\n if (reverse) {\n for (i = array.length - 1; i >= 0; i--) {\n if (fn(array[i], i, array)) {\n return array[i];\n }\n }\n } else {\n for (i = 0; i < array.length; i++) {\n if (fn(array[i], i, array)) {\n return array[i];\n }\n }\n }\n};\n\n/**\n * The removeElement() method removes the first element in the array that\n * satisfies (returns true) the provided testing function.\n * @param {Array} array The array.\n * @param {Function} fn Function to execute on each value in the array, with the\n * function signature <code>fn(element, index, array)</code>. Return true to\n * remove this element and break.\n * @param {boolean} reverse True to search in reverse order.\n * @return {boolean} True if an element was removed.\n */\nmodule.exports.removeElement = function(array, fn, reverse) {\n let i;\n let removed;\n if (reverse) {\n for (i = array.length - 1; i >= 0; i--) {\n if (fn(array[i], i, array)) {\n removed = array[i];\n array.splice(i, 1);\n return removed;\n }\n }\n } else {\n for (i = 0; i < array.length; i++) {\n if (fn(array[i], i, array)) {\n removed = array[i];\n array.splice(i, 1);\n return removed;\n }\n }\n }\n return false;\n};\n\n/**\n * Checks if the given thing is a function.\n * @param {*} value The thing to check.\n * @return {boolean} True if it is a function.\n */\nmodule.exports.isFunction = function(value) {\n return Object.prototype.toString.call(value) == \"[object Function]\";\n};\n\n/**\n * Checks if the given thing is an array.\n * @param {*} value The thing to check.\n * @return {boolean} True if it is an array.\n */\nmodule.exports.isArray = function(value) {\n return Array.isArray ? Array.isArray(value) :\n Boolean(value && value.constructor === Array);\n};\n\n/**\n * Checks that the given object has the specified keys.\n * @param {Object} obj The object to check.\n * @param {string[]} keys The list of keys that 'obj' must have.\n * @throws If the object is missing keys.\n */\nmodule.exports.checkObjectHasKeys = function(obj, keys) {\n for (let i = 0; i < keys.length; i++) {\n if (!obj.hasOwnProperty(keys[i])) {\n throw new Error(\"Missing required key: \" + keys[i]);\n }\n }\n};\n\n/**\n * Checks that the given object has no extra keys other than the specified ones.\n * @param {Object} obj The object to check.\n * @param {string[]} allowedKeys The list of allowed key names.\n * @throws If there are extra keys.\n */\nmodule.exports.checkObjectHasNoAdditionalKeys = function(obj, allowedKeys) {\n for (const key in obj) {\n if (!obj.hasOwnProperty(key)) {\n continue;\n }\n if (allowedKeys.indexOf(key) === -1) {\n throw new Error(\"Unknown key: \" + key);\n }\n }\n};\n\n/**\n * Deep copy the given object. The object MUST NOT have circular references and\n * MUST NOT have functions.\n * @param {Object} obj The object to deep copy.\n * @return {Object} A copy of the object without any references to the original.\n */\nmodule.exports.deepCopy = function(obj) {\n return JSON.parse(JSON.stringify(obj));\n};\n\n/**\n * Compare two objects for equality. The objects MUST NOT have circular references.\n *\n * @param {Object} x The first object to compare.\n * @param {Object} y The second object to compare.\n *\n * @return {boolean} true if the two objects are equal\n */\nconst deepCompare = module.exports.deepCompare = function(x, y) {\n // Inspired by\n // http://stackoverflow.com/questions/1068834/object-comparison-in-javascript#1144249\n\n // Compare primitives and functions.\n // Also check if both arguments link to the same object.\n if (x === y) {\n return true;\n }\n\n if (typeof x !== typeof y) {\n return false;\n }\n\n // special-case NaN (since NaN !== NaN)\n if (typeof x === 'number' && isNaN(x) && isNaN(y)) {\n return true;\n }\n\n // special-case null (since typeof null == 'object', but null.constructor\n // throws)\n if (x === null || y === null) {\n return x === y;\n }\n\n // everything else is either an unequal primitive, or an object\n if (!(x instanceof Object)) {\n return false;\n }\n\n // check they are the same type of object\n if (x.constructor !== y.constructor || x.prototype !== y.prototype) {\n return false;\n }\n\n // special-casing for some special types of object\n if (x instanceof RegExp || x instanceof Date) {\n return x.toString() === y.toString();\n }\n\n // the object algorithm works for Array, but it's sub-optimal.\n if (x instanceof Array) {\n if (x.length !== y.length) {\n return false;\n }\n\n for (let i = 0; i < x.length; i++) {\n if (!deepCompare(x[i], y[i])) {\n return false;\n }\n }\n } else {\n // disable jshint \"The body of a for in should be wrapped in an if\n // statement\"\n /* jshint -W089 */\n\n // check that all of y's direct keys are in x\n let p;\n for (p in y) {\n if (y.hasOwnProperty(p) !== x.hasOwnProperty(p)) {\n return false;\n }\n }\n\n // finally, compare each of x's keys with y\n for (p in y) { // eslint-disable-line guard-for-in\n if (y.hasOwnProperty(p) !== x.hasOwnProperty(p)) {\n return false;\n }\n if (!deepCompare(x[p], y[p])) {\n return false;\n }\n }\n }\n /* jshint +W089 */\n return true;\n};\n\n/**\n * Copy properties from one object to another.\n *\n * All enumerable properties, included inherited ones, are copied.\n *\n * This is approximately equivalent to ES6's Object.assign, except\n * that the latter doesn't copy inherited properties.\n *\n * @param {Object} target The object that will receive new properties\n * @param {...Object} source Objects from which to copy properties\n *\n * @return {Object} target\n */\nmodule.exports.extend = function() {\n const target = arguments[0] || {};\n for (let i = 1; i < arguments.length; i++) {\n const source = arguments[i];\n for (const propName in source) { // eslint-disable-line guard-for-in\n target[propName] = source[propName];\n }\n }\n return target;\n};\n\n/**\n * Run polyfills to add Array.map and Array.filter if they are missing.\n */\nmodule.exports.runPolyfills = function() {\n // Array.prototype.filter\n // ========================================================\n // SOURCE:\n // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter\n if (!Array.prototype.filter) {\n Array.prototype.filter = function(fun/*, thisArg*/) {\n if (this === void 0 || this === null) {\n throw new TypeError();\n }\n\n const t = Object(this);\n const len = t.length >>> 0;\n if (typeof fun !== 'function') {\n throw new TypeError();\n }\n\n const res = [];\n const thisArg = arguments.length >= 2 ? arguments[1] : void 0;\n for (let i = 0; i < len; i++) {\n if (i in t) {\n const val = t[i];\n\n // NOTE: Technically this should Object.defineProperty at\n // the next index, as push can be affected by\n // properties on Object.prototype and Array.prototype.\n // But that method's new, and collisions should be\n // rare, so use the more-compatible alternative.\n if (fun.call(thisArg, val, i, t)) {\n res.push(val);\n }\n }\n }\n\n return res;\n };\n }\n\n // Array.prototype.map\n // ========================================================\n // SOURCE:\n // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map\n // Production steps of ECMA-262, Edition 5, 15.4.4.19\n // Reference: http://es5.github.io/#x15.4.4.19\n if (!Array.prototype.map) {\n Array.prototype.map = function(callback, thisArg) {\n let T, k;\n\n if (this === null || this === undefined) {\n throw new TypeError(' this is null or not defined');\n }\n\n // 1. Let O be the result of calling ToObject passing the |this|\n // value as the argument.\n const O = Object(this);\n\n // 2. Let lenValue be the result of calling the Get internal\n // method of O with the argument \"length\".\n // 3. Let len be ToUint32(lenValue).\n const len = O.length >>> 0;\n\n // 4. If IsCallable(callback) is false, throw a TypeError exception.\n // See: http://es5.github.com/#x9.11\n if (typeof callback !== 'function') {\n throw new TypeError(callback + ' is not a function');\n }\n\n // 5. If thisArg was supplied, let T be thisArg; else let T be undefined.\n if (arguments.length > 1) {\n T = thisArg;\n }\n\n // 6. Let A be a new array created as if by the expression new Array(len)\n // where Array is the standard built-in constructor with that name and\n // len is the value of len.\n const A = new Array(len);\n\n // 7. Let k be 0\n k = 0;\n\n // 8. Repeat, while k < len\n while (k < len) {\n var kValue, mappedValue;\n\n // a. Let Pk be ToString(k).\n // This is implicit for LHS operands of the in operator\n // b. Let kPresent be the result of calling the HasProperty internal\n // method of O with argument Pk.\n // This step can be combined with c\n // c. If kPresent is true, then\n if (k in O) {\n // i. Let kValue be the result of calling the Get internal\n // method of O with argument Pk.\n kValue = O[k];\n\n // ii. Let mappedValue be the result of calling the Call internal\n // method of callback with T as the this value and argument\n // list containing kValue, k, and O.\n mappedValue = callback.call(T, kValue, k, O);\n\n // iii. Call the DefineOwnProperty internal method of A with arguments\n // Pk, Property Descriptor\n // { Value: mappedValue,\n // Writable: true,\n // Enumerable: true,\n // Configurable: true },\n // and false.\n\n // In browsers that support Object.defineProperty, use the following:\n // Object.defineProperty(A, k, {\n // value: mappedValue,\n // writable: true,\n // enumerable: true,\n // configurable: true\n // });\n\n // For best browser support, use the following:\n A[k] = mappedValue;\n }\n // d. Increase k by 1.\n k++;\n }\n\n // 9. return A\n return A;\n };\n }\n\n // Array.prototype.forEach\n // ========================================================\n // SOURCE:\n // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/forEach\n // Production steps of ECMA-262, Edition 5, 15.4.4.18\n // Reference: http://es5.github.io/#x15.4.4.18\n if (!Array.prototype.forEach) {\n Array.prototype.forEach = function(callback, thisArg) {\n let T, k;\n\n if (this === null || this === undefined) {\n throw new TypeError(' this is null or not defined');\n }\n\n // 1. Let O be the result of calling ToObject passing the |this| value as the\n // argument.\n const O = Object(this);\n\n // 2. Let lenValue be the result of calling the Get internal method of O with the\n // argument \"length\".\n // 3. Let len be ToUint32(lenValue).\n const len = O.length >>> 0;\n\n // 4. If IsCallable(callback) is false, throw a TypeError exception.\n // See: http://es5.github.com/#x9.11\n if (typeof callback !== \"function\") {\n throw new TypeError(callback + ' is not a function');\n }\n\n // 5. If thisArg was supplied, let T be thisArg; else let T be undefined.\n if (arguments.length > 1) {\n T = thisArg;\n }\n\n // 6. Let k be 0\n k = 0;\n\n // 7. Repeat, while k < len\n while (k < len) {\n var kValue;\n\n // a. Let Pk be ToString(k).\n // This is implicit for LHS operands of the in operator\n // b. Let kPresent be the result of calling the HasProperty internal\n // method of O with\n // argument Pk.\n // This step can be combined with c\n // c. If kPresent is true, then\n if (k in O) {\n // i. Let kValue be the result of calling the Get internal method of O with\n // argument Pk\n kValue = O[k];\n\n // ii. Call the Call internal method of callback with T as the this value and\n // argument list containing kValue, k, and O.\n callback.call(T, kValue, k, O);\n }\n // d. Increase k by 1.\n k++;\n }\n // 8. return undefined\n };\n }\n};\n\n/**\n * Inherit the prototype methods from one constructor into another. This is a\n * port of the Node.js implementation with an Object.create polyfill.\n *\n * @param {function} ctor Constructor function which needs to inherit the\n * prototype.\n * @param {function} superCtor Constructor function to inherit prototype from.\n */\nmodule.exports.inherits = function(ctor, superCtor) {\n // Add Object.create polyfill for IE8\n // Source:\n // https://developer.mozilla.org/en-US/docs/Web/JavaScript\n // /Reference/Global_Objects/Object/create#Polyfill\n if (typeof Object.create != 'function') {\n // Production steps of ECMA-262, Edition 5, 15.2.3.5\n // Reference: http://es5.github.io/#x15.2.3.5\n Object.create = (function() {\n // To save on memory, use a shared constructor\n function Temp() {}\n\n // make a safe reference to Object.prototype.hasOwnProperty\n const hasOwn = Object.prototype.hasOwnProperty;\n\n return function(O) {\n // 1. If Type(O) is not Object or Null throw a TypeError exception.\n if (typeof O != 'object') {\n throw new TypeError('Object prototype may only be an Object or null');\n }\n\n // 2. Let obj be the result of creating a new object as if by the\n // expression new Object() where Object is the standard built-in\n // constructor with that name\n // 3. Set the [[Prototype]] internal property of obj to O.\n Temp.prototype = O;\n const obj = new Temp();\n Temp.prototype = null; // Let's not keep a stray reference to O...\n\n // 4. If the argument Properties is present and not undefined, add\n // own properties to obj as if by calling the standard built-in\n // function Object.defineProperties with arguments obj and\n // Properties.\n if (arguments.length > 1) {\n // Object.defineProperties does ToObject on its first argument.\n const Properties = Object(arguments[1]);\n for (const prop in Properties) {\n if (hasOwn.call(Properties, prop)) {\n obj[prop] = Properties[prop];\n }\n }\n }\n\n // 5. Return obj\n return obj;\n };\n })();\n }\n // END polyfill\n\n // Add util.inherits from Node.js\n // Source:\n // https://github.com/joyent/node/blob/master/lib/util.js\n // Copyright Joyent, Inc. and other Node contributors.\n //\n // Permission is hereby granted, free of charge, to any person obtaining a\n // copy of this software and associated documentation files (the\n // \"Software\"), to deal in the Software without restriction, including\n // without limitation the rights to use, copy, modify, merge, publish,\n // distribute, sublicense, and/or sell copies of the Software, and to permit\n // persons to whom the Software is furnished to do so, subject to the\n // following conditions:\n //\n // The above copyright notice and this permission notice shall be included\n // in all copies or substantial portions of the Software.\n //\n // THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN\n // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\n // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE\n // USE OR OTHER DEALINGS IN THE SOFTWARE.\n ctor.super_ = superCtor;\n ctor.prototype = Object.create(superCtor.prototype, {\n constructor: {\n value: ctor,\n enumerable: false,\n writable: true,\n configurable: true,\n },\n });\n};\n\n/**\n * Returns whether the given value is a finite number without type-coercion\n *\n * @param {*} value the value to test\n * @return {boolean} whether or not value is a finite number without type-coercion\n */\nmodule.exports.isNumber = function(value) {\n return typeof value === 'number' && isFinite(value);\n};\n\n/**\n * Removes zero width chars, diacritics and whitespace from the string\n * Also applies an unhomoglyph on the string, to prevent similar looking chars\n * @param {string} str the string to remove hidden characters from\n * @return {string} a string with the hidden characters removed\n */\nmodule.exports.removeHiddenChars = function(str) {\n return unhomoglyph(str.normalize('NFD').replace(removeHiddenCharsRegex, ''));\n};\nconst removeHiddenCharsRegex = /[\\u200B-\\u200D\\u0300-\\u036f\\uFEFF\\s]/g;\n\nfunction escapeRegExp(string) {\n return string.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\");\n}\nmodule.exports.escapeRegExp = escapeRegExp;\n\nmodule.exports.globToRegexp = function(glob, extended) {\n extended = typeof(extended) === 'boolean' ? extended : true;\n // From\n // https://github.com/matrix-org/synapse/blob/abbee6b29be80a77e05730707602f3bbfc3f38cb/synapse/push/__init__.py#L132\n // Because micromatch is about 130KB with dependencies,\n // and minimatch is not much better.\n let pat = escapeRegExp(glob);\n pat = pat.replace(/\\\\\\*/g, '.*');\n pat = pat.replace(/\\?/g, '.');\n if (extended) {\n pat = pat.replace(/\\\\\\[(!|)(.*)\\\\]/g, function(match, p1, p2, offset, string) {\n const first = p1 && '^' || '';\n const second = p2.replace(/\\\\-/, '-');\n return '[' + first + second + ']';\n });\n }\n return pat;\n};\n"]}
\No newline at end of file