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AK,GACV,GACF,EAGI,EAAM,EAAO,KAAK,MAAM,EAAK,SAAS,SAAS,UAC/C,cAAc,GAChB,EAAI,KAAK,EAAW,GAEpB,EAAU,EAEd,CAAE,MAAO,GACP,EAAQ,EACV,CACF,GACF","file":"/npm/gulp-json-editor@2.6.0/index.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/gulp-json-editor@2.6.0/index.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","var jsbeautify   = require('js-beautify').js_beautify;\nvar deepmerge    = require('deepmerge');\nvar through      = require('through2');\nvar PluginError  = require('plugin-error');\nvar detectIndent = require('detect-indent');\n\nmodule.exports = function(editor, jsbeautifyOptions, deepmergeOptions) {\n\n  /*\n   * deepmerge options\n   */\n  deepmergeOptions = deepmergeOptions || {};\n\n  /*\n   * create 'editBy' function from 'editor'\n   */\n  var editBy;\n  if (typeof editor === 'function') {\n    // edit JSON object by user specific function\n    editBy = function(json) { return editor(json); };\n  } else if (typeof editor === 'object') {\n    // edit JSON object by merging with user specific object\n    editBy = function(json) { return deepmerge(json, editor, deepmergeOptions); };\n  } else if (typeof editor === 'undefined') {\n    throw new PluginError('gulp-json-editor', 'missing \"editor\" option');\n  } else {\n    throw new PluginError('gulp-json-editor', '\"editor\" option must be a function or object');\n  }\n\n  /*\n   * js-beautify options\n   */\n  jsbeautifyOptions = jsbeautifyOptions || {};\n\n  /*\n   * create through object and return it\n   */\n  return through.obj(function(file, encoding, callback) {\n    var self = this;\n\n    // ignore it\n    if (file.isNull()) {\n      this.push(file);\n      return callback();\n    }\n\n    // stream is not supported\n    if (file.isStream()) {\n      this.emit('error',\n        new PluginError('gulp-json-editor', 'Streaming is not supported'));\n      return callback();\n    }\n\n    // when edit fail\n    var onError = function(err) {\n      self.emit('error', new PluginError('gulp-json-editor', err));\n      callback();\n    };\n\n    try {\n      // try to get current indentation\n      var indent = detectIndent(file.contents.toString('utf8'));\n\n      // beautify options for this particular file\n      var beautifyOptions = deepmerge({}, jsbeautifyOptions); // make copy\n      beautifyOptions.indent_size = beautifyOptions.indent_size || indent.amount || 2;\n      beautifyOptions.indent_char = beautifyOptions.indent_char || (indent.type === 'tab' ? '\\t' : ' ');\n      beautifyOptions.beautify = !('beautify' in beautifyOptions && !beautifyOptions.beautify);\n\n      // when edit success\n      var onSuccess = function(json) {\n        json = JSON.stringify(json);\n        \n        // beautify JSON\n        if (beautifyOptions.beautify) {\n          json = jsbeautify(json, beautifyOptions);\n        }\n  \n        // write it to file\n        file.contents = Buffer.from(json);\n        self.push(file);\n        callback();\n      };\n  \n      // edit JSON object and get it as string notation\n      var res = editBy(JSON.parse(file.contents.toString('utf8')));\n      if (isPromiseLike(res)) {\n        res.then(onSuccess, onError);\n      } else {\n        onSuccess(res);\n      }\n    } catch (err) {\n      onError(err);\n    }\n  });\n};\n\nfunction isPromiseLike(maybePromise) {\n  return typeof maybePromise === 'object' && maybePromise !== null && typeof maybePromise.then === 'function';\n}\n"]}