@aws-amplify/core
Version:
Core category of aws-amplify
1 lines • 2.45 kB
Source Map (JSON)
{"version":3,"file":"cacheHelpers.mjs","sources":["../../../../src/Cache/utils/cacheHelpers.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { currentSizeKey } from '../constants';\n/**\n * return the byte size of the string\n * @param str\n */\nexport function getByteLength(str) {\n let ret = 0;\n ret = str.length;\n for (let i = str.length; i >= 0; i -= 1) {\n const charCode = str.charCodeAt(i);\n if (charCode > 0x7f && charCode <= 0x7ff) {\n ret += 1;\n }\n else if (charCode > 0x7ff && charCode <= 0xffff) {\n ret += 2;\n }\n // trail surrogate\n if (charCode >= 0xdc00 && charCode <= 0xdfff) {\n i -= 1;\n }\n }\n return ret;\n}\n/**\n * get current time\n */\nexport function getCurrentTime() {\n const currentTime = new Date();\n return currentTime.getTime();\n}\n/**\n * check if passed value is an integer\n */\nexport function isInteger(value) {\n if (Number.isInteger) {\n return Number.isInteger(value);\n }\n return (typeof value === 'number' && isFinite(value) && Math.floor(value) === value);\n}\nexport const getCurrentSizeKey = (keyPrefix) => `${keyPrefix}${currentSizeKey}`;\n"],"names":[],"mappings":";;AAAA;AACA;AAEA;AACA;AACA;AACA;AACO,SAAS,aAAa,CAAC,GAAG,EAAE;AACnC,IAAI,IAAI,GAAG,GAAG,CAAC,CAAC;AAChB,IAAI,GAAG,GAAG,GAAG,CAAC,MAAM,CAAC;AACrB,IAAI,KAAK,IAAI,CAAC,GAAG,GAAG,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE;AAC7C,QAAQ,MAAM,QAAQ,GAAG,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;AAC3C,QAAQ,IAAI,QAAQ,GAAG,IAAI,IAAI,QAAQ,IAAI,KAAK,EAAE;AAClD,YAAY,GAAG,IAAI,CAAC,CAAC;AACrB,SAAS;AACT,aAAa,IAA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