{"version":3,"file":"utils-BfU0COqs.js","sources":["../../app/javascript/utils/utils.js"],"sourcesContent":["/**\n * \"Utils\" modules are considered an anti-pattern, for good reason. Do your best to avoid adding to\n * this file :). To belong here, a method must be extremely generic, and fulfill a need not already\n * addressed by JavaScript's standard library or Lodash.\n */\n\nimport _ from \"lodash\";\n\n/**\n * Private function. (Not exported.) Returns a new object where each key in the object, recursively, is replaced with\n * callback(key).\n * NOTE: This object retains arrays as arrays, and does not try to map them into {: } objects.\n * See https://github.com/lodash/lodash/issues/1244.\n * @param {Object}\n * @return {Function}\n */\nfunction mapKeysDeep(object, callback) {\n return _.mapValues(_.mapKeys(object, callback), (value) =>\n _.isObject(value) && !Array.isArray(value) ? mapKeysDeep(value, callback) : value\n );\n}\n\n/**\n * @param {Object}\n * @param {Boolean} If true, camelize all keys in the object recursively. If false, camelize only\n * the top layer. Defaults to true.\n * @return {Object} The input, but with its keys in camelCase. (We run _.camelCase on each key.)\n */\nfunction withKeysCamelized(object, deep = true) {\n if (deep) {\n return mapKeysDeep(object, (_value, key) => _.camelCase(key));\n } else {\n return _.mapKeys(object, (_value, key) => _.camelCase(key));\n }\n}\n\nexport { withKeysCamelized };\n"],"names":["mapKeysDeep","object","callback","_","value","withKeysCamelized","deep","_value","key"],"mappings":"qaAgBA,SAASA,EAAYC,EAAQC,EAAU,CACrC,OAAOC,EAAE,UAAUA,EAAE,QAAQF,EAAQC,CAAQ,EAAIE,GAC/CD,EAAE,SAASC,CAAK,GAAK,CAAC,MAAM,QAAQA,CAAK,EAAIJ,EAAYI,EAAOF,CAAQ,EAAIE,CAC7E,CACH,CAQA,SAASC,EAAkBJ,EAAQK,EAAO,GAAM,CAC9C,OAAIA,EACKN,EAAYC,EAAQ,CAACM,EAAQC,IAAQL,EAAE,UAAUK,CAAG,CAAC,EAErDL,EAAE,QAAQF,EAAQ,CAACM,EAAQC,IAAQL,EAAE,UAAUK,CAAG,CAAC,CAE9D"}