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B,OADA,EAAK,OAAS,EACP,CACT,CAEF,GAAE,KAAK","file":"/npm/dryify@0.1.4/dryify.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/dryify@0.1.4/dryify.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","//---------------------------------------------------------------------------\n// @license\n// dryify 0.1.0 (Custom Build) <https://github.com/brilliantmichael/dryify/>\n// Copyright 2015 Michael Isidro\n// Available under ISC license <http://opensource.org/licenses/ISC>\n//---------------------------------------------------------------------------\n(function() {\n\n  \"use strict\";\n\n  var self = this; // equivalent to @window in the browser\n  var olderDryify = self.dryify;\n  var dryify = (function() {\n\n    // http://stackoverflow.com/a/8580611\n    function Dryify() {\n      if (arguments.length) {\n        throw new Error('Dryify expects a call to a method');\n      }\n    }\n\n    // Private methods\n\n    //-----------------------------------------------------------------------\n    // Ripped from lodash\n    //\n    // Required\n    // --------\n    // @array - array - an array to remove falsy elements from\n    //-----------------------------------------------------------------------\n    function _compact(array) {\n\n      var index = -1;\n      var length = array ? array.length : 0;\n      var resIndex = -1;\n      var result = [];\n\n      while (++index < length) {\n        var value = array[index];\n        if (value) {\n          result[++resIndex] = value;\n        }\n      }\n      return result;\n    };\n\n    //-----------------------------------------------------------------------\n    // Extracts @fn's parameter names as strings in an array\n    //\n    // Required\n    // --------\n    // @fn - function - the function to get the parameter names from\n    //-----------------------------------------------------------------------\n    function _getFunctionParameterNames(fn) {\n\n      // http://stackoverflow.com/a/9924463\n      var fnStr = fn.toString();\n\n      return fnStr\n        .slice(\n          fnStr.indexOf(\"(\") + 1,\n          fnStr.indexOf(\")\")\n        )\n        .match(/([^\\s,]+)/g) || [];\n    };\n\n    //-----------------------------------------------------------------------\n    // Translates a JSON path string into an array of key references\n    // Used internally by @getval, @setval\n    //\n    // Required\n    // --------\n    // @jsonPath - string - the path string\n    //                      The convention uses strings like:\n    //                      \"[3].key1[2].key2\"\n    //                      \"key1.key2[1]\"\n    //                      etc...\n    //-----------------------------------------------------------------------\n    function _interpretJsonPath(jsonPath) {\n\n      if (typeof jsonPath === 'string') {\n        if (jsonPath) {\n\n          jsonPath = _compact(jsonPath.split(/[\\]\\.]+|\\[|\\]/g));\n\n          for (\n            var i = 0, path; i < jsonPath.length; i++\n          ) {\n\n            path = jsonPath[i];\n\n            if (!isNaN(path)) {\n              path = parseInt(path);\n            }\n          }\n        } else {\n          jsonPath = [];\n        }\n      } else {\n        throw Error(\n          \"@jsonPath must be a string. Type is [\" + (typeof jsonPath) + \"]\"\n        );\n      }\n\n      return jsonPath;\n    };\n\n    //-------------------------------------------------------------------------\n    //\n    // \"The prototype mechanism is used for inheritance. It also conserves\n    // memory\"\n    // http://javascript.crockford.com/private.html\n    //\n    // Takes a single argument - a function - and converts it into the same\n    // function that can take the arguments in the form of an 'options' object\n    //\n    // Required\n    // --------\n    // @fn - function - the function to convert into an equivalent function\n    //                  that accepts a single options object instead of\n    //                  multiple parameter arguments\n    //\n    // Optional\n    // --------\n    // @orderedParamNames - array - an array of strings specifying the names\n    //                              (and ordering) of acceptable keys as\n    //                              parameters. Usually used if a function has\n    //                              been minified and the options object keys\n    //                              don't match the real parameter names, in\n    //                              which case we rely on ordering\n    //-------------------------------------------------------------------------\n    Dryify.prototype.optionify = function(fn, orderedParamNames) {\n\n      var self = this; // Whatever calls this function will serve as @this\n\n      if (typeof fn !== 'function') {\n        throw Error(\n          \"@fn must take a function argument. Type is [\" + (typeof fn) + \"]\"\n        );\n      }\n\n      return function(options) {\n\n        // In the case where the function has been minified and the parameter\n        // names differ from the original keys used in the options object,\n        // you can no longer obtain the argument values without providing the\n        // @orderParamNames array\n\n        var argsToApply = [];\n        var opnLength;\n\n        if (!(orderedParamNames instanceof Array)) {\n          // Only use regex to get the param names if they have not been\n          // supplied\n          orderedParamNames = _getFunctionParameterNames(fn);\n        }\n\n        opnLength = orderedParamNames.length;\n\n        // Keys can possibly be iterated in any order. In the event the names\n        // don't match, we assume the ordering provided in @orderParamNames\n        // maps to the parameters required in the function\n\n        while (opnLength--) {\n          argsToApply[opnLength] = options[orderedParamNames[opnLength]];\n        }\n\n        return fn.apply(\n          self, // pass the outer context provided as @this into the function\n          argsToApply\n        );\n      };\n    };\n\n    //-------------------------------------------------------------------------\n    // Allows the elegant retrieval of a JSON value using a starting reference,\n    // an evaluated string, and a configurable return value or behaviour when\n    // not found.\n    //\n    // Saves you from the repitition of multiple levels of 'if... exists...'\n    //\n    // Required\n    // --------\n    // @startingReference - object  - the referenced JS object\n    // @jsonPath          - string  - a string that evaluates to a path deep\n    //                                into the object, saving you from having\n    //                                to check if it exists at each step of the\n    //                                path.\n    //\n    //                                The convention uses strings like:\n    //                                \"[3].key1[2].key2\"\n    //                                \"key1.key2[1]\"\n    //                                etc...\n    //\n    // Optional\n    // --------\n    // @ifNull            - [any type, function] - if the path is not found,\n    //                    returns this if not a function, or if a function,\n    //                    calls the function\n    //-------------------------------------------------------------------------\n    Dryify.prototype.getval = function(startingReference, jsonPath, ifNull) {\n\n      function notFound(ifNull) {\n        if (typeof ifNull !== 'function') {\n          return ifNull || null; // prevent empty errors being thrown upstream\n        } else {\n          return ifNull();\n        }\n      }\n\n      jsonPath = _interpretJsonPath(jsonPath);\n\n      if (!startingReference) {\n        return notFound(ifNull);\n      }\n      // This loop has to ascend\n      for (\n        var i = 0, path; i < jsonPath.length; i++\n      ) {\n\n        path = jsonPath[i];\n\n        if (!startingReference ||\n          typeof startingReference[path] === 'undefined' ||\n          typeof startingReference[path] === null\n        ) {\n          return notFound(ifNull);\n        } else {\n          startingReference = startingReference[path];\n        }\n      }\n\n      return startingReference;\n\n    };\n\n    //-------------------------------------------------------------------------\n    // Allows the elegant setting of a JSON value using a starting reference,\n    // an evaluated string, and a configurable return value or behaviour when\n    // not found.\n    //\n    // Saves you from the repitition of multiple levels of 'if... exists...'\n    //\n    // Required\n    // --------\n    // @startingReference - object  - the referenced JS object\n    // @jsonPath          - string  - a string that evaluates to a path deep\n    //                                into the object, saving you from having\n    //                                to check if it exists at each step of the\n    //                                path.\n    //\n    //                                The convention uses strings like:\n    //                                \"[3].key1[2].key2\"\n    //                                \"key1.key2[1]\"\n    //                                etc...\n    //\n    // @value             - [any]   - the value to assign\n    //\n    // Optional\n    // --------\n    // @ifPathNotFound    - [boolean, function] - defaults to false. If the \n    //                                path or part of the path is not found,\n    //                                should the path be created automatically.\n    //\n    //                                If a function is passed, this function\n    //                                is executed with the @startingReference\n    //                                and @value arguments passed in.\n    //-------------------------------------------------------------------------\n    Dryify.prototype.setval = function(startingReference, jsonPath, value, ifPathNotFound) {\n\n      var currentReference = startingReference;\n\n      if (\n        typeof currentReference !== 'object' || typeof jsonPath !== 'string'\n      ) {\n        throw Error(\"@setval missing some mandatory arguments\");\n      }\n\n      jsonPath = _interpretJsonPath(jsonPath);\n\n      // This loop has to ascend\n      for (\n        var i = 0, loopKey, loopKeyPlus; i < jsonPath.length; i++\n      ) {\n\n        // DRY.\n        loopKey = jsonPath[i];\n        loopKeyPlus = jsonPath[i + 1];\n\n        // If it doesn't exist\n        if (typeof currentReference[loopKey] === 'undefined') {\n\n          if (ifPathNotFound === true) {\n\n            if (typeof loopKeyPlus !== 'undefined') {\n              if (typeof loopKeyPlus === 'string') {\n                // create an object\n                currentReference[loopKey] = {};\n              } else {\n                // create an Array\n                currentReference[loopKey] = [];\n              }\n              // Switch in the currentReference\n              currentReference = currentReference[loopKey];\n            } else {\n              currentReference[loopKey] = value;\n            }\n\n          } else if (typeof ifPathNotFound === 'function') {\n            return ifPathNotFound(startingReference, value);\n          } else {\n            break;\n          }\n\n\n        } else {\n          // If it exists\n\n          // Switch in the currentReference\n          currentReference = currentReference[loopKey];\n        }\n      }\n\n      return startingReference;\n    };\n\n    //-------------------------------------------------------------------------\n    // Traverses an entire JSON object hierarchically, iterating over every key\n    // and value referentially.\n    //\n    // Required\n    // --------\n    // @json      - object    - the JSON to traverse\n    // @callback  - function  - a function that passes in the value, index,\n    //                          and reference-path  of the traversal as the\n    //                          arguments (v [any], i [Number], path [Array]).\n    //-------------------------------------------------------------------------\n    Dryify.prototype.traverse = function(json, callback) {\n\n      // @path - {object} Array - path keys\n      function iter(o, path) {\n\n        var counter = 0;\n        var newPath;\n\n        for (var property in o) {\n\n          if (typeof(o[property]) !== 'function') {\n\n            // No longer mandatory to pass back value (passed back by default)\n            o[property] =\n              callback(o[property], counter++, path) || o[property];\n\n            if (!!o[property] && typeof(o[property]) === 'object') {\n\n              // Pass in a cloned Array\n              newPath = path.slice();\n              newPath.push(property);\n\n              iter(o[property], newPath);\n            }\n          }\n        }\n\n        return o;\n      }\n\n      return iter(json, []);\n    };\n\n    //-------------------------------------------------------------------------\n\n    dryify = new Dryify();\n    dryify.Dryify = Dryify; // make constructor available\n\n    //-------------------------------------------------------------------------\n    // Export the module / assign to @this context\n    //-------------------------------------------------------------------------\n    //\n    // node\n    if (typeof exports !== 'undefined') {\n\n      if (typeof module !== 'undefined' && module.exports) {\n        exports = module.exports = dryify;\n      }\n\n      exports.dryify = dryify;\n\n    } else {\n      // browser\n      self.dryify = dryify;\n    }\n\n    return dryify;\n\n  }());\n\n  //-------------------------------------------------------------------------\n  // Provide the option for compatability with older versions of this module\n  // http://www.richardrodger.com/2013/09/27/how-to-make-simple-node-js-modules-work-in-the-browser/\n  //-------------------------------------------------------------------------\n  dryify.noConflict = function() {\n    self.dryify = olderDryify; // publish older version\n    return dryify; // allow chaining\n  };\n\n}.call(this)); // Calls the window object in the browser\n"]}