Transpiled version (6849L) is out of date.
scope ipToCountry2020. sS #dataSnippetID = #1400400; static Map<Long, S> #cache = mruCache(100); static Lock #lock = lock(); static File #dataDir() { ret javaxCachesDir("ipToCountry2020"); } sS ipToCountry2020(S ip) { ret ipToCountry2020(ipToInt(ip)); } sS ipToCountry2020(long ipNum) { ret mapGetOrCreate(cache, ipNum, () -> uncached(ipNum)); } sS #uncached(long ipNum) { { lock lock; if (directoryEmpty(dataDir())) unzipSnippet(dataSnippetID, dataDir()); } S line = pairB(binarySearchForLineInTextFile(newFile(dataDir(), "IP2LOCATION-LITE-DB1.CSV"), s -> { LS l = tok_splitAtComma_unquote(s); long a = parseLongOpt(first(l)), b = parseLongOpt(second(l)); ifdef ipToCountry2020_debug printVars_str("ipToCountry2020: ", +a, +b, +ipNum); endifdef ret ipNum > b ? 1 : ipNum < a ? -1 : 0; })); ret get(tok_splitAtComma_unquote(line), 2); }
Began life as a copy of #1008738
download show line numbers debug dex old transpilations
Travelled to 7 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv
No comments. add comment
Snippet ID: | #1028338 |
Snippet name: | ipToCountry2020 - use ipToCountry2021 instead! |
Eternal ID of this version: | #1028338/15 |
Text MD5: | 587d2a4d97c6c2b1e6740fd512a32788 |
Author: | stefan |
Category: | javax |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2021-10-06 03:56:33 |
Source code size: | 932 bytes / 34 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 286 / 442 |
Version history: | 14 change(s) |
Referenced in: | #1006654 - Standard functions list 2 (LIVE, continuation of #761) #1028351 - ipToCountry2020_safe #1028654 - IP-to-country standalone demo #1030439 - queryUSZipCode #1032616 - ipToCountry2021 |