@mtkruto/node 0.69.0 → 0.70.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/esm/0_deps.d.ts +3 -1
- package/esm/0_deps.d.ts.map +1 -1
- package/esm/0_deps.js +3 -1
- package/esm/3_types.d.ts +35 -35
- package/esm/3_types.d.ts.map +1 -1
- package/esm/3_types.js +35 -35
- package/esm/_dnt.polyfills.d.ts +7 -0
- package/esm/_dnt.polyfills.d.ts.map +1 -1
- package/esm/_dnt.polyfills.js +109 -0
- package/esm/client/0_abortable_loop.d.ts +27 -0
- package/esm/client/0_abortable_loop.d.ts.map +1 -0
- package/esm/client/0_abortable_loop.js +49 -0
- package/esm/client/0_filters.d.ts +9 -3
- package/esm/client/0_filters.d.ts.map +1 -1
- package/esm/client/0_filters.js +4 -1
- package/esm/client/0_params.d.ts +1 -1
- package/esm/client/0_password.d.ts +2 -2
- package/esm/client/0_password.d.ts.map +1 -1
- package/esm/client/0_storage_operations.d.ts +53 -71
- package/esm/client/0_storage_operations.d.ts.map +1 -1
- package/esm/client/0_storage_operations.js +241 -238
- package/esm/client/0_update_processor.d.ts +2 -2
- package/esm/client/0_update_processor.d.ts.map +1 -1
- package/esm/client/0_utilities.d.ts +2 -2
- package/esm/client/0_utilities.d.ts.map +1 -1
- package/esm/client/1_types.d.ts +2 -2
- package/esm/client/1_types.d.ts.map +1 -1
- package/esm/client/2_account_manager.js +5 -5
- package/esm/client/2_business_connection_manager.d.ts +1 -1
- package/esm/client/2_business_connection_manager.d.ts.map +1 -1
- package/esm/client/2_business_connection_manager.js +3 -3
- package/esm/client/2_client_encrypted.d.ts +1 -1
- package/esm/client/2_client_encrypted.d.ts.map +1 -1
- package/esm/client/2_file_manager.js +2 -2
- package/esm/client/2_payment_manager.d.ts +1 -1
- package/esm/client/2_payment_manager.d.ts.map +1 -1
- package/esm/client/2_payment_manager.js +2 -2
- package/esm/client/2_reaction_manager.d.ts +1 -1
- package/esm/client/2_reaction_manager.d.ts.map +1 -1
- package/esm/client/2_reaction_manager.js +2 -2
- package/esm/client/2_translations_manager.d.ts +1 -1
- package/esm/client/2_translations_manager.d.ts.map +1 -1
- package/esm/client/2_translations_manager.js +15 -11
- package/esm/client/2_update_manager.d.ts +4 -2
- package/esm/client/2_update_manager.d.ts.map +1 -1
- package/esm/client/2_update_manager.js +61 -79
- package/esm/client/3_message_manager.d.ts +2 -2
- package/esm/client/3_message_manager.d.ts.map +1 -1
- package/esm/client/3_message_manager.js +5 -5
- package/esm/client/3_video_chat_manager.d.ts +1 -1
- package/esm/client/3_video_chat_manager.d.ts.map +1 -1
- package/esm/client/4_callback_query_manager.d.ts +1 -1
- package/esm/client/4_callback_query_manager.d.ts.map +1 -1
- package/esm/client/4_callback_query_manager.js +1 -1
- package/esm/client/4_chat_list_manager.d.ts +2 -3
- package/esm/client/4_chat_list_manager.d.ts.map +1 -1
- package/esm/client/4_chat_list_manager.js +10 -265
- package/esm/client/4_chat_manager.d.ts +2 -2
- package/esm/client/4_chat_manager.d.ts.map +1 -1
- package/esm/client/4_chat_manager.js +7 -7
- package/esm/client/4_gift_manager.js +3 -3
- package/esm/client/4_inline_query_manager.d.ts +1 -1
- package/esm/client/4_inline_query_manager.d.ts.map +1 -1
- package/esm/client/4_inline_query_manager.js +3 -3
- package/esm/client/4_link_preview_manager.d.ts +1 -1
- package/esm/client/4_link_preview_manager.d.ts.map +1 -1
- package/esm/client/4_link_preview_manager.js +3 -3
- package/esm/client/4_poll_manager.d.ts +1 -1
- package/esm/client/4_poll_manager.d.ts.map +1 -1
- package/esm/client/4_poll_manager.js +1 -1
- package/esm/client/4_story_manager.d.ts +1 -1
- package/esm/client/4_story_manager.d.ts.map +1 -1
- package/esm/client/4_story_manager.js +7 -7
- package/esm/client/5_client.d.ts +15 -9
- package/esm/client/5_client.d.ts.map +1 -1
- package/esm/client/5_client.js +420 -382
- package/esm/deps/jsr.io/@std/cache/0.2.0/_serialize_arg_list.d.ts +12 -0
- package/esm/deps/jsr.io/@std/cache/0.2.0/_serialize_arg_list.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/cache/0.2.0/_serialize_arg_list.js +69 -0
- package/esm/deps/jsr.io/@std/cache/0.2.0/lru_cache.d.ts +112 -0
- package/esm/deps/jsr.io/@std/cache/0.2.0/lru_cache.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/cache/0.2.0/lru_cache.js +140 -0
- package/esm/deps/jsr.io/@std/cache/0.2.0/memoize.d.ts +111 -0
- package/esm/deps/jsr.io/@std/cache/0.2.0/memoize.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/cache/0.2.0/memoize.js +82 -0
- package/esm/deps/jsr.io/@std/encoding/1.0.7/hex.d.ts +39 -0
- package/esm/deps/jsr.io/@std/encoding/1.0.7/hex.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/encoding/1.0.7/hex.js +109 -0
- package/esm/session/2_session_encrypted.d.ts +1 -1
- package/esm/session/2_session_encrypted.d.ts.map +1 -1
- package/esm/session/2_session_encrypted.js +71 -72
- package/esm/storage/0_storage.d.ts +1 -0
- package/esm/storage/0_storage.d.ts.map +1 -1
- package/esm/storage/2_storage_indexed_db.d.ts +1 -0
- package/esm/storage/2_storage_indexed_db.d.ts.map +1 -1
- package/esm/storage/2_storage_indexed_db.js +3 -0
- package/esm/storage/2_storage_local_storage.node.d.ts +1 -0
- package/esm/storage/2_storage_local_storage.node.d.ts.map +1 -1
- package/esm/storage/2_storage_local_storage.node.js +3 -0
- package/esm/storage/2_storage_memory.d.ts +1 -0
- package/esm/storage/2_storage_memory.d.ts.map +1 -1
- package/esm/storage/2_storage_memory.js +3 -0
- package/esm/storage/2_storage_session_storage.d.ts +1 -0
- package/esm/storage/2_storage_session_storage.d.ts.map +1 -1
- package/esm/storage/2_storage_session_storage.js +3 -0
- package/esm/tl/0_utilities.d.ts +1 -0
- package/esm/tl/0_utilities.d.ts.map +1 -1
- package/esm/tl/0_utilities.js +20 -1
- package/esm/tl/1_telegram_api.d.ts +810 -254
- package/esm/tl/1_telegram_api.d.ts.map +1 -1
- package/esm/tl/1_telegram_api.js +912 -213
- package/esm/tl/1_tl_reader.d.ts +2 -2
- package/esm/tl/1_tl_reader.d.ts.map +1 -1
- package/esm/tl/1_tl_writer.d.ts +2 -2
- package/esm/tl/1_tl_writer.d.ts.map +1 -1
- package/esm/tl/2_mtproto.d.ts +1 -1
- package/esm/tl/2_mtproto.d.ts.map +1 -1
- package/esm/types/0_file_source.d.ts +1 -1
- package/esm/types/0_file_source.d.ts.map +1 -1
- package/esm/types/1_chat_p.d.ts +10 -0
- package/esm/types/1_chat_p.d.ts.map +1 -1
- package/esm/types/1_chat_p.js +4 -0
- package/esm/types/2_chat.d.ts +2 -5
- package/esm/types/2_chat.d.ts.map +1 -1
- package/esm/types/2_chat.js +10 -15
- package/esm/types/{0_message_entity.d.ts → 2_message_entity.d.ts} +3 -3
- package/esm/types/{0_message_entity.d.ts.map → 2_message_entity.d.ts.map} +1 -1
- package/esm/types/{0_message_entity.js → 2_message_entity.js} +7 -7
- package/esm/types/2_message_reaction_count.d.ts +2 -3
- package/esm/types/2_message_reaction_count.d.ts.map +1 -1
- package/esm/types/2_message_reaction_count.js +4 -6
- package/esm/types/2_poll_answer.d.ts +2 -3
- package/esm/types/2_poll_answer.d.ts.map +1 -1
- package/esm/types/2_poll_answer.js +4 -5
- package/esm/types/2_story_interactive_area.d.ts +2 -2
- package/esm/types/2_story_interactive_area.d.ts.map +1 -1
- package/esm/types/2_story_interactive_area.js +2 -2
- package/esm/types/{1_story_privacy.d.ts → 2_story_privacy.d.ts} +3 -3
- package/esm/types/{1_story_privacy.d.ts.map → 2_story_privacy.d.ts.map} +1 -1
- package/esm/types/{1_story_privacy.js → 2_story_privacy.js} +10 -10
- package/{script/types/1_user.d.ts → esm/types/2_user.d.ts} +5 -1
- package/esm/types/2_user.d.ts.map +1 -0
- package/esm/types/{1_user.js → 2_user.js} +24 -0
- package/esm/types/{2_business_connection.d.ts → 3_business_connection.d.ts} +4 -4
- package/esm/types/3_business_connection.d.ts.map +1 -0
- package/esm/types/{2_business_connection.js → 3_business_connection.js} +10 -3
- package/{script/types/2_chat_member.d.ts → esm/types/3_chat_member.d.ts} +6 -4
- package/esm/types/{2_chat_member.d.ts.map → 3_chat_member.d.ts.map} +1 -1
- package/esm/types/{2_chat_member.js → 3_chat_member.js} +5 -5
- package/esm/types/{2_chat_settings.d.ts → 3_chat_settings.d.ts} +2 -2
- package/{script/types/2_chat_settings.d.ts.map → esm/types/3_chat_settings.d.ts.map} +1 -1
- package/esm/types/{2_chat_settings.js → 3_chat_settings.js} +1 -1
- package/esm/types/{2_chosen_inline_result.d.ts → 3_chosen_inline_result.d.ts} +4 -4
- package/esm/types/3_chosen_inline_result.d.ts.map +1 -0
- package/esm/types/{2_chosen_inline_result.js → 3_chosen_inline_result.js} +3 -3
- package/esm/types/{2_forward_header.d.ts → 3_forward_header.d.ts} +4 -5
- package/esm/types/3_forward_header.d.ts.map +1 -0
- package/esm/types/{2_forward_header.js → 3_forward_header.js} +11 -12
- package/{script/types/2_game.d.ts → esm/types/3_game.d.ts} +2 -2
- package/esm/types/3_game.d.ts.map +1 -0
- package/esm/types/{2_gift_upgraded_component.d.ts → 3_gift_upgraded_component.d.ts} +2 -2
- package/esm/types/{2_gift_upgraded_component.d.ts.map → 3_gift_upgraded_component.d.ts.map} +1 -1
- package/esm/types/{2_gift_upgraded_component.js → 3_gift_upgraded_component.js} +1 -1
- package/esm/types/{2_inline_query.d.ts → 3_inline_query.d.ts} +4 -4
- package/esm/types/3_inline_query.d.ts.map +1 -0
- package/esm/types/{2_inline_query.js → 3_inline_query.js} +5 -5
- package/{script/types/1_input_media.d.ts → esm/types/3_input_media.d.ts} +2 -2
- package/esm/types/{1_input_media.d.ts.map → 3_input_media.d.ts.map} +1 -1
- package/{script/types/2_invite_link.d.ts → esm/types/3_invite_link.d.ts} +4 -4
- package/{script/types/2_invite_link.d.ts.map → esm/types/3_invite_link.d.ts.map} +1 -1
- package/esm/types/{2_invite_link.js → 3_invite_link.js} +5 -5
- package/{script/types/2_message_reactions.d.ts → esm/types/3_message_reactions.d.ts} +5 -6
- package/esm/types/3_message_reactions.d.ts.map +1 -0
- package/esm/types/{2_message_reactions.js → 3_message_reactions.js} +10 -12
- package/esm/types/{1_poll_option.d.ts → 3_poll_option.d.ts} +2 -2
- package/esm/types/{1_poll_option.d.ts.map → 3_poll_option.d.ts.map} +1 -1
- package/esm/types/{1_poll_option.js → 3_poll_option.js} +1 -1
- package/esm/types/{2_pre_checkout_query.d.ts → 3_pre_checkout_query.d.ts} +4 -4
- package/esm/types/3_pre_checkout_query.d.ts.map +1 -0
- package/esm/types/{2_pre_checkout_query.js → 3_pre_checkout_query.js} +5 -5
- package/{script/types/1_reply_quote.d.ts → esm/types/3_reply_quote.d.ts} +2 -2
- package/esm/types/{1_reply_quote.d.ts.map → 3_reply_quote.d.ts.map} +1 -1
- package/esm/types/{1_reply_quote.js → 3_reply_quote.js} +1 -1
- package/esm/types/3_story.d.ts +4 -5
- package/esm/types/3_story.d.ts.map +1 -1
- package/esm/types/3_story.js +6 -7
- package/esm/types/{3_chat_member_updated.d.ts → 4_chat_member_updated.d.ts} +6 -7
- package/esm/types/4_chat_member_updated.d.ts.map +1 -0
- package/esm/types/{3_chat_member_updated.js → 4_chat_member_updated.js} +13 -14
- package/esm/types/{3_gift.d.ts → 4_gift.d.ts} +6 -6
- package/esm/types/{3_gift.d.ts.map → 4_gift.d.ts.map} +1 -1
- package/esm/types/{3_gift.js → 4_gift.js} +7 -7
- package/esm/types/{3_join_request.d.ts → 4_join_request.d.ts} +6 -7
- package/esm/types/4_join_request.d.ts.map +1 -0
- package/esm/types/{3_join_request.js → 4_join_request.js} +17 -18
- package/esm/types/{2_poll.d.ts → 4_poll.d.ts} +3 -3
- package/esm/types/{2_poll.d.ts.map → 4_poll.d.ts.map} +1 -1
- package/esm/types/{2_poll.js → 4_poll.js} +2 -2
- package/{script/types/2_reply_to.d.ts → esm/types/4_reply_to.d.ts} +2 -2
- package/esm/types/{2_reply_to.d.ts.map → 4_reply_to.d.ts.map} +1 -1
- package/esm/types/{4_claimed_gift.d.ts → 5_claimed_gift.d.ts} +5 -6
- package/esm/types/5_claimed_gift.d.ts.map +1 -0
- package/esm/types/{4_claimed_gift.js → 5_claimed_gift.js} +4 -4
- package/esm/types/{4_link_preview.d.ts → 5_link_preview.d.ts} +4 -4
- package/{script/types/4_link_preview.d.ts.map → esm/types/5_link_preview.d.ts.map} +1 -1
- package/esm/types/{4_link_preview.js → 5_link_preview.js} +3 -3
- package/esm/types/{5_claimed_gifts.d.ts → 6_claimed_gifts.d.ts} +4 -4
- package/esm/types/6_claimed_gifts.d.ts.map +1 -0
- package/esm/types/{5_claimed_gifts.js → 6_claimed_gifts.js} +4 -4
- package/esm/types/{5_message.d.ts → 6_message.d.ts} +10 -11
- package/esm/types/6_message.d.ts.map +1 -0
- package/esm/types/{5_message.js → 6_message.js} +41 -66
- package/{script/types/5_message_content.d.ts → esm/types/6_message_content.d.ts} +3 -3
- package/esm/types/{5_message_content.d.ts.map → 6_message_content.d.ts.map} +1 -1
- package/{script/types/6_callback_query.d.ts → esm/types/7_callback_query.d.ts} +5 -5
- package/esm/types/{6_callback_query.d.ts.map → 7_callback_query.d.ts.map} +1 -1
- package/esm/types/{6_callback_query.js → 7_callback_query.js} +5 -5
- package/{script/types/6_chat_list_item.d.ts → esm/types/7_chat_list_item.d.ts} +6 -7
- package/esm/types/7_chat_list_item.d.ts.map +1 -0
- package/esm/types/{6_chat_list_item.js → 7_chat_list_item.js} +11 -11
- package/{script/types/6_inline_query_result.d.ts → esm/types/7_inline_query_result.d.ts} +3 -3
- package/esm/types/{6_inline_query_result.d.ts.map → 7_inline_query_result.d.ts.map} +1 -1
- package/esm/types/{6_inline_query_result.js → 7_inline_query_result.js} +1 -1
- package/esm/types/{6_saved_chat.d.ts → 7_saved_chat.d.ts} +4 -5
- package/esm/types/7_saved_chat.d.ts.map +1 -0
- package/esm/types/{6_saved_chat.js → 7_saved_chat.js} +4 -4
- package/esm/types/{6_topic.d.ts → 7_topic.d.ts} +2 -2
- package/esm/types/{6_topic.d.ts.map → 7_topic.d.ts.map} +1 -1
- package/esm/types/{7_inline_query_answer.d.ts → 8_inline_query_answer.d.ts} +2 -2
- package/esm/types/{7_inline_query_answer.d.ts.map → 8_inline_query_answer.d.ts.map} +1 -1
- package/esm/types/{7_inline_query_answer.js → 8_inline_query_answer.js} +1 -1
- package/{script/types/7_saved_chats.d.ts → esm/types/8_saved_chats.d.ts} +5 -5
- package/esm/types/8_saved_chats.d.ts.map +1 -0
- package/esm/types/{7_saved_chats.js → 8_saved_chats.js} +3 -3
- package/esm/types/{7_update.d.ts → 8_update.d.ts} +35 -16
- package/esm/types/8_update.d.ts.map +1 -0
- package/esm/types/_file_id.d.ts +1 -1
- package/esm/types/_file_id.d.ts.map +1 -1
- package/esm/types/_getters.d.ts +0 -7
- package/esm/types/_getters.d.ts.map +1 -1
- package/esm/utilities/0_hash.d.ts +2 -2
- package/esm/utilities/0_hash.d.ts.map +1 -1
- package/esm/utilities/0_misc.d.ts +1 -0
- package/esm/utilities/0_misc.d.ts.map +1 -1
- package/esm/utilities/0_misc.js +14 -1
- package/esm/utilities/0_part_stream.d.ts +1 -1
- package/esm/utilities/0_part_stream.d.ts.map +1 -1
- package/package.json +1 -1
- package/script/0_deps.d.ts +3 -1
- package/script/0_deps.d.ts.map +1 -1
- package/script/0_deps.js +6 -1
- package/script/3_types.d.ts +35 -35
- package/script/3_types.d.ts.map +1 -1
- package/script/3_types.js +35 -35
- package/script/_dnt.polyfills.d.ts +7 -0
- package/script/_dnt.polyfills.d.ts.map +1 -1
- package/script/_dnt.polyfills.js +109 -0
- package/script/client/0_abortable_loop.d.ts +27 -0
- package/script/client/0_abortable_loop.d.ts.map +1 -0
- package/script/client/0_abortable_loop.js +53 -0
- package/script/client/0_filters.d.ts +9 -3
- package/script/client/0_filters.d.ts.map +1 -1
- package/script/client/0_filters.js +4 -1
- package/script/client/0_params.d.ts +1 -1
- package/script/client/0_password.d.ts +2 -2
- package/script/client/0_password.d.ts.map +1 -1
- package/script/client/0_storage_operations.d.ts +53 -71
- package/script/client/0_storage_operations.d.ts.map +1 -1
- package/script/client/0_storage_operations.js +239 -236
- package/script/client/0_update_processor.d.ts +2 -2
- package/script/client/0_update_processor.d.ts.map +1 -1
- package/script/client/0_utilities.d.ts +2 -2
- package/script/client/0_utilities.d.ts.map +1 -1
- package/script/client/1_types.d.ts +2 -2
- package/script/client/1_types.d.ts.map +1 -1
- package/script/client/2_account_manager.js +5 -5
- package/script/client/2_business_connection_manager.d.ts +1 -1
- package/script/client/2_business_connection_manager.d.ts.map +1 -1
- package/script/client/2_business_connection_manager.js +3 -3
- package/script/client/2_client_encrypted.d.ts +1 -1
- package/script/client/2_client_encrypted.d.ts.map +1 -1
- package/script/client/2_file_manager.js +2 -2
- package/script/client/2_payment_manager.d.ts +1 -1
- package/script/client/2_payment_manager.d.ts.map +1 -1
- package/script/client/2_payment_manager.js +2 -2
- package/script/client/2_reaction_manager.d.ts +1 -1
- package/script/client/2_reaction_manager.d.ts.map +1 -1
- package/script/client/2_reaction_manager.js +2 -2
- package/script/client/2_translations_manager.d.ts +1 -1
- package/script/client/2_translations_manager.d.ts.map +1 -1
- package/script/client/2_translations_manager.js +15 -11
- package/script/client/2_update_manager.d.ts +4 -2
- package/script/client/2_update_manager.d.ts.map +1 -1
- package/script/client/2_update_manager.js +61 -79
- package/script/client/3_message_manager.d.ts +2 -2
- package/script/client/3_message_manager.d.ts.map +1 -1
- package/script/client/3_message_manager.js +5 -5
- package/script/client/3_video_chat_manager.d.ts +1 -1
- package/script/client/3_video_chat_manager.d.ts.map +1 -1
- package/script/client/4_callback_query_manager.d.ts +1 -1
- package/script/client/4_callback_query_manager.d.ts.map +1 -1
- package/script/client/4_callback_query_manager.js +1 -1
- package/script/client/4_chat_list_manager.d.ts +2 -3
- package/script/client/4_chat_list_manager.d.ts.map +1 -1
- package/script/client/4_chat_list_manager.js +9 -264
- package/script/client/4_chat_manager.d.ts +2 -2
- package/script/client/4_chat_manager.d.ts.map +1 -1
- package/script/client/4_chat_manager.js +7 -7
- package/script/client/4_gift_manager.js +3 -3
- package/script/client/4_inline_query_manager.d.ts +1 -1
- package/script/client/4_inline_query_manager.d.ts.map +1 -1
- package/script/client/4_inline_query_manager.js +3 -3
- package/script/client/4_link_preview_manager.d.ts +1 -1
- package/script/client/4_link_preview_manager.d.ts.map +1 -1
- package/script/client/4_link_preview_manager.js +3 -3
- package/script/client/4_poll_manager.d.ts +1 -1
- package/script/client/4_poll_manager.d.ts.map +1 -1
- package/script/client/4_poll_manager.js +1 -1
- package/script/client/4_story_manager.d.ts +1 -1
- package/script/client/4_story_manager.d.ts.map +1 -1
- package/script/client/4_story_manager.js +7 -7
- package/script/client/5_client.d.ts +15 -9
- package/script/client/5_client.d.ts.map +1 -1
- package/script/client/5_client.js +418 -380
- package/script/deps/jsr.io/@std/cache/0.2.0/_serialize_arg_list.d.ts +12 -0
- package/script/deps/jsr.io/@std/cache/0.2.0/_serialize_arg_list.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/cache/0.2.0/_serialize_arg_list.js +72 -0
- package/script/deps/jsr.io/@std/cache/0.2.0/lru_cache.d.ts +112 -0
- package/script/deps/jsr.io/@std/cache/0.2.0/lru_cache.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/cache/0.2.0/lru_cache.js +144 -0
- package/script/deps/jsr.io/@std/cache/0.2.0/memoize.d.ts +111 -0
- package/script/deps/jsr.io/@std/cache/0.2.0/memoize.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/cache/0.2.0/memoize.js +85 -0
- package/script/deps/jsr.io/@std/encoding/1.0.7/hex.d.ts +39 -0
- package/script/deps/jsr.io/@std/encoding/1.0.7/hex.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/encoding/1.0.7/hex.js +113 -0
- package/script/session/2_session_encrypted.d.ts +1 -1
- package/script/session/2_session_encrypted.d.ts.map +1 -1
- package/script/session/2_session_encrypted.js +70 -71
- package/script/storage/0_storage.d.ts +1 -0
- package/script/storage/0_storage.d.ts.map +1 -1
- package/script/storage/2_storage_indexed_db.d.ts +1 -0
- package/script/storage/2_storage_indexed_db.d.ts.map +1 -1
- package/script/storage/2_storage_indexed_db.js +3 -0
- package/script/storage/2_storage_local_storage.node.d.ts +1 -0
- package/script/storage/2_storage_local_storage.node.d.ts.map +1 -1
- package/script/storage/2_storage_local_storage.node.js +3 -0
- package/script/storage/2_storage_memory.d.ts +1 -0
- package/script/storage/2_storage_memory.d.ts.map +1 -1
- package/script/storage/2_storage_memory.js +3 -0
- package/script/storage/2_storage_session_storage.d.ts +1 -0
- package/script/storage/2_storage_session_storage.d.ts.map +1 -1
- package/script/storage/2_storage_session_storage.js +3 -0
- package/script/tl/0_utilities.d.ts +1 -0
- package/script/tl/0_utilities.d.ts.map +1 -1
- package/script/tl/0_utilities.js +20 -0
- package/script/tl/1_telegram_api.d.ts +810 -254
- package/script/tl/1_telegram_api.d.ts.map +1 -1
- package/script/tl/1_telegram_api.js +912 -213
- package/script/tl/1_tl_reader.d.ts +2 -2
- package/script/tl/1_tl_reader.d.ts.map +1 -1
- package/script/tl/1_tl_writer.d.ts +2 -2
- package/script/tl/1_tl_writer.d.ts.map +1 -1
- package/script/tl/2_mtproto.d.ts +1 -1
- package/script/tl/2_mtproto.d.ts.map +1 -1
- package/script/types/0_file_source.d.ts +1 -1
- package/script/types/0_file_source.d.ts.map +1 -1
- package/script/types/1_chat_p.d.ts +10 -0
- package/script/types/1_chat_p.d.ts.map +1 -1
- package/script/types/1_chat_p.js +5 -0
- package/script/types/2_chat.d.ts +2 -5
- package/script/types/2_chat.d.ts.map +1 -1
- package/script/types/2_chat.js +10 -15
- package/script/types/{0_message_entity.d.ts → 2_message_entity.d.ts} +3 -3
- package/script/types/{0_message_entity.d.ts.map → 2_message_entity.d.ts.map} +1 -1
- package/script/types/{0_message_entity.js → 2_message_entity.js} +7 -7
- package/script/types/2_message_reaction_count.d.ts +2 -3
- package/script/types/2_message_reaction_count.d.ts.map +1 -1
- package/script/types/2_message_reaction_count.js +4 -6
- package/script/types/2_poll_answer.d.ts +2 -3
- package/script/types/2_poll_answer.d.ts.map +1 -1
- package/script/types/2_poll_answer.js +4 -5
- package/script/types/2_story_interactive_area.d.ts +2 -2
- package/script/types/2_story_interactive_area.d.ts.map +1 -1
- package/script/types/2_story_interactive_area.js +2 -2
- package/script/types/{1_story_privacy.d.ts → 2_story_privacy.d.ts} +3 -3
- package/script/types/{1_story_privacy.d.ts.map → 2_story_privacy.d.ts.map} +1 -1
- package/script/types/{1_story_privacy.js → 2_story_privacy.js} +10 -10
- package/{esm/types/1_user.d.ts → script/types/2_user.d.ts} +5 -1
- package/script/types/2_user.d.ts.map +1 -0
- package/script/types/{1_user.js → 2_user.js} +25 -0
- package/script/types/{2_business_connection.d.ts → 3_business_connection.d.ts} +4 -4
- package/script/types/3_business_connection.d.ts.map +1 -0
- package/script/types/{2_business_connection.js → 3_business_connection.js} +10 -3
- package/{esm/types/2_chat_member.d.ts → script/types/3_chat_member.d.ts} +6 -4
- package/script/types/{2_chat_member.d.ts.map → 3_chat_member.d.ts.map} +1 -1
- package/script/types/{2_chat_member.js → 3_chat_member.js} +5 -5
- package/script/types/{2_chat_settings.d.ts → 3_chat_settings.d.ts} +2 -2
- package/{esm/types/2_chat_settings.d.ts.map → script/types/3_chat_settings.d.ts.map} +1 -1
- package/script/types/{2_chat_settings.js → 3_chat_settings.js} +2 -2
- package/script/types/{2_chosen_inline_result.d.ts → 3_chosen_inline_result.d.ts} +4 -4
- package/script/types/3_chosen_inline_result.d.ts.map +1 -0
- package/script/types/{2_chosen_inline_result.js → 3_chosen_inline_result.js} +4 -4
- package/script/types/{2_forward_header.d.ts → 3_forward_header.d.ts} +4 -5
- package/script/types/3_forward_header.d.ts.map +1 -0
- package/script/types/{2_forward_header.js → 3_forward_header.js} +11 -12
- package/{esm/types/2_game.d.ts → script/types/3_game.d.ts} +2 -2
- package/script/types/3_game.d.ts.map +1 -0
- package/script/types/{2_gift_upgraded_component.d.ts → 3_gift_upgraded_component.d.ts} +2 -2
- package/script/types/{2_gift_upgraded_component.d.ts.map → 3_gift_upgraded_component.d.ts.map} +1 -1
- package/script/types/{2_gift_upgraded_component.js → 3_gift_upgraded_component.js} +2 -2
- package/script/types/{2_inline_query.d.ts → 3_inline_query.d.ts} +4 -4
- package/script/types/3_inline_query.d.ts.map +1 -0
- package/script/types/{2_inline_query.js → 3_inline_query.js} +5 -5
- package/{esm/types/1_input_media.d.ts → script/types/3_input_media.d.ts} +2 -2
- package/script/types/{1_input_media.d.ts.map → 3_input_media.d.ts.map} +1 -1
- package/{esm/types/2_invite_link.d.ts → script/types/3_invite_link.d.ts} +4 -4
- package/{esm/types/2_invite_link.d.ts.map → script/types/3_invite_link.d.ts.map} +1 -1
- package/script/types/{2_invite_link.js → 3_invite_link.js} +5 -5
- package/{esm/types/2_message_reactions.d.ts → script/types/3_message_reactions.d.ts} +5 -6
- package/script/types/3_message_reactions.d.ts.map +1 -0
- package/script/types/{2_message_reactions.js → 3_message_reactions.js} +10 -12
- package/script/types/{1_poll_option.d.ts → 3_poll_option.d.ts} +2 -2
- package/script/types/{1_poll_option.d.ts.map → 3_poll_option.d.ts.map} +1 -1
- package/script/types/{1_poll_option.js → 3_poll_option.js} +2 -2
- package/script/types/{2_pre_checkout_query.d.ts → 3_pre_checkout_query.d.ts} +4 -4
- package/script/types/3_pre_checkout_query.d.ts.map +1 -0
- package/script/types/{2_pre_checkout_query.js → 3_pre_checkout_query.js} +5 -5
- package/{esm/types/1_reply_quote.d.ts → script/types/3_reply_quote.d.ts} +2 -2
- package/script/types/{1_reply_quote.d.ts.map → 3_reply_quote.d.ts.map} +1 -1
- package/script/types/{1_reply_quote.js → 3_reply_quote.js} +2 -2
- package/script/types/3_story.d.ts +4 -5
- package/script/types/3_story.d.ts.map +1 -1
- package/script/types/3_story.js +8 -9
- package/script/types/{3_chat_member_updated.d.ts → 4_chat_member_updated.d.ts} +6 -7
- package/script/types/4_chat_member_updated.d.ts.map +1 -0
- package/script/types/{3_chat_member_updated.js → 4_chat_member_updated.js} +13 -14
- package/script/types/{3_gift.d.ts → 4_gift.d.ts} +6 -6
- package/script/types/{3_gift.d.ts.map → 4_gift.d.ts.map} +1 -1
- package/script/types/{3_gift.js → 4_gift.js} +9 -9
- package/script/types/{3_join_request.d.ts → 4_join_request.d.ts} +6 -7
- package/script/types/4_join_request.d.ts.map +1 -0
- package/script/types/{3_join_request.js → 4_join_request.js} +17 -18
- package/script/types/{2_poll.d.ts → 4_poll.d.ts} +3 -3
- package/script/types/{2_poll.d.ts.map → 4_poll.d.ts.map} +1 -1
- package/script/types/{2_poll.js → 4_poll.js} +5 -5
- package/{esm/types/2_reply_to.d.ts → script/types/4_reply_to.d.ts} +2 -2
- package/script/types/{2_reply_to.d.ts.map → 4_reply_to.d.ts.map} +1 -1
- package/script/types/{4_claimed_gift.d.ts → 5_claimed_gift.d.ts} +5 -6
- package/script/types/5_claimed_gift.d.ts.map +1 -0
- package/script/types/{4_claimed_gift.js → 5_claimed_gift.js} +5 -5
- package/script/types/{4_link_preview.d.ts → 5_link_preview.d.ts} +4 -4
- package/{esm/types/4_link_preview.d.ts.map → script/types/5_link_preview.d.ts.map} +1 -1
- package/script/types/{4_link_preview.js → 5_link_preview.js} +3 -3
- package/script/types/{5_claimed_gifts.d.ts → 6_claimed_gifts.d.ts} +4 -4
- package/script/types/6_claimed_gifts.d.ts.map +1 -0
- package/script/types/{5_claimed_gifts.js → 6_claimed_gifts.js} +4 -4
- package/script/types/{5_message.d.ts → 6_message.d.ts} +10 -11
- package/script/types/6_message.d.ts.map +1 -0
- package/script/types/{5_message.js → 6_message.js} +45 -70
- package/{esm/types/5_message_content.d.ts → script/types/6_message_content.d.ts} +3 -3
- package/script/types/{5_message_content.d.ts.map → 6_message_content.d.ts.map} +1 -1
- package/{esm/types/6_callback_query.d.ts → script/types/7_callback_query.d.ts} +5 -5
- package/script/types/{6_callback_query.d.ts.map → 7_callback_query.d.ts.map} +1 -1
- package/script/types/{6_callback_query.js → 7_callback_query.js} +5 -5
- package/{esm/types/6_chat_list_item.d.ts → script/types/7_chat_list_item.d.ts} +6 -7
- package/script/types/7_chat_list_item.d.ts.map +1 -0
- package/script/types/{6_chat_list_item.js → 7_chat_list_item.js} +11 -11
- package/{esm/types/6_inline_query_result.d.ts → script/types/7_inline_query_result.d.ts} +3 -3
- package/script/types/{6_inline_query_result.d.ts.map → 7_inline_query_result.d.ts.map} +1 -1
- package/script/types/{6_inline_query_result.js → 7_inline_query_result.js} +3 -3
- package/script/types/{6_saved_chat.d.ts → 7_saved_chat.d.ts} +4 -5
- package/script/types/7_saved_chat.d.ts.map +1 -0
- package/script/types/{6_saved_chat.js → 7_saved_chat.js} +4 -4
- package/script/types/{6_topic.d.ts → 7_topic.d.ts} +2 -2
- package/script/types/{6_topic.d.ts.map → 7_topic.d.ts.map} +1 -1
- package/script/types/{7_inline_query_answer.d.ts → 8_inline_query_answer.d.ts} +2 -2
- package/script/types/{7_inline_query_answer.d.ts.map → 8_inline_query_answer.d.ts.map} +1 -1
- package/script/types/{7_inline_query_answer.js → 8_inline_query_answer.js} +2 -2
- package/{esm/types/7_saved_chats.d.ts → script/types/8_saved_chats.d.ts} +5 -5
- package/script/types/8_saved_chats.d.ts.map +1 -0
- package/script/types/{7_saved_chats.js → 8_saved_chats.js} +3 -3
- package/script/types/{7_update.d.ts → 8_update.d.ts} +35 -16
- package/script/types/8_update.d.ts.map +1 -0
- package/script/types/_file_id.d.ts +1 -1
- package/script/types/_file_id.d.ts.map +1 -1
- package/script/types/_getters.d.ts +0 -7
- package/script/types/_getters.d.ts.map +1 -1
- package/script/utilities/0_hash.d.ts +2 -2
- package/script/utilities/0_hash.d.ts.map +1 -1
- package/script/utilities/0_misc.d.ts +1 -0
- package/script/utilities/0_misc.d.ts.map +1 -1
- package/script/utilities/0_misc.js +14 -0
- package/script/utilities/0_part_stream.d.ts +1 -1
- package/script/utilities/0_part_stream.d.ts.map +1 -1
- package/esm/types/1_user.d.ts.map +0 -1
- package/esm/types/2_business_connection.d.ts.map +0 -1
- package/esm/types/2_chosen_inline_result.d.ts.map +0 -1
- package/esm/types/2_forward_header.d.ts.map +0 -1
- package/esm/types/2_game.d.ts.map +0 -1
- package/esm/types/2_inline_query.d.ts.map +0 -1
- package/esm/types/2_message_reactions.d.ts.map +0 -1
- package/esm/types/2_pre_checkout_query.d.ts.map +0 -1
- package/esm/types/3_chat_member_updated.d.ts.map +0 -1
- package/esm/types/3_join_request.d.ts.map +0 -1
- package/esm/types/4_claimed_gift.d.ts.map +0 -1
- package/esm/types/5_claimed_gifts.d.ts.map +0 -1
- package/esm/types/5_message.d.ts.map +0 -1
- package/esm/types/6_chat_list_item.d.ts.map +0 -1
- package/esm/types/6_saved_chat.d.ts.map +0 -1
- package/esm/types/7_saved_chats.d.ts.map +0 -1
- package/esm/types/7_update.d.ts.map +0 -1
- package/script/types/1_user.d.ts.map +0 -1
- package/script/types/2_business_connection.d.ts.map +0 -1
- package/script/types/2_chosen_inline_result.d.ts.map +0 -1
- package/script/types/2_forward_header.d.ts.map +0 -1
- package/script/types/2_game.d.ts.map +0 -1
- package/script/types/2_inline_query.d.ts.map +0 -1
- package/script/types/2_message_reactions.d.ts.map +0 -1
- package/script/types/2_pre_checkout_query.d.ts.map +0 -1
- package/script/types/3_chat_member_updated.d.ts.map +0 -1
- package/script/types/3_join_request.d.ts.map +0 -1
- package/script/types/4_claimed_gift.d.ts.map +0 -1
- package/script/types/5_claimed_gifts.d.ts.map +0 -1
- package/script/types/5_message.d.ts.map +0 -1
- package/script/types/6_chat_list_item.d.ts.map +0 -1
- package/script/types/6_saved_chat.d.ts.map +0 -1
- package/script/types/7_saved_chats.d.ts.map +0 -1
- package/script/types/7_update.d.ts.map +0 -1
- /package/esm/types/{2_game.js → 3_game.js} +0 -0
- /package/esm/types/{1_input_media.js → 3_input_media.js} +0 -0
- /package/esm/types/{2_reply_to.js → 4_reply_to.js} +0 -0
- /package/esm/types/{5_message_content.js → 6_message_content.js} +0 -0
- /package/esm/types/{6_topic.js → 7_topic.js} +0 -0
- /package/esm/types/{7_update.js → 8_update.js} +0 -0
- /package/script/types/{2_game.js → 3_game.js} +0 -0
- /package/script/types/{1_input_media.js → 3_input_media.js} +0 -0
- /package/script/types/{2_reply_to.js → 4_reply_to.js} +0 -0
- /package/script/types/{5_message_content.js → 6_message_content.js} +0 -0
- /package/script/types/{6_topic.js → 7_topic.js} +0 -0
- /package/script/types/{7_update.js → 8_update.js} +0 -0
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { MemoizationCache } from "./memoize.js";
|
|
2
|
+
/**
|
|
3
|
+
* Default serialization of arguments list for use as cache keys. Equivalence
|
|
4
|
+
* follows [`SameValueZero`](https://tc39.es/ecma262/multipage/abstract-operations.html#sec-samevaluezero)
|
|
5
|
+
* reference equality, such that `getKey(x, y) === getKey(x, y)` for all values
|
|
6
|
+
* of `x` and `y`, but `getKey({}) !== getKey({})`.
|
|
7
|
+
*
|
|
8
|
+
* @param cache The cache for which the keys will be used.
|
|
9
|
+
* @returns `getKey`, the function for getting cache keys.
|
|
10
|
+
*/
|
|
11
|
+
export declare function _serializeArgList<Return>(cache: MemoizationCache<unknown, Return>): (this: unknown, ...args: unknown[]) => string;
|
|
12
|
+
//# sourceMappingURL=_serialize_arg_list.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"_serialize_arg_list.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/cache/0.2.0/_serialize_arg_list.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAErD;;;;;;;;GAQG;AAEH,wBAAgB,iBAAiB,CAAC,MAAM,EACtC,KAAK,EAAE,gBAAgB,CAAC,OAAO,EAAE,MAAM,CAAC,GACvC,CAAC,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,MAAM,CAmE/C"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Default serialization of arguments list for use as cache keys. Equivalence
|
|
3
|
+
* follows [`SameValueZero`](https://tc39.es/ecma262/multipage/abstract-operations.html#sec-samevaluezero)
|
|
4
|
+
* reference equality, such that `getKey(x, y) === getKey(x, y)` for all values
|
|
5
|
+
* of `x` and `y`, but `getKey({}) !== getKey({})`.
|
|
6
|
+
*
|
|
7
|
+
* @param cache The cache for which the keys will be used.
|
|
8
|
+
* @returns `getKey`, the function for getting cache keys.
|
|
9
|
+
*/
|
|
10
|
+
export function _serializeArgList(cache) {
|
|
11
|
+
const weakKeyToKeySegmentCache = new WeakMap();
|
|
12
|
+
const weakKeySegmentToKeyCache = new Map();
|
|
13
|
+
let i = 0;
|
|
14
|
+
const registry = new FinalizationRegistry((keySegment) => {
|
|
15
|
+
for (const key of weakKeySegmentToKeyCache.get(keySegment) ?? []) {
|
|
16
|
+
cache.delete(key);
|
|
17
|
+
}
|
|
18
|
+
weakKeySegmentToKeyCache.delete(keySegment);
|
|
19
|
+
});
|
|
20
|
+
return function getKey(...args) {
|
|
21
|
+
const weakKeySegments = [];
|
|
22
|
+
const keySegments = [this, ...args].map((arg) => {
|
|
23
|
+
if (typeof arg === "undefined")
|
|
24
|
+
return "undefined";
|
|
25
|
+
if (typeof arg === "bigint")
|
|
26
|
+
return `${arg}n`;
|
|
27
|
+
if (typeof arg === "number") {
|
|
28
|
+
return String(arg);
|
|
29
|
+
}
|
|
30
|
+
if (arg === null ||
|
|
31
|
+
typeof arg === "string" ||
|
|
32
|
+
typeof arg === "boolean") {
|
|
33
|
+
// This branch will need to be updated if further types are added to
|
|
34
|
+
// the language that support value equality,
|
|
35
|
+
// e.g. https://github.com/tc39/proposal-record-tuple
|
|
36
|
+
return JSON.stringify(arg);
|
|
37
|
+
}
|
|
38
|
+
try {
|
|
39
|
+
assertWeakKey(arg);
|
|
40
|
+
}
|
|
41
|
+
catch {
|
|
42
|
+
if (typeof arg === "symbol") {
|
|
43
|
+
return `Symbol.for(${JSON.stringify(arg.description)})`;
|
|
44
|
+
}
|
|
45
|
+
// Non-weak keys other than `Symbol.for(...)` are handled by the branches above.
|
|
46
|
+
throw new Error("Should be unreachable: please open an issue at https://github.com/denoland/std/issues/new");
|
|
47
|
+
}
|
|
48
|
+
if (!weakKeyToKeySegmentCache.has(arg)) {
|
|
49
|
+
const keySegment = `{${i++}}`;
|
|
50
|
+
weakKeySegments.push(keySegment);
|
|
51
|
+
registry.register(arg, keySegment);
|
|
52
|
+
weakKeyToKeySegmentCache.set(arg, keySegment);
|
|
53
|
+
}
|
|
54
|
+
const keySegment = weakKeyToKeySegmentCache.get(arg);
|
|
55
|
+
weakKeySegments.push(keySegment);
|
|
56
|
+
return keySegment;
|
|
57
|
+
});
|
|
58
|
+
const key = keySegments.join(",");
|
|
59
|
+
for (const keySegment of weakKeySegments) {
|
|
60
|
+
const keys = weakKeySegmentToKeyCache.get(keySegment) ?? [];
|
|
61
|
+
keys.push(key);
|
|
62
|
+
weakKeySegmentToKeyCache.set(keySegment, keys);
|
|
63
|
+
}
|
|
64
|
+
return key;
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
function assertWeakKey(arg) {
|
|
68
|
+
new WeakRef(arg);
|
|
69
|
+
}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import type { MemoizationCache } from "./memoize.js";
|
|
2
|
+
export type { MemoizationCache };
|
|
3
|
+
/**
|
|
4
|
+
* Least-recently-used cache.
|
|
5
|
+
*
|
|
6
|
+
* @experimental **UNSTABLE**: New API, yet to be vetted.
|
|
7
|
+
*
|
|
8
|
+
* @see {@link https://en.wikipedia.org/wiki/Cache_replacement_policies#LRU | Least-recently-used cache}
|
|
9
|
+
*
|
|
10
|
+
* Automatically removes entries above the max size based on when they were
|
|
11
|
+
* last accessed with `get`, `set`, or `has`.
|
|
12
|
+
*
|
|
13
|
+
* @typeParam K The type of the cache keys.
|
|
14
|
+
* @typeParam V The type of the cache values.
|
|
15
|
+
*
|
|
16
|
+
* @example Basic usage
|
|
17
|
+
* ```ts
|
|
18
|
+
* import { LruCache } from "@std/cache";
|
|
19
|
+
* import { assert, assertEquals } from "@std/assert";
|
|
20
|
+
*
|
|
21
|
+
* const MAX_SIZE = 3;
|
|
22
|
+
* const cache = new LruCache<string, number>(MAX_SIZE);
|
|
23
|
+
*
|
|
24
|
+
* cache.set("a", 1);
|
|
25
|
+
* cache.set("b", 2);
|
|
26
|
+
* cache.set("c", 3);
|
|
27
|
+
* cache.set("d", 4);
|
|
28
|
+
*
|
|
29
|
+
* // most recent values are stored up to `MAX_SIZE`
|
|
30
|
+
* assertEquals(cache.get("b"), 2);
|
|
31
|
+
* assertEquals(cache.get("c"), 3);
|
|
32
|
+
* assertEquals(cache.get("d"), 4);
|
|
33
|
+
*
|
|
34
|
+
* // less recent values are removed
|
|
35
|
+
* assert(!cache.has("a"));
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
export declare class LruCache<K, V> extends Map<K, V> implements MemoizationCache<K, V> {
|
|
39
|
+
#private;
|
|
40
|
+
/**
|
|
41
|
+
* The maximum number of entries to store in the cache.
|
|
42
|
+
*
|
|
43
|
+
* @example Max size
|
|
44
|
+
* ```ts no-assert
|
|
45
|
+
* import { LruCache } from "@std/cache";
|
|
46
|
+
* import { assertEquals } from "@std/assert";
|
|
47
|
+
*
|
|
48
|
+
* const cache = new LruCache<string, number>(100);
|
|
49
|
+
* assertEquals(cache.maxSize, 100);
|
|
50
|
+
* ```
|
|
51
|
+
*/
|
|
52
|
+
maxSize: number;
|
|
53
|
+
/**
|
|
54
|
+
* Constructs a new `LruCache`.
|
|
55
|
+
*
|
|
56
|
+
* @param maxSize The maximum number of entries to store in the cache.
|
|
57
|
+
*/
|
|
58
|
+
constructor(maxSize: number);
|
|
59
|
+
/**
|
|
60
|
+
* Checks whether an element with the specified key exists or not.
|
|
61
|
+
*
|
|
62
|
+
* @param key The key to check.
|
|
63
|
+
* @returns `true` if the cache contains the specified key, otherwise `false`.
|
|
64
|
+
*
|
|
65
|
+
* @example Checking for the existence of a key
|
|
66
|
+
* ```ts
|
|
67
|
+
* import { LruCache } from "@std/cache";
|
|
68
|
+
* import { assert } from "@std/assert";
|
|
69
|
+
*
|
|
70
|
+
* const cache = new LruCache<string, number>(100);
|
|
71
|
+
*
|
|
72
|
+
* cache.set("a", 1);
|
|
73
|
+
* assert(cache.has("a"));
|
|
74
|
+
* ```
|
|
75
|
+
*/
|
|
76
|
+
has(key: K): boolean;
|
|
77
|
+
/**
|
|
78
|
+
* Gets the element with the specified key.
|
|
79
|
+
*
|
|
80
|
+
* @param key The key to get the value for.
|
|
81
|
+
* @returns The value associated with the specified key, or `undefined` if the key is not present in the cache.
|
|
82
|
+
*
|
|
83
|
+
* @example Getting a value from the cache
|
|
84
|
+
* ```ts
|
|
85
|
+
* import { LruCache } from "@std/cache";
|
|
86
|
+
* import { assertEquals } from "@std/assert";
|
|
87
|
+
*
|
|
88
|
+
* const cache = new LruCache<string, number>(100);
|
|
89
|
+
*
|
|
90
|
+
* cache.set("a", 1);
|
|
91
|
+
* assertEquals(cache.get("a"), 1);
|
|
92
|
+
* ```
|
|
93
|
+
*/
|
|
94
|
+
get(key: K): V | undefined;
|
|
95
|
+
/**
|
|
96
|
+
* Sets the specified key to the specified value.
|
|
97
|
+
*
|
|
98
|
+
* @param key The key to set the value for.
|
|
99
|
+
* @param value The value to set.
|
|
100
|
+
* @returns `this` for chaining.
|
|
101
|
+
*
|
|
102
|
+
* @example Setting a value in the cache
|
|
103
|
+
* ```ts no-assert
|
|
104
|
+
* import { LruCache } from "@std/cache";
|
|
105
|
+
*
|
|
106
|
+
* const cache = new LruCache<string, number>(100);
|
|
107
|
+
* cache.set("a", 1);
|
|
108
|
+
* ```
|
|
109
|
+
*/
|
|
110
|
+
set(key: K, value: V): this;
|
|
111
|
+
}
|
|
112
|
+
//# sourceMappingURL=lru_cache.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lru_cache.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/cache/0.2.0/lru_cache.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AACrD,YAAY,EAAE,gBAAgB,EAAE,CAAC;AAEjC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,qBAAa,QAAQ,CAAC,CAAC,EAAE,CAAC,CAAE,SAAQ,GAAG,CAAC,CAAC,EAAE,CAAC,CAC1C,YAAW,gBAAgB,CAAC,CAAC,EAAE,CAAC,CAAC;;IACjC;;;;;;;;;;;OAWG;IACH,OAAO,EAAE,MAAM,CAAC;IAEhB;;;;OAIG;gBACS,OAAO,EAAE,MAAM;IAiB3B;;;;;;;;;;;;;;;;OAgBG;IACM,GAAG,CAAC,GAAG,EAAE,CAAC,GAAG,OAAO;IAU7B;;;;;;;;;;;;;;;;OAgBG;IACM,GAAG,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,GAAG,SAAS;IAUnC;;;;;;;;;;;;;;OAcG;IACM,GAAG,CAAC,GAAG,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,IAAI;CAMrC"}
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
// Copyright 2018-2025 the Deno authors. MIT license.
|
|
2
|
+
// This module is browser compatible.
|
|
3
|
+
/**
|
|
4
|
+
* Least-recently-used cache.
|
|
5
|
+
*
|
|
6
|
+
* @experimental **UNSTABLE**: New API, yet to be vetted.
|
|
7
|
+
*
|
|
8
|
+
* @see {@link https://en.wikipedia.org/wiki/Cache_replacement_policies#LRU | Least-recently-used cache}
|
|
9
|
+
*
|
|
10
|
+
* Automatically removes entries above the max size based on when they were
|
|
11
|
+
* last accessed with `get`, `set`, or `has`.
|
|
12
|
+
*
|
|
13
|
+
* @typeParam K The type of the cache keys.
|
|
14
|
+
* @typeParam V The type of the cache values.
|
|
15
|
+
*
|
|
16
|
+
* @example Basic usage
|
|
17
|
+
* ```ts
|
|
18
|
+
* import { LruCache } from "@std/cache";
|
|
19
|
+
* import { assert, assertEquals } from "@std/assert";
|
|
20
|
+
*
|
|
21
|
+
* const MAX_SIZE = 3;
|
|
22
|
+
* const cache = new LruCache<string, number>(MAX_SIZE);
|
|
23
|
+
*
|
|
24
|
+
* cache.set("a", 1);
|
|
25
|
+
* cache.set("b", 2);
|
|
26
|
+
* cache.set("c", 3);
|
|
27
|
+
* cache.set("d", 4);
|
|
28
|
+
*
|
|
29
|
+
* // most recent values are stored up to `MAX_SIZE`
|
|
30
|
+
* assertEquals(cache.get("b"), 2);
|
|
31
|
+
* assertEquals(cache.get("c"), 3);
|
|
32
|
+
* assertEquals(cache.get("d"), 4);
|
|
33
|
+
*
|
|
34
|
+
* // less recent values are removed
|
|
35
|
+
* assert(!cache.has("a"));
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
export class LruCache extends Map {
|
|
39
|
+
/**
|
|
40
|
+
* The maximum number of entries to store in the cache.
|
|
41
|
+
*
|
|
42
|
+
* @example Max size
|
|
43
|
+
* ```ts no-assert
|
|
44
|
+
* import { LruCache } from "@std/cache";
|
|
45
|
+
* import { assertEquals } from "@std/assert";
|
|
46
|
+
*
|
|
47
|
+
* const cache = new LruCache<string, number>(100);
|
|
48
|
+
* assertEquals(cache.maxSize, 100);
|
|
49
|
+
* ```
|
|
50
|
+
*/
|
|
51
|
+
maxSize;
|
|
52
|
+
/**
|
|
53
|
+
* Constructs a new `LruCache`.
|
|
54
|
+
*
|
|
55
|
+
* @param maxSize The maximum number of entries to store in the cache.
|
|
56
|
+
*/
|
|
57
|
+
constructor(maxSize) {
|
|
58
|
+
super();
|
|
59
|
+
this.maxSize = maxSize;
|
|
60
|
+
}
|
|
61
|
+
#setMostRecentlyUsed(key, value) {
|
|
62
|
+
// delete then re-add to ensure most recently accessed elements are last
|
|
63
|
+
super.delete(key);
|
|
64
|
+
super.set(key, value);
|
|
65
|
+
}
|
|
66
|
+
#pruneToMaxSize() {
|
|
67
|
+
if (this.size > this.maxSize) {
|
|
68
|
+
this.delete(this.keys().next().value);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Checks whether an element with the specified key exists or not.
|
|
73
|
+
*
|
|
74
|
+
* @param key The key to check.
|
|
75
|
+
* @returns `true` if the cache contains the specified key, otherwise `false`.
|
|
76
|
+
*
|
|
77
|
+
* @example Checking for the existence of a key
|
|
78
|
+
* ```ts
|
|
79
|
+
* import { LruCache } from "@std/cache";
|
|
80
|
+
* import { assert } from "@std/assert";
|
|
81
|
+
*
|
|
82
|
+
* const cache = new LruCache<string, number>(100);
|
|
83
|
+
*
|
|
84
|
+
* cache.set("a", 1);
|
|
85
|
+
* assert(cache.has("a"));
|
|
86
|
+
* ```
|
|
87
|
+
*/
|
|
88
|
+
has(key) {
|
|
89
|
+
const exists = super.has(key);
|
|
90
|
+
if (exists) {
|
|
91
|
+
this.#setMostRecentlyUsed(key, super.get(key));
|
|
92
|
+
}
|
|
93
|
+
return exists;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Gets the element with the specified key.
|
|
97
|
+
*
|
|
98
|
+
* @param key The key to get the value for.
|
|
99
|
+
* @returns The value associated with the specified key, or `undefined` if the key is not present in the cache.
|
|
100
|
+
*
|
|
101
|
+
* @example Getting a value from the cache
|
|
102
|
+
* ```ts
|
|
103
|
+
* import { LruCache } from "@std/cache";
|
|
104
|
+
* import { assertEquals } from "@std/assert";
|
|
105
|
+
*
|
|
106
|
+
* const cache = new LruCache<string, number>(100);
|
|
107
|
+
*
|
|
108
|
+
* cache.set("a", 1);
|
|
109
|
+
* assertEquals(cache.get("a"), 1);
|
|
110
|
+
* ```
|
|
111
|
+
*/
|
|
112
|
+
get(key) {
|
|
113
|
+
if (super.has(key)) {
|
|
114
|
+
const value = super.get(key);
|
|
115
|
+
this.#setMostRecentlyUsed(key, value);
|
|
116
|
+
return value;
|
|
117
|
+
}
|
|
118
|
+
return undefined;
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Sets the specified key to the specified value.
|
|
122
|
+
*
|
|
123
|
+
* @param key The key to set the value for.
|
|
124
|
+
* @param value The value to set.
|
|
125
|
+
* @returns `this` for chaining.
|
|
126
|
+
*
|
|
127
|
+
* @example Setting a value in the cache
|
|
128
|
+
* ```ts no-assert
|
|
129
|
+
* import { LruCache } from "@std/cache";
|
|
130
|
+
*
|
|
131
|
+
* const cache = new LruCache<string, number>(100);
|
|
132
|
+
* cache.set("a", 1);
|
|
133
|
+
* ```
|
|
134
|
+
*/
|
|
135
|
+
set(key, value) {
|
|
136
|
+
this.#setMostRecentlyUsed(key, value);
|
|
137
|
+
this.#pruneToMaxSize();
|
|
138
|
+
return this;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A cache suitable for use with {@linkcode memoize}.
|
|
3
|
+
*
|
|
4
|
+
* @experimental **UNSTABLE**: New API, yet to be vetted.
|
|
5
|
+
*/
|
|
6
|
+
export type MemoizationCache<K, V> = {
|
|
7
|
+
has: (key: K) => boolean;
|
|
8
|
+
get: (key: K) => V | undefined;
|
|
9
|
+
set: (key: K, val: V) => unknown;
|
|
10
|
+
delete: (key: K) => unknown;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* The result of a memoized function, as stored in its cache.
|
|
14
|
+
*
|
|
15
|
+
* @experimental **UNSTABLE**: New API, yet to be vetted.
|
|
16
|
+
*/
|
|
17
|
+
export type MemoizationCacheResult<T> = {
|
|
18
|
+
kind: "ok";
|
|
19
|
+
value: T;
|
|
20
|
+
} | {
|
|
21
|
+
kind: "error";
|
|
22
|
+
error: unknown;
|
|
23
|
+
} | (T extends Promise<unknown> ? {
|
|
24
|
+
kind: "promise";
|
|
25
|
+
value: T;
|
|
26
|
+
} : never);
|
|
27
|
+
/**
|
|
28
|
+
* Options for {@linkcode memoize}.
|
|
29
|
+
*
|
|
30
|
+
* @experimental **UNSTABLE**: New API, yet to be vetted.
|
|
31
|
+
*
|
|
32
|
+
* @typeParam Fn The type of the function to memoize.
|
|
33
|
+
* @typeParam Key The type of the cache key.
|
|
34
|
+
* @typeParam Cache The type of the cache.
|
|
35
|
+
*/
|
|
36
|
+
export type MemoizeOptions<Fn extends (...args: never[]) => unknown, Key, Cache extends MemoizationCache<Key, MemoizationCacheResult<ReturnType<Fn>>>> = {
|
|
37
|
+
/**
|
|
38
|
+
* Provide a custom cache for getting previous results. By default, a new
|
|
39
|
+
* {@linkcode Map} object is instantiated upon memoization and used as a cache, with no
|
|
40
|
+
* limit on the number of results to be cached.
|
|
41
|
+
*
|
|
42
|
+
* Alternatively, you can supply a {@linkcode LruCache} with a specified max
|
|
43
|
+
* size to limit memory usage.
|
|
44
|
+
*/
|
|
45
|
+
cache?: Cache;
|
|
46
|
+
/**
|
|
47
|
+
* Function to get a unique cache key from the function's arguments. By
|
|
48
|
+
* default, a composite key is created from all the arguments plus the `this`
|
|
49
|
+
* value, using reference equality to check for equivalence.
|
|
50
|
+
*
|
|
51
|
+
* @example
|
|
52
|
+
* ```ts
|
|
53
|
+
* import { memoize } from "@std/cache";
|
|
54
|
+
* import { assertEquals } from "@std/assert";
|
|
55
|
+
*
|
|
56
|
+
* const fn = memoize(({ value }: { cacheKey: number; value: number }) => {
|
|
57
|
+
* return value;
|
|
58
|
+
* }, { getKey: ({ cacheKey }) => cacheKey });
|
|
59
|
+
*
|
|
60
|
+
* assertEquals(fn({ cacheKey: 1, value: 2 }), 2);
|
|
61
|
+
* assertEquals(fn({ cacheKey: 1, value: 99 }), 2);
|
|
62
|
+
* assertEquals(fn({ cacheKey: 2, value: 99 }), 99);
|
|
63
|
+
* ```
|
|
64
|
+
*/
|
|
65
|
+
getKey?: (this: ThisParameterType<Fn>, ...args: Parameters<Fn>) => Key;
|
|
66
|
+
/**
|
|
67
|
+
* Callback to determine if an error or other thrown value is cacheable.
|
|
68
|
+
*
|
|
69
|
+
* @default {() => false}
|
|
70
|
+
*
|
|
71
|
+
* @param err The thrown error or other value.
|
|
72
|
+
* @returns `true` if the error is cacheable, `false` otherwise.
|
|
73
|
+
*/
|
|
74
|
+
errorIsCacheable?: (err: unknown) => boolean;
|
|
75
|
+
};
|
|
76
|
+
/**
|
|
77
|
+
* Cache the results of a function based on its arguments.
|
|
78
|
+
*
|
|
79
|
+
* @experimental **UNSTABLE**: New API, yet to be vetted.
|
|
80
|
+
*
|
|
81
|
+
* @typeParam Fn The type of the function to memoize.
|
|
82
|
+
* @typeParam Key The type of the cache key.
|
|
83
|
+
* @typeParam Cache The type of the cache.
|
|
84
|
+
* @param fn The function to memoize
|
|
85
|
+
* @param options Options for memoization
|
|
86
|
+
*
|
|
87
|
+
* @returns The memoized function.
|
|
88
|
+
*
|
|
89
|
+
* @example Basic usage
|
|
90
|
+
* ```ts
|
|
91
|
+
* import { memoize } from "@std/cache";
|
|
92
|
+
* import { assertEquals } from "@std/assert";
|
|
93
|
+
*
|
|
94
|
+
* // fibonacci function, which is very slow for n > ~30 if not memoized
|
|
95
|
+
* const fib = memoize((n: bigint): bigint => {
|
|
96
|
+
* return n <= 2n ? 1n : fib(n - 1n) + fib(n - 2n);
|
|
97
|
+
* });
|
|
98
|
+
*
|
|
99
|
+
* assertEquals(fib(100n), 354224848179261915075n);
|
|
100
|
+
* ```
|
|
101
|
+
*
|
|
102
|
+
* > [!NOTE]
|
|
103
|
+
* > * By default, memoization is on the basis of all arguments passed to the
|
|
104
|
+
* > function, with equality determined by reference. This means that, for
|
|
105
|
+
* > example, passing a memoized function as `arr.map(func)` will not use the
|
|
106
|
+
* > cached results, as the index is implicitly passed as an argument. To
|
|
107
|
+
* > avoid this, you can pass a custom `getKey` option or use the memoized
|
|
108
|
+
* > function inside an anonymous callback like `arr.map((x) => func(x))`.
|
|
109
|
+
*/
|
|
110
|
+
export declare function memoize<Fn extends (...args: never[]) => unknown, Key = string, Cache extends MemoizationCache<Key, MemoizationCacheResult<ReturnType<Fn>>> = Map<Key, MemoizationCacheResult<ReturnType<Fn>>>>(fn: Fn, options?: MemoizeOptions<Fn, Key, Cache>): Fn;
|
|
111
|
+
//# sourceMappingURL=memoize.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"memoize.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/cache/0.2.0/memoize.ts"],"names":[],"mappings":"AAOA;;;;GAIG;AACH,MAAM,MAAM,gBAAgB,CAAC,CAAC,EAAE,CAAC,IAAI;IACnC,GAAG,EAAE,CAAC,GAAG,EAAE,CAAC,KAAK,OAAO,CAAC;IACzB,GAAG,EAAE,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,GAAG,SAAS,CAAC;IAC/B,GAAG,EAAE,CAAC,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,KAAK,OAAO,CAAC;IACjC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,KAAK,OAAO,CAAC;CAC7B,CAAC;AAEF;;;;GAIG;AACH,MAAM,MAAM,sBAAsB,CAAC,CAAC,IAChC;IAAE,IAAI,EAAE,IAAI,CAAC;IAAC,KAAK,EAAE,CAAC,CAAA;CAAE,GACxB;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,KAAK,EAAE,OAAO,CAAA;CAAE,GACjC,CAAC,CAAC,SAAS,OAAO,CAAC,OAAO,CAAC,GAAG;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,KAAK,EAAE,CAAC,CAAA;CAAE,GAAG,KAAK,CAAC,CAAC;AAEzE;;;;;;;;GAQG;AACH,MAAM,MAAM,cAAc,CACxB,EAAE,SAAS,CAAC,GAAG,IAAI,EAAE,KAAK,EAAE,KAAK,OAAO,EACxC,GAAG,EACH,KAAK,SAAS,gBAAgB,CAAC,GAAG,EAAE,sBAAsB,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC,CAAC,IACzE;IACF;;;;;;;OAOG;IACH,KAAK,CAAC,EAAE,KAAK,CAAC;IACd;;;;;;;;;;;;;;;;;;OAkBG;IACH,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,iBAAiB,CAAC,EAAE,CAAC,EAAE,GAAG,IAAI,EAAE,UAAU,CAAC,EAAE,CAAC,KAAK,GAAG,CAAC;IACvE;;;;;;;OAOG;IACH,gBAAgB,CAAC,EAAE,CAAC,GAAG,EAAE,OAAO,KAAK,OAAO,CAAC;CAC9C,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,wBAAgB,OAAO,CACrB,EAAE,SAAS,CAAC,GAAG,IAAI,EAAE,KAAK,EAAE,KAAK,OAAO,EACxC,GAAG,GAAG,MAAM,EACZ,KAAK,SAAS,gBAAgB,CAAC,GAAG,EAAE,sBAAsB,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC,CAAC,GACzE,GAAG,CACD,GAAG,EACH,sBAAsB,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC,CACvC,EAEH,EAAE,EAAE,EAAE,EACN,OAAO,CAAC,EAAE,cAAc,CAAC,EAAE,EAAE,GAAG,EAAE,KAAK,CAAC,GACvC,EAAE,CA+DJ"}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
// Copyright 2018-2025 the Deno authors. MIT license.
|
|
2
|
+
// This module is browser compatible.
|
|
3
|
+
import { _serializeArgList } from "./_serialize_arg_list.js";
|
|
4
|
+
/**
|
|
5
|
+
* Cache the results of a function based on its arguments.
|
|
6
|
+
*
|
|
7
|
+
* @experimental **UNSTABLE**: New API, yet to be vetted.
|
|
8
|
+
*
|
|
9
|
+
* @typeParam Fn The type of the function to memoize.
|
|
10
|
+
* @typeParam Key The type of the cache key.
|
|
11
|
+
* @typeParam Cache The type of the cache.
|
|
12
|
+
* @param fn The function to memoize
|
|
13
|
+
* @param options Options for memoization
|
|
14
|
+
*
|
|
15
|
+
* @returns The memoized function.
|
|
16
|
+
*
|
|
17
|
+
* @example Basic usage
|
|
18
|
+
* ```ts
|
|
19
|
+
* import { memoize } from "@std/cache";
|
|
20
|
+
* import { assertEquals } from "@std/assert";
|
|
21
|
+
*
|
|
22
|
+
* // fibonacci function, which is very slow for n > ~30 if not memoized
|
|
23
|
+
* const fib = memoize((n: bigint): bigint => {
|
|
24
|
+
* return n <= 2n ? 1n : fib(n - 1n) + fib(n - 2n);
|
|
25
|
+
* });
|
|
26
|
+
*
|
|
27
|
+
* assertEquals(fib(100n), 354224848179261915075n);
|
|
28
|
+
* ```
|
|
29
|
+
*
|
|
30
|
+
* > [!NOTE]
|
|
31
|
+
* > * By default, memoization is on the basis of all arguments passed to the
|
|
32
|
+
* > function, with equality determined by reference. This means that, for
|
|
33
|
+
* > example, passing a memoized function as `arr.map(func)` will not use the
|
|
34
|
+
* > cached results, as the index is implicitly passed as an argument. To
|
|
35
|
+
* > avoid this, you can pass a custom `getKey` option or use the memoized
|
|
36
|
+
* > function inside an anonymous callback like `arr.map((x) => func(x))`.
|
|
37
|
+
*/
|
|
38
|
+
export function memoize(fn, options) {
|
|
39
|
+
const cache = options?.cache ?? new Map();
|
|
40
|
+
const getKey = options?.getKey ??
|
|
41
|
+
_serializeArgList(cache);
|
|
42
|
+
const errorIsCacheable = options?.errorIsCacheable ?? (() => false);
|
|
43
|
+
const memoized = function (...args) {
|
|
44
|
+
const key = getKey.apply(this, args);
|
|
45
|
+
if (cache.has(key)) {
|
|
46
|
+
const result = cache.get(key);
|
|
47
|
+
switch (result.kind) {
|
|
48
|
+
case "ok":
|
|
49
|
+
case "promise":
|
|
50
|
+
return result.value;
|
|
51
|
+
case "error":
|
|
52
|
+
throw result.error;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
try {
|
|
56
|
+
let value = fn.apply(this, args);
|
|
57
|
+
if (value instanceof Promise) {
|
|
58
|
+
value = value.catch((reason) => {
|
|
59
|
+
if (!errorIsCacheable(reason)) {
|
|
60
|
+
cache.delete(key);
|
|
61
|
+
}
|
|
62
|
+
throw reason;
|
|
63
|
+
});
|
|
64
|
+
cache.set(key, { kind: "promise", value });
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
cache.set(key, { kind: "ok", value });
|
|
68
|
+
}
|
|
69
|
+
return value;
|
|
70
|
+
}
|
|
71
|
+
catch (e) {
|
|
72
|
+
if (errorIsCacheable(e)) {
|
|
73
|
+
cache.set(key, { kind: "error", error: e });
|
|
74
|
+
}
|
|
75
|
+
throw e;
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
return Object.defineProperties(memoized, {
|
|
79
|
+
length: { value: fn.length },
|
|
80
|
+
name: { value: fn.name },
|
|
81
|
+
});
|
|
82
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { Uint8Array_ } from "./_types.js";
|
|
2
|
+
export type { Uint8Array_ };
|
|
3
|
+
/**
|
|
4
|
+
* Converts data into a hex-encoded string.
|
|
5
|
+
*
|
|
6
|
+
* @param src The data to encode.
|
|
7
|
+
*
|
|
8
|
+
* @returns The hex-encoded string.
|
|
9
|
+
*
|
|
10
|
+
* @example Usage
|
|
11
|
+
* ```ts
|
|
12
|
+
* import { encodeHex } from "@std/encoding/hex";
|
|
13
|
+
* import { assertEquals } from "@std/assert";
|
|
14
|
+
*
|
|
15
|
+
* assertEquals(encodeHex("abc"), "616263");
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
export declare function encodeHex(src: string | Uint8Array | ArrayBuffer): string;
|
|
19
|
+
/**
|
|
20
|
+
* Decodes the given hex-encoded string. If the input is malformed, an error is
|
|
21
|
+
* thrown.
|
|
22
|
+
*
|
|
23
|
+
* @param src The hex-encoded string to decode.
|
|
24
|
+
*
|
|
25
|
+
* @returns The decoded data.
|
|
26
|
+
*
|
|
27
|
+
* @example Usage
|
|
28
|
+
* ```ts
|
|
29
|
+
* import { decodeHex } from "@std/encoding/hex";
|
|
30
|
+
* import { assertEquals } from "@std/assert";
|
|
31
|
+
*
|
|
32
|
+
* assertEquals(
|
|
33
|
+
* decodeHex("616263"),
|
|
34
|
+
* new TextEncoder().encode("abc"),
|
|
35
|
+
* );
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
export declare function decodeHex(src: string): Uint8Array_;
|
|
39
|
+
//# sourceMappingURL=hex.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hex.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/encoding/1.0.7/hex.ts"],"names":[],"mappings":"AA6BA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,YAAY,EAAE,WAAW,EAAE,CAAC;AA4B5B;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,UAAU,GAAG,WAAW,GAAG,MAAM,CAUxE;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,WAAW,CAiBlD"}
|