{"ast":null,"code":"/**\n * Contains all configured adapters for the given environment.\n *\n * @type {Array}\n * @public\n */\nvar adapters = [];\n/**\n * Contains all modifier functions.\n *\n * @typs {Array}\n * @public\n */\n\nvar modifiers = [];\n/**\n * Our default logger.\n *\n * @public\n */\n\nvar logger = function devnull() {};\n/**\n * Register a new adapter that will used to find environments.\n *\n * @param {Function} adapter A function that will return the possible env.\n * @returns {Boolean} Indication of a successful add.\n * @public\n */\n\n\nfunction use(adapter) {\n  if (~adapters.indexOf(adapter)) return false;\n  adapters.push(adapter);\n  return true;\n}\n/**\n * Assign a new log method.\n *\n * @param {Function} custom The log method.\n * @public\n */\n\n\nfunction set(custom) {\n  logger = custom;\n}\n/**\n * Check if the namespace is allowed by any of our adapters.\n *\n * @param {String} namespace The namespace that needs to be enabled\n * @returns {Boolean|Promise} Indication if the namespace is enabled by our adapters.\n * @public\n */\n\n\nfunction enabled(namespace) {\n  var async = [];\n\n  for (var i = 0; i < adapters.length; i++) {\n    if (adapters[i].async) {\n      async.push(adapters[i]);\n      continue;\n    }\n\n    if (adapters[i](namespace)) return true;\n  }\n\n  if (!async.length) return false; //\n  // Now that we know that we Async functions, we know we run in an ES6\n  // environment and can use all the API's that they offer, in this case\n  // we want to return a Promise so that we can `await` in React-Native\n  // for an async adapter.\n  //\n\n  return new Promise(function pinky(resolve) {\n    Promise.all(async.map(function prebind(fn) {\n      return fn(namespace);\n    })).then(function resolved(values) {\n      resolve(values.some(Boolean));\n    });\n  });\n}\n/**\n * Add a new message modifier to the debugger.\n *\n * @param {Function} fn Modification function.\n * @returns {Boolean} Indication of a successful add.\n * @public\n */\n\n\nfunction modify(fn) {\n  if (~modifiers.indexOf(fn)) return false;\n  modifiers.push(fn);\n  return true;\n}\n/**\n * Write data to the supplied logger.\n *\n * @param {Object} meta Meta information about the log.\n * @param {Array} args Arguments for console.log.\n * @public\n */\n\n\nfunction write() {\n  logger.apply(logger, arguments);\n}\n/**\n * Process the message with the modifiers.\n *\n * @param {Mixed} message The message to be transformed by modifers.\n * @returns {String} Transformed message.\n * @public\n */\n\n\nfunction process(message) {\n  for (var i = 0; i < modifiers.length; i++) {\n    message = modifiers[i].apply(modifiers[i], arguments);\n  }\n\n  return message;\n}\n/**\n * Introduce options to the logger function.\n *\n * @param {Function} fn Calback function.\n * @param {Object} options Properties to introduce on fn.\n * @returns {Function} The passed function\n * @public\n */\n\n\nfunction introduce(fn, options) {\n  var has = Object.prototype.hasOwnProperty;\n\n  for (var key in options) {\n    if (has.call(options, key)) {\n      fn[key] = options[key];\n    }\n  }\n\n  return fn;\n}\n/**\n * Nope, we're not allowed to write messages.\n *\n * @returns {Boolean} false\n * @public\n */\n\n\nfunction nope(options) {\n  options.enabled = false;\n  options.modify = modify;\n  options.set = set;\n  options.use = use;\n  return introduce(function diagnopes() {\n    return false;\n  }, options);\n}\n/**\n * Yep, we're allowed to write debug messages.\n *\n * @param {Object} options The options for the process.\n * @returns {Function} The function that does the logging.\n * @public\n */\n\n\nfunction yep(options) {\n  /**\n   * The function that receives the actual debug information.\n   *\n   * @returns {Boolean} indication that we're logging.\n   * @public\n   */\n  function diagnostics() {\n    var args = Array.prototype.slice.call(arguments, 0);\n    write.call(write, options, process(args, options));\n    return true;\n  }\n\n  options.enabled = true;\n  options.modify = modify;\n  options.set = set;\n  options.use = use;\n  return introduce(diagnostics, options);\n}\n/**\n * Simple helper function to introduce various of helper methods to our given\n * diagnostics function.\n *\n * @param {Function} diagnostics The diagnostics function.\n * @returns {Function} diagnostics\n * @public\n */\n\n\nmodule.exports = function create(diagnostics) {\n  diagnostics.introduce = introduce;\n  diagnostics.enabled = enabled;\n  diagnostics.process = process;\n  diagnostics.modify = modify;\n  diagnostics.write = write;\n  diagnostics.nope = nope;\n  diagnostics.yep = yep;\n  diagnostics.set = set;\n  diagnostics.use = use;\n  return diagnostics;\n};","map":{"version":3,"sources":["D:/Development/Work/CENOS/cenos-ui/node_modules/@dabh/diagnostics/diagnostics.js"],"names":["adapters","modifiers","logger","devnull","use","adapter","indexOf","push","set","custom","enabled","namespace","async","i","length","Promise","pinky","resolve","all","map","prebind","fn","then","resolved","values","some","Boolean","modify","write","apply","arguments","process","message","introduce","options","has","Object","prototype","hasOwnProperty","key","call","nope","diagnopes","yep","diagnostics","args","Array","slice","module","exports","create"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA,IAAIA,QAAQ,GAAG,EAAf;AAEA;AACA;AACA;AACA;AACA;AACA;;AACA,IAAIC,SAAS,GAAG,EAAhB;AAEA;AACA;AACA;AACA;AACA;;AACA,IAAIC,MAAM,GAAG,SAASC,OAAT,GAAmB,CAAE,CAAlC;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,SAASC,GAAT,CAAaC,OAAb,EAAsB;AACpB,MAAI,CAACL,QAAQ,CAACM,OAAT,CAAiBD,OAAjB,CAAL,EAAgC,OAAO,KAAP;AAEhCL,EAAAA,QAAQ,CAACO,IAAT,CAAcF,OAAd;AACA,SAAO,IAAP;AACD;AAED;AACA;AACA;AACA;AACA;AACA;;;AACA,SAASG,GAAT,CAAaC,MAAb,EAAqB;AACnBP,EAAAA,MAAM,GAAGO,MAAT;AACD;AAED;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,SAASC,OAAT,CAAiBC,SAAjB,EAA4B;AAC1B,MAAIC,KAAK,GAAG,EAAZ;;AAEA,OAAK,IAAIC,CAAC,GAAG,CAAb,EAAgBA,CAAC,GAAGb,QAAQ,CAACc,MAA7B,EAAqCD,CAAC,EAAtC,EAA0C;AACxC,QAAIb,QAAQ,CAACa,CAAD,CAAR,CAAYD,KAAhB,EAAuB;AACrBA,MAAAA,KAAK,CAACL,IAAN,CAAWP,QAAQ,CAACa,CAAD,CAAnB;AACA;AACD;;AAED,QAAIb,QAAQ,CAACa,CAAD,CAAR,CAAYF,SAAZ,CAAJ,EAA4B,OAAO,IAAP;AAC7B;;AAED,MAAI,CAACC,KAAK,CAACE,MAAX,EAAmB,OAAO,KAAP,CAZO,CAc1B;AAC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ED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACAc,MAAM,CAACC,OAAP,GAAiB,SAASC,MAAT,CAAgBN,WAAhB,EAA6B;AAC5CA,EAAAA,WAAW,CAACX,SAAZ,GAAwBA,SAAxB;AACAW,EAAAA,WAAW,CAAClC,OAAZ,GAAsBA,OAAtB;AACAkC,EAAAA,WAAW,CAACb,OAAZ,GAAsBA,OAAtB;AACAa,EAAAA,WAAW,CAACjB,MAAZ,GAAqBA,MAArB;AACAiB,EAAAA,WAAW,CAAChB,KAAZ,GAAoBA,KAApB;AACAgB,EAAAA,WAAW,CAACH,IAAZ,GAAmBA,IAAnB;AACAG,EAAAA,WAAW,CAACD,GAAZ,GAAkBA,GAAlB;AACAC,EAAAA,WAAW,CAACpC,GAAZ,GAAkBA,GAAlB;AACAoC,EAAAA,WAAW,CAACxC,GAAZ,GAAkBA,GAAlB;AAEA,SAAOwC,WAAP;AACD,CAZD","sourcesContent":["/**\n * Contains all configured adapters for the given environment.\n *\n * @type {Array}\n * @public\n */\nvar adapters = [];\n\n/**\n * Contains all modifier functions.\n *\n * @typs {Array}\n * @public\n */\nvar modifiers = [];\n\n/**\n * Our default logger.\n *\n * @public\n */\nvar logger = function devnull() {};\n\n/**\n * Register a new adapter that will used to find environments.\n *\n * @param {Function} adapter A function that will return the possible env.\n * @returns {Boolean} Indication of a successful add.\n * @public\n */\nfunction use(adapter) {\n  if (~adapters.indexOf(adapter)) return false;\n\n  adapters.push(adapter);\n  return true;\n}\n\n/**\n * Assign a new log method.\n *\n * @param {Function} custom The log method.\n * @public\n */\nfunction set(custom) {\n  logger = custom;\n}\n\n/**\n * Check if the namespace is allowed by any of our adapters.\n *\n * @param {String} namespace The namespace that needs to be enabled\n * @returns {Boolean|Promise} Indication if the namespace is enabled by our adapters.\n * @public\n */\nfunction enabled(namespace) {\n  var async = [];\n\n  for (var i = 0; i < adapters.length; i++) {\n    if (adapters[i].async) {\n      async.push(adapters[i]);\n      continue;\n    }\n\n    if (adapters[i](namespace)) return true;\n  }\n\n  if (!async.length) return false;\n\n  //\n  // Now that we know that we Async functions, we know we run in an ES6\n  // environment and can use all the API's that they offer, in this case\n  // we want to return a Promise so that we can `await` in React-Native\n  // for an async adapter.\n  //\n  return new Promise(function pinky(resolve) {\n    Promise.all(\n      async.map(function prebind(fn) {\n        return fn(namespace);\n      })\n    ).then(function resolved(values) {\n      resolve(values.some(Boolean));\n    });\n  });\n}\n\n/**\n * Add a new message modifier to the debugger.\n *\n * @param {Function} fn Modification function.\n * @returns {Boolean} Indication of a successful add.\n * @public\n */\nfunction modify(fn) {\n  if (~modifiers.indexOf(fn)) return false;\n\n  modifiers.push(fn);\n  return true;\n}\n\n/**\n * Write data to the supplied logger.\n *\n * @param {Object} meta Meta information about the log.\n * @param {Array} args Arguments for console.log.\n * @public\n */\nfunction write() {\n  logger.apply(logger, arguments);\n}\n\n/**\n * Process the message with the modifiers.\n *\n * @param {Mixed} message The message to be transformed by modifers.\n * @returns {String} Transformed message.\n * @public\n */\nfunction process(message) {\n  for (var i = 0; i < modifiers.length; i++) {\n    message = modifiers[i].apply(modifiers[i], arguments);\n  }\n\n  return message;\n}\n\n/**\n * Introduce options to the logger function.\n *\n * @param {Function} fn Calback function.\n * @param {Object} options Properties to introduce on fn.\n * @returns {Function} The passed function\n * @public\n */\nfunction introduce(fn, options) {\n  var has = Object.prototype.hasOwnProperty;\n\n  for (var key in options) {\n    if (has.call(options, key)) {\n      fn[key] = options[key];\n    }\n  }\n\n  return fn;\n}\n\n/**\n * Nope, we're not allowed to write messages.\n *\n * @returns {Boolean} false\n * @public\n */\nfunction nope(options) {\n  options.enabled = false;\n  options.modify = modify;\n  options.set = set;\n  options.use = use;\n\n  return introduce(function diagnopes() {\n    return false;\n  }, options);\n}\n\n/**\n * Yep, we're allowed to write debug messages.\n *\n * @param {Object} options The options for the process.\n * @returns {Function} The function that does the logging.\n * @public\n */\nfunction yep(options) {\n  /**\n   * The function that receives the actual debug information.\n   *\n   * @returns {Boolean} indication that we're logging.\n   * @public\n   */\n  function diagnostics() {\n    var args = Array.prototype.slice.call(arguments, 0);\n\n    write.call(write, options, process(args, options));\n    return true;\n  }\n\n  options.enabled = true;\n  options.modify = modify;\n  options.set = set;\n  options.use = use;\n\n  return introduce(diagnostics, options);\n}\n\n/**\n * Simple helper function to introduce various of helper methods to our given\n * diagnostics function.\n *\n * @param {Function} diagnostics The diagnostics function.\n * @returns {Function} diagnostics\n * @public\n */\nmodule.exports = function create(diagnostics) {\n  diagnostics.introduce = introduce;\n  diagnostics.enabled = enabled;\n  diagnostics.process = process;\n  diagnostics.modify = modify;\n  diagnostics.write = write;\n  diagnostics.nope = nope;\n  diagnostics.yep = yep;\n  diagnostics.set = set;\n  diagnostics.use = use;\n\n  return diagnostics;\n}\n"]},"metadata":{},"sourceType":"script"}