Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 928x 928x 928x 928x 1x 1x 1x 1x 1x 904x 904x 904x 904x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 938x 10x 10x 938x 6x 6x 938x 18x 18x 938x 163x 163x 741x 741x 741x 1x 1x | const queryTransformer = require('./queryTransformer'); /** * Checks whether element is a wildcard */ const isElementWildcard = (element) => ['*', '{$all}', '{*}'].indexOf(element) > -1; /** * Checks whether element is a number */ const isNumberNumber = (element) => !Number.isNaN(Number(element)); /** * Checks whether element is of type string */ const isElementString = (element) => element && typeof element === 'string'; /** * Checks whether element is a query (surrounded by quotes) */ const isStringString = (element) => { const firstChar = element.charAt(0); const lastChar = element.charAt(element.length - 1); return (firstChar === lastChar && (firstChar === '"' || firstChar === "'")); }; /** * Checks whether element is a query (surrounded by curly brackets) */ const isQueryQuery = (element) => { const firstChar = element.charAt(0); const lastChar = element.charAt(element.length - 1); return (firstChar === '{' && lastChar === '}'); }; /** * Removes opening and closing characters from string */ const removeOpeningClosingChars = (element) => element.substr(1, element.length - 2); /** * Transforms each element of path into workable object representation * @param {String} element - string representation of path element * @param {Object} funcs - object with functions provided by the user that may be part of the query * @returns {Object} - object with keyName the type of element and keyValue the value of element */ // eslint-disable-next-line complexity const elementTransformer = (element, funcs) => { if (isElementWildcard(element)) { return { wildcard: true }; } if (isElementString(element) && isStringString(element)) { return { string: removeOpeningClosingChars(element) }; } if (isNumberNumber(element)) { return { number: Number(element) }; } if (isElementString(element) && isQueryQuery(element)) { return { query: queryTransformer(removeOpeningClosingChars(element), funcs) }; } return { string: element }; }; module.exports = elementTransformer; |