d57e9f014bf1fff9b0cffb43de146cc6.json
6.24 KB
{"ast":null,"code":"import _classCallCheck from \"@babel/runtime/helpers/esm/classCallCheck\";\nimport _createClass from \"@babel/runtime/helpers/esm/createClass\";\nimport { matchNamePath } from './valueUtil';\n/**\n * NameMap like a `Map` but accepts `string[]` as key.\n */\n\nvar NameMap = /*#__PURE__*/function () {\n function NameMap() {\n _classCallCheck(this, NameMap);\n\n this.list = [];\n }\n\n _createClass(NameMap, [{\n key: \"set\",\n value: function set(key, value) {\n var index = this.list.findIndex(function (item) {\n return matchNamePath(item.key, key);\n });\n\n if (index !== -1) {\n this.list[index].value = value;\n } else {\n this.list.push({\n key: key,\n value: value\n });\n }\n }\n }, {\n key: \"get\",\n value: function get(key) {\n var result = this.list.find(function (item) {\n return matchNamePath(item.key, key);\n });\n return result && result.value;\n }\n }, {\n key: \"update\",\n value: function update(key, updater) {\n var origin = this.get(key);\n var next = updater(origin);\n\n if (!next) {\n this.delete(key);\n } else {\n this.set(key, next);\n }\n }\n }, {\n key: \"delete\",\n value: function _delete(key) {\n this.list = this.list.filter(function (item) {\n return !matchNamePath(item.key, key);\n });\n }\n }, {\n key: \"map\",\n value: function map(callback) {\n return this.list.map(callback);\n }\n }, {\n key: \"toJSON\",\n value: function toJSON() {\n var json = {};\n this.map(function (_ref) {\n var key = _ref.key,\n value = _ref.value;\n json[key.join('.')] = value;\n return null;\n });\n return json;\n }\n }]);\n\n return NameMap;\n}();\n\nexport default NameMap;","map":{"version":3,"sources":["C:/Users/kkwan_000/Desktop/git/2017110269/minsung/node_modules/rc-field-form/es/utils/NameMap.js"],"names":["_classCallCheck","_createClass","matchNamePath","NameMap","list","key","value","set","index","findIndex","item","push","get","result","find","update","updater","origin","next","delete","_delete","filter","map","callback","toJSON","json","_ref","join"],"mappings":"AAAA,OAAOA,eAAP,MAA4B,2CAA5B;AACA,OAAOC,YAAP,MAAyB,wCAAzB;AACA,SAASC,aAAT,QAA8B,aAA9B;AACA;AACA;AACA;;AAEA,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Ia,IAAI,GAAGF,OAAO,CAACC,MAAD,CAAlB;;AAEA,UAAI,CAACC,IAAL,EAAW;AACT,aAAKC,MAAL,CAAYd,GAAZ;AACD,OAFD,MAEO;AACL,aAAKE,GAAL,CAASF,GAAT,EAAca,IAAd;AACD;AACF;AAXA,GAxBmB,EAoCnB;AACDb,IAAAA,GAAG,EAAE,QADJ;AAEDC,IAAAA,KAAK,EAAE,SAASc,OAAT,CAAiBf,GAAjB,EAAsB;AAC3B,WAAKD,IAAL,GAAY,KAAKA,IAAL,CAAUiB,MAAV,CAAiB,UAAUX,IAAV,EAAgB;AAC3C,eAAO,CAACR,aAAa,CAACQ,IAAI,CAACL,GAAN,EAAWA,GAAX,CAArB;AACD,OAFW,CAAZ;AAGD;AANA,GApCmB,EA2CnB;AACDA,IAAAA,GAAG,EAAE,KADJ;AAEDC,IAAAA,KAAK,EAAE,SAASgB,GAAT,CAAaC,QAAb,EAAuB;AAC5B,aAAO,KAAKnB,IAAL,CAAUkB,GAAV,CAAcC,QAAd,CAAP;AACD;AAJA,GA3CmB,EAgDnB;AACDlB,IAAAA,GAAG,EAAE,QADJ;AAEDC,IAAAA,KAAK,EAAE,SAASkB,MAAT,GAAkB;AACvB,UAAIC,IAAI,GAAG,EAAX;AACA,WAAKH,GAAL,CAAS,UAAUI,IAAV,EAAgB;AACvB,YAAIrB,GAAG,GAAGqB,IAAI,CAACrB,GAAf;AAAA,YACIC,KAAK,GAAGoB,IAAI,CAACpB,KADjB;AAEAmB,QAAAA,IAAI,CAACpB,GAAG,CAACsB,IAAJ,CAAS,GAAT,CAAD,CAAJ,GAAsBrB,KAAtB;AACA,eAAO,IAAP;AACD,OALD;AAMA,aAAOmB,IAAP;AACD;AAXA,GAhDmB,CAAV,CAAZ;;AA8DA,SAAOtB,OAAP;AACD,CAtE0B,EAA3B;;AAwEA,eAAeA,OAAf","sourcesContent":["import _classCallCheck from \"@babel/runtime/helpers/esm/classCallCheck\";\nimport _createClass from \"@babel/runtime/helpers/esm/createClass\";\nimport { matchNamePath } from './valueUtil';\n/**\n * NameMap like a `Map` but accepts `string[]` as key.\n */\n\nvar NameMap = /*#__PURE__*/function () {\n function NameMap() {\n _classCallCheck(this, NameMap);\n\n this.list = [];\n }\n\n _createClass(NameMap, [{\n key: \"set\",\n value: function set(key, value) {\n var index = this.list.findIndex(function (item) {\n return matchNamePath(item.key, key);\n });\n\n if (index !== -1) {\n this.list[index].value = value;\n } else {\n this.list.push({\n key: key,\n value: value\n });\n }\n }\n }, {\n key: \"get\",\n value: function get(key) {\n var result = this.list.find(function (item) {\n return matchNamePath(item.key, key);\n });\n return result && result.value;\n }\n }, {\n key: \"update\",\n value: function update(key, updater) {\n var origin = this.get(key);\n var next = updater(origin);\n\n if (!next) {\n this.delete(key);\n } else {\n this.set(key, next);\n }\n }\n }, {\n key: \"delete\",\n value: function _delete(key) {\n this.list = this.list.filter(function (item) {\n return !matchNamePath(item.key, key);\n });\n }\n }, {\n key: \"map\",\n value: function map(callback) {\n return this.list.map(callback);\n }\n }, {\n key: \"toJSON\",\n value: function toJSON() {\n var json = {};\n this.map(function (_ref) {\n var key = _ref.key,\n value = _ref.value;\n json[key.join('.')] = value;\n return null;\n });\n return json;\n }\n }]);\n\n return NameMap;\n}();\n\nexport default NameMap;"]},"metadata":{},"sourceType":"module"}