7e07d0e1756e237cb790d9cb3d522a79.json
2.35 KB
{"ast":null,"code":"import * as React from 'react';\nexport default function useCacheOptions(values, options) {\n var prevOptionMapRef = React.useRef(null);\n var optionMap = React.useMemo(function () {\n var map = new Map();\n options.forEach(function (item) {\n var value = item.data.value;\n map.set(value, item);\n });\n return map;\n }, [values, options]);\n prevOptionMapRef.current = optionMap;\n\n var getValueOption = function getValueOption(vals) {\n return vals.map(function (value) {\n return prevOptionMapRef.current.get(value);\n }).filter(Boolean);\n };\n\n return getValueOption;\n}","map":{"version":3,"sources":["C:/Users/kkwan_000/Desktop/git/2017110269/minsung/node_modules/rc-select/es/hooks/useCacheOptions.js"],"names":["React","useCacheOptions","values","options","prevOptionMapRef","useRef","optionMap","useMemo","map","Map","forEach","item","value","data","set","current","getValueOption","vals","get","filter","Boolean"],"mappings":"AAAA,OAAO,KAAKA,KAAZ,MAAuB,OAAvB;AACA,eAAe,SAASC,eAAT,CAAyBC,MAAzB,EAAiCC,OAAjC,EAA0C;AACvD,MAAIC,gBAAgB,GAAGJ,KAAK,CAACK,MAAN,CAAa,IAAb,CAAvB;AACA,MAAIC,SAAS,GAAGN,KAAK,CAACO,OAAN,CAAc,YAAY;AACxC,QAAIC,GAAG,GAAG,IAAIC,GAAJ,EAAV;AACAN,IAAAA,OAAO,CAACO,OAAR,CAAgB,UAAUC,IAAV,EAAgB;AAC9B,UAAIC,KAAK,GAAGD,IAAI,CAACE,IAAL,CAAUD,KAAtB;AACAJ,MAAAA,GAAG,CAACM,GAAJ,CAAQF,KAAR,EAAeD,IAAf;AACD,KAHD;AAIA,WAAOH,GAAP;AACD,GAPe,EAOb,CAACN,MAAD,EAASC,OAAT,CAPa,CAAhB;AAQAC,EAAAA,gBAAgB,CAACW,OAAjB,GAA2BT,SAA3B;;AAEA,MAAIU,cAAc,GAAG,SAASA,cAAT,CAAwBC,IAAxB,EAA8B;AACjD,WAAOA,IAAI,CAACT,GAAL,CAAS,UAAUI,KAAV,EAAiB;AAC/B,aAAOR,gBAAgB,CAACW,OAAjB,CAAyBG,GAAzB,CAA6BN,KAA7B,CAAP;AACD,KAFM,EAEJO,MAFI,CAEGC,OAFH,CAAP;AAGD,GAJD;;AAMA,SAAOJ,cAAP;AACD","sourcesContent":["import * as React from 'react';\nexport default function useCacheOptions(values, options) {\n var prevOptionMapRef = React.useRef(null);\n var optionMap = React.useMemo(function () {\n var map = new Map();\n options.forEach(function (item) {\n var value = item.data.value;\n map.set(value, item);\n });\n return map;\n }, [values, options]);\n prevOptionMapRef.current = optionMap;\n\n var getValueOption = function getValueOption(vals) {\n return vals.map(function (value) {\n return prevOptionMapRef.current.get(value);\n }).filter(Boolean);\n };\n\n return getValueOption;\n}"]},"metadata":{},"sourceType":"module"}