You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

1 lines
4.1 KiB

{"ast":null,"code":"import { useState, useRef, useEffect } from 'react';\n\nfunction areInputsEqual(newInputs, lastInputs) {\n if (newInputs.length !== lastInputs.length) {\n return false;\n }\n\n for (var i = 0; i < newInputs.length; i++) {\n if (newInputs[i] !== lastInputs[i]) {\n return false;\n }\n }\n\n return true;\n}\n\nfunction useMemoOne(getResult, inputs) {\n var initial = useState(function () {\n return {\n inputs: inputs,\n result: getResult()\n };\n })[0];\n var isFirstRun = useRef(true);\n var committed = useRef(initial);\n var useCache = isFirstRun.current || Boolean(inputs && committed.current.inputs && areInputsEqual(inputs, committed.current.inputs));\n var cache = useCache ? committed.current : {\n inputs: inputs,\n result: getResult()\n };\n useEffect(function () {\n isFirstRun.current = false;\n committed.current = cache;\n }, [cache]);\n return cache.result;\n}\n\nfunction useCallbackOne(callback, inputs) {\n return useMemoOne(function () {\n return callback;\n }, inputs);\n}\n\nvar useMemo = useMemoOne;\nvar useCallback = useCallbackOne;\nexport { useCallback, useCallbackOne, useMemo, useMemoOne };","map":{"version":3,"names":["useState","useRef","useEffect","areInputsEqual","newInputs","lastInputs","length","i","useMemoOne","getResult","inputs","initial","result","isFirstRun","committed","useCache","current","Boolean","cache","useCallbackOne","callback","useMemo","useCallback"],"sources":["/Users/mahdi/Documents/work/programming/barnameNegar/arbaeenWebApp/node_modules/use-memo-one/dist/use-memo-one.esm.js"],"sourcesContent":["import { useState, useRef, useEffect } from 'react';\n\nfunction areInputsEqual(newInputs, lastInputs) {\n if (newInputs.length !== lastInputs.length) {\n return false;\n }\n\n for (var i = 0; i < newInputs.length; i++) {\n if (newInputs[i] !== lastInputs[i]) {\n return false;\n }\n }\n\n return true;\n}\n\nfunction useMemoOne(getResult, inputs) {\n var initial = useState(function () {\n return {\n inputs: inputs,\n result: getResult()\n };\n })[0];\n var isFirstRun = useRef(true);\n var committed = useRef(initial);\n var useCache = isFirstRun.current || Boolean(inputs && committed.current.inputs && areInputsEqual(inputs, committed.current.inputs));\n var cache = useCache ? committed.current : {\n inputs: inputs,\n result: getResult()\n };\n useEffect(function () {\n isFirstRun.current = false;\n committed.current = cache;\n }, [cache]);\n return cache.result;\n}\nfunction useCallbackOne(callback, inputs) {\n return useMemoOne(function () {\n return callback;\n }, inputs);\n}\nvar useMemo = useMemoOne;\nvar useCallback = useCallbackOne;\n\nexport { useCallback, useCallbackOne, useMemo, useMemoOne };\n"],"mappings":"AAAA,SAASA,QAAT,EAAmBC,MAAnB,EAA2BC,SAA3B,QAA4C,OAA5C;;AAEA,SAASC,cAAT,CAAwBC,SAAxB,EAAmCC,UAAnC,EAA+C;EAC7C,IAAID,SAAS,CAACE,MAAV,KAAqBD,UAAU,CAACC,MAApC,EAA4C;IAC1C,OAAO,KAAP;EACD;;EAED,KAAK,IAAIC,CAAC,GAAG,CAAb,EAAgBA,CAAC,GAAGH,SAAS,CAACE,MAA9B,EAAsCC,CAAC,EAAvC,EAA2C;IACzC,IAAIH,SAAS,CAACG,CAAD,CAAT,KAAiBF,UAAU,CAACE,CAAD,CAA/B,EAAoC;MAClC,OAAO,KAAP;IACD;EACF;;EAED,OAAO,IAAP;AACD;;AAED,SAASC,UAAT,CAAoBC,SAApB,EAA+BC,MAA/B,EAAuC;EACrC,IAAIC,OAAO,GAAGX,QAAQ,CAAC,YAAY;IACjC,OAAO;MACLU,MAAM,EAAEA,MADH;MAELE,MAAM,EAAEH,SAAS;IAFZ,CAAP;EAID,CALqB,CAAR,CAKX,CALW,CAAd;EAMA,IAAII,UAAU,GAAGZ,MAAM,CAAC,IAAD,CAAvB;EACA,IAAIa,SAAS,GAAGb,MAAM,CAACU,OAAD,CAAtB;EACA,IAAII,QAAQ,GAAGF,UAAU,CAACG,OAAX,IAAsBC,OAAO,CAACP,MAAM,IAAII,SAAS,CAACE,OAAV,CAAkBN,MAA5B,IAAsCP,cAAc,CAACO,MAAD,EAASI,SAAS,CAACE,OAAV,CAAkB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