{"version":3,"file":"memoization.mjs","sources":["../../../../src/clients/utils/memoization.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n/**\n * Cache the payload of a response body. It allows multiple calls to the body,\n * for example, when reading the body in both retry decider and error deserializer.\n * Caching body is allowed here because we call the body accessor(blob(), json(),\n * etc.) when body is small or streaming implementation is not available(RN).\n *\n * @internal\n */\nexport const withMemoization = (payloadAccessor) => {\n    let cached;\n    return () => {\n        if (!cached) {\n            // Explicitly not awaiting. Intermediate await would add overhead and\n            // introduce a possible race in the event that this wrapper is called\n            // again before the first `payloadAccessor` call resolves.\n            cached = payloadAccessor();\n        }\n        return cached;\n    };\n};\n"],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACY,MAAC,eAAe,GAAG,CAAC,eAAe,KAAK;AACpD,IAAI,IAAI,MAAM;AACd,IAAI,OAAO,MAAM;AACjB,QAAQ,IAAI,CAAC,MAAM,EAAE;AACrB;AACA;AACA;AACA,YAAY,MAAM,GAAG,eAAe,EAAE;AACtC,QAAQ;AACR,QAAQ,OAAO,MAAM;AACrB,IAAI,CAAC;AACL;;;;"}