nintendo-switch-eshop
Advanced tools
Comparing version 5.0.0 to 5.1.0
@@ -5,2 +5,12 @@ # Changelog | ||
## [5.1.0](https://github.com/lmmfranco/nintendo-switch-eshop/compare/v5.0.0...v5.1.0) (2021-03-05) | ||
### Features | ||
- bundle ESM compatible exports ([b58a3aa](https://github.com/lmmfranco/nintendo-switch-eshop/commit/b58a3aa61c34a7ba2dbf8ac65379090f8a483cfa)) | ||
### Bug Fixes | ||
- **getqueriedgamesamerica:** fixed type exports and TSDoc ([103f028](https://github.com/lmmfranco/nintendo-switch-eshop/commit/103f0283ab69e142238a881b7450c1587fcab39e)) | ||
## [5.0.0](https://github.com/lmmfranco/nintendo-switch-eshop/compare/v4.0.0...v5.0.0) (2021-03-05) | ||
@@ -7,0 +17,0 @@ |
@@ -13,5 +13,5 @@ export { getGamesAmerica as default, getGamesAmerica } from './lib/getGames/getGamesAmerica'; | ||
export { parseNSUID } from './lib/other/parseNSUID'; | ||
export { EU_GET_GAMES_URL, JP_GET_GAMES_URL, PRICE_GET_URL, QUERIED_US_ALGOLIA_KEY, Region, US_ALGOLIA_HEADERS, US_ALGOLIA_ID, US_ALGOLIA_KEY, US_GET_GAMES_URL } from './lib/utils/constants'; | ||
export type { EShop, EURequestOptions, GameEU, GameJP, GameUS, PriceResponse, QueriedGameUS } from './lib/utils/interfaces'; | ||
export { EU_GET_GAMES_URL, JP_GET_GAMES_URL, PRICE_GET_URL, QUERIED_US_ALGOLIA_KEY, QUERIED_US_GET_GAMES_URL, Region, US_ALGOLIA_HEADERS, US_ALGOLIA_ID, US_ALGOLIA_KEY, US_GET_GAMES_URL } from './lib/utils/constants'; | ||
export type { EShop, EURequestOptions, GameEU, GameJP, GameUS, HighlightResult, Nsuid, PriceResponse, QueriedGameResult, QueriedGamesAmericaOptions, QueriedGameUS, TitleData } from './lib/utils/interfaces'; | ||
export { EshopError } from './lib/utils/utils'; | ||
//# sourceMappingURL=index.d.ts.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.EshopError = exports.US_GET_GAMES_URL = exports.US_ALGOLIA_KEY = exports.US_ALGOLIA_ID = exports.US_ALGOLIA_HEADERS = exports.Region = exports.QUERIED_US_ALGOLIA_KEY = exports.PRICE_GET_URL = exports.JP_GET_GAMES_URL = exports.EU_GET_GAMES_URL = exports.parseNSUID = exports.parseGameCode = exports.getShopsByCountryCodes = exports.getPrices = exports.getShopsEurope = exports.getShopsAsia = exports.getShopsAmerica = exports.getActiveShops = exports.getQueriedGamesAmerica = exports.getGamesJapan = exports.getGamesEurope = exports.getGamesAmerica = exports.default = void 0; | ||
exports.EshopError = exports.US_GET_GAMES_URL = exports.US_ALGOLIA_KEY = exports.US_ALGOLIA_ID = exports.US_ALGOLIA_HEADERS = exports.Region = exports.QUERIED_US_GET_GAMES_URL = exports.QUERIED_US_ALGOLIA_KEY = exports.PRICE_GET_URL = exports.JP_GET_GAMES_URL = exports.EU_GET_GAMES_URL = exports.parseNSUID = exports.parseGameCode = exports.getShopsByCountryCodes = exports.getPrices = exports.getShopsEurope = exports.getShopsAsia = exports.getShopsAmerica = exports.getActiveShops = exports.getQueriedGamesAmerica = exports.getGamesJapan = exports.getGamesEurope = exports.getGamesAmerica = exports.default = void 0; | ||
var getGamesAmerica_1 = require("./lib/getGames/getGamesAmerica"); | ||
@@ -34,2 +34,3 @@ Object.defineProperty(exports, "default", { enumerable: true, get: function () { return getGamesAmerica_1.getGamesAmerica; } }); | ||
Object.defineProperty(exports, "QUERIED_US_ALGOLIA_KEY", { enumerable: true, get: function () { return constants_1.QUERIED_US_ALGOLIA_KEY; } }); | ||
Object.defineProperty(exports, "QUERIED_US_GET_GAMES_URL", { enumerable: true, get: function () { return constants_1.QUERIED_US_GET_GAMES_URL; } }); | ||
Object.defineProperty(exports, "Region", { enumerable: true, get: function () { return constants_1.Region; } }); | ||
@@ -36,0 +37,0 @@ Object.defineProperty(exports, "US_ALGOLIA_HEADERS", { enumerable: true, get: function () { return constants_1.US_ALGOLIA_HEADERS; } }); |
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
@@ -28,3 +19,3 @@ return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
*/ | ||
const getGamesAmerica = () => __awaiter(void 0, void 0, void 0, function* () { | ||
const getGamesAmerica = async () => { | ||
const limit = constants_1.US_GAME_LIST_LIMIT; | ||
@@ -129,6 +120,6 @@ const page = 0; | ||
try { | ||
const allGamesResponse = yield node_fetch_1.default(constants_1.US_GET_GAMES_URL, body); | ||
const allGamesResponse = await node_fetch_1.default(constants_1.US_GET_GAMES_URL, body); | ||
if (!allGamesResponse.ok) | ||
throw new Error('US_games_request_failed'); | ||
const gamesResponse = yield allGamesResponse.json(); | ||
const gamesResponse = await allGamesResponse.json(); | ||
let allGames = []; | ||
@@ -146,4 +137,4 @@ for (const results of gamesResponse.results) { | ||
} | ||
}); | ||
}; | ||
exports.getGamesAmerica = getGamesAmerica; | ||
//# sourceMappingURL=getGamesAmerica.js.map |
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
@@ -29,3 +20,3 @@ return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
*/ | ||
const getGamesEurope = (options = { limit: constants_1.EU_GAME_LIST_LIMIT, locale: constants_1.EU_DEFAULT_LOCALE }) => __awaiter(void 0, void 0, void 0, function* () { | ||
const getGamesEurope = async (options = { limit: constants_1.EU_GAME_LIST_LIMIT, locale: constants_1.EU_DEFAULT_LOCALE }) => { | ||
if (!options.limit) | ||
@@ -36,6 +27,9 @@ options.limit = constants_1.EU_GAME_LIST_LIMIT; | ||
try { | ||
const gamesEU = yield node_fetch_1.default(`${constants_1.EU_GET_GAMES_URL.replace('{locale}', options.locale)}?${querystring_1.stringify(Object.assign({ rows: options.limit }, constants_1.EU_GET_GAMES_OPTIONS))}`); | ||
const gamesEU = await node_fetch_1.default(`${constants_1.EU_GET_GAMES_URL.replace('{locale}', options.locale)}?${querystring_1.stringify({ | ||
rows: options.limit, | ||
...constants_1.EU_GET_GAMES_OPTIONS | ||
})}`); | ||
if (!gamesEU.ok) | ||
throw new Error('EU_games_request_failed'); | ||
const gamesData = yield gamesEU.json(); | ||
const gamesData = await gamesEU.json(); | ||
return gamesData.response.docs; | ||
@@ -48,4 +42,4 @@ } | ||
} | ||
}); | ||
}; | ||
exports.getGamesEurope = getGamesEurope; | ||
//# sourceMappingURL=getGamesEurope.js.map |
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
@@ -25,8 +16,8 @@ return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
*/ | ||
const getGamesJapan = () => __awaiter(void 0, void 0, void 0, function* () { | ||
const getGamesJapan = async () => { | ||
try { | ||
const gamesJP = yield node_fetch_1.default(constants_1.JP_GET_GAMES_URL); | ||
const gamesJP = await node_fetch_1.default(constants_1.JP_GET_GAMES_URL); | ||
if (!gamesJP.ok) | ||
throw new Error('JP_games_request_failed'); | ||
const parsedGamesJP = fast_xml_parser_1.parse(yield gamesJP.text()); | ||
const parsedGamesJP = fast_xml_parser_1.parse(await gamesJP.text()); | ||
const allGamesJP = parsedGamesJP.TitleInfoList.TitleInfo; | ||
@@ -40,4 +31,4 @@ return allGamesJP; | ||
} | ||
}); | ||
}; | ||
exports.getGamesJapan = getGamesJapan; | ||
//# sourceMappingURL=getGamesJapan.js.map |
@@ -5,3 +5,4 @@ import type { QueriedGamesAmericaOptions, QueriedGameUS } from '../utils/interfaces'; | ||
* @param query The query to search for | ||
* @returns Promise containing the first 200 games that match your query | ||
* @param __namedParameters Additional options for the [[getQueriedGamesAmerica]] call. Defaults to `{ hitsPerPage: 200, page: 0 }` | ||
* @returns Promise containing the first `hitsPerPage` games that match your query | ||
* @license Apache-2.0 Favna & Antonio Román | ||
@@ -8,0 +9,0 @@ * @copyright 2019 |
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
@@ -23,10 +14,14 @@ return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
* @param query The query to search for | ||
* @returns Promise containing the first 200 games that match your query | ||
* @param __namedParameters Additional options for the [[getQueriedGamesAmerica]] call. Defaults to `{ hitsPerPage: 200, page: 0 }` | ||
* @returns Promise containing the first `hitsPerPage` games that match your query | ||
* @license Apache-2.0 Favna & Antonio Román | ||
* @copyright 2019 | ||
*/ | ||
const getQueriedGamesAmerica = (query, { hitsPerPage = 200, page = 0 } = { hitsPerPage: 200, page: 0 }) => __awaiter(void 0, void 0, void 0, function* () { | ||
const response = yield node_fetch_1.default(constants_1.QUERIED_US_GET_GAMES_URL, { | ||
const getQueriedGamesAmerica = async (query, { hitsPerPage = 200, page = 0 } = { hitsPerPage: 200, page: 0 }) => { | ||
const response = await node_fetch_1.default(constants_1.QUERIED_US_GET_GAMES_URL, { | ||
method: 'POST', | ||
headers: Object.assign(Object.assign({}, constants_1.US_ALGOLIA_HEADERS), { 'X-Algolia-API-Key': constants_1.QUERIED_US_ALGOLIA_KEY }), | ||
headers: { | ||
...constants_1.US_ALGOLIA_HEADERS, | ||
'X-Algolia-API-Key': constants_1.QUERIED_US_ALGOLIA_KEY | ||
}, | ||
body: JSON.stringify({ | ||
@@ -42,8 +37,8 @@ params: querystring_1.stringify({ | ||
throw new utils_1.EshopError(`Fetching games for the query "${query} failed"`); | ||
const { hits } = yield response.json(); | ||
const { hits } = await response.json(); | ||
if (!hits.length) | ||
throw new utils_1.EshopError(`No game results for the query "${query}"`); | ||
return hits; | ||
}); | ||
}; | ||
exports.getQueriedGamesAmerica = getQueriedGamesAmerica; | ||
//# sourceMappingURL=getQueriedGamesAmerica.js.map |
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -24,7 +15,7 @@ exports.getActiveShops = void 0; | ||
*/ | ||
const getActiveShops = () => __awaiter(void 0, void 0, void 0, function* () { | ||
const getActiveShops = async () => { | ||
try { | ||
const shopsAmerica = yield getShopsAmerica_1.getShopsAmerica(); | ||
const shopsAsia = yield getShopsAsia_1.getShopsAsia(); | ||
const shopsEurope = yield getShopsEurope_1.getShopsEurope(); | ||
const shopsAmerica = await getShopsAmerica_1.getShopsAmerica(); | ||
const shopsAsia = await getShopsAsia_1.getShopsAsia(); | ||
const shopsEurope = await getShopsEurope_1.getShopsEurope(); | ||
return shopsAmerica.concat(shopsAsia, shopsEurope); | ||
@@ -35,4 +26,4 @@ } | ||
} | ||
}); | ||
}; | ||
exports.getActiveShops = getActiveShops; | ||
//# sourceMappingURL=getActiveShops.js.map |
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -24,6 +15,6 @@ exports.getShopsAmerica = void 0; | ||
*/ | ||
const getShopsAmerica = () => __awaiter(void 0, void 0, void 0, function* () { | ||
return getShopByCountryCode_1.getShopsByCountryCodes(country_data_1.regions.southAmerica.countries.concat(country_data_1.regions.centralAfrica.countries, country_data_1.regions.northernAmerica.countries), constants_1.US_GAME_CHECK_CODE, constants_1.Region.AMERICAS); | ||
}); | ||
const getShopsAmerica = async () => { | ||
return getShopByCountryCode_1.getShopsByCountryCodes(country_data_1.regions.southAmerica.countries.concat(country_data_1.regions.centralAfrica.countries, country_data_1.regions.northernAmerica.countries), constants_1.US_GAME_CHECK_CODE, 1 /* AMERICAS */); | ||
}; | ||
exports.getShopsAmerica = getShopsAmerica; | ||
//# sourceMappingURL=getShopsAmerica.js.map |
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -24,6 +15,6 @@ exports.getShopsAsia = void 0; | ||
*/ | ||
const getShopsAsia = () => __awaiter(void 0, void 0, void 0, function* () { | ||
return getShopByCountryCode_1.getShopsByCountryCodes(country_data_1.regions.southernAsia.countries.concat(country_data_1.regions.southernAsia.countries, country_data_1.regions.southeastAsia.countries, country_data_1.regions.eastAsia.countries, country_data_1.regions.westernAsia.countries), constants_1.JP_GAME_CHECK_CODE, constants_1.Region.ASIA); | ||
}); | ||
const getShopsAsia = async () => { | ||
return getShopByCountryCode_1.getShopsByCountryCodes(country_data_1.regions.southernAsia.countries.concat(country_data_1.regions.southernAsia.countries, country_data_1.regions.southeastAsia.countries, country_data_1.regions.eastAsia.countries, country_data_1.regions.westernAsia.countries), constants_1.JP_GAME_CHECK_CODE, 3 /* ASIA */); | ||
}; | ||
exports.getShopsAsia = getShopsAsia; | ||
//# sourceMappingURL=getShopsAsia.js.map |
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -24,6 +15,6 @@ exports.getShopsEurope = void 0; | ||
*/ | ||
const getShopsEurope = () => __awaiter(void 0, void 0, void 0, function* () { | ||
return getShopByCountryCode_1.getShopsByCountryCodes(country_data_1.regions.northernEurope.countries.concat(country_data_1.regions.southernEurope.countries, country_data_1.regions.easternEurope.countries, country_data_1.regions.westernEurope.countries, country_data_1.regions.australia.countries, country_data_1.regions.southernAfrica.countries), constants_1.EU_GAME_CHECK_CODE, constants_1.Region.EUROPE); | ||
}); | ||
const getShopsEurope = async () => { | ||
return getShopByCountryCode_1.getShopsByCountryCodes(country_data_1.regions.northernEurope.countries.concat(country_data_1.regions.southernEurope.countries, country_data_1.regions.easternEurope.countries, country_data_1.regions.westernEurope.countries, country_data_1.regions.australia.countries, country_data_1.regions.southernAfrica.countries), constants_1.EU_GAME_CHECK_CODE, 2 /* EUROPE */); | ||
}; | ||
exports.getShopsEurope = getShopsEurope; | ||
//# sourceMappingURL=getShopsEurope.js.map |
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
@@ -29,6 +20,11 @@ return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
*/ | ||
const getPrices = (country, gameIds, offset = 0, prices = []) => __awaiter(void 0, void 0, void 0, function* () { | ||
const getPrices = async (country, gameIds, offset = 0, prices = []) => { | ||
try { | ||
const filteredIds = gameIds.slice(offset, offset + constants_1.PRICE_LIST_LIMIT); | ||
const priceData = yield node_fetch_1.default(`${constants_1.PRICE_GET_URL}?${querystring_1.stringify(Object.assign({ country, ids: filteredIds, limit: constants_1.PRICE_LIST_LIMIT }, constants_1.PRICE_GET_OPTIONS))}`); | ||
const priceData = await node_fetch_1.default(`${constants_1.PRICE_GET_URL}?${querystring_1.stringify({ | ||
country, | ||
ids: filteredIds, | ||
limit: constants_1.PRICE_LIST_LIMIT, | ||
...constants_1.PRICE_GET_OPTIONS | ||
})}`); | ||
if (priceData.status === 403) | ||
@@ -38,6 +34,6 @@ throw new Error('PRICE_Rate_Limit'); | ||
throw new Error('PRICE_get_request_failed'); | ||
const response = yield priceData.json(); | ||
const response = await priceData.json(); | ||
if (response.prices && response.prices.length + offset < gameIds.length) { | ||
const accumulatedPrices = prices.concat(response.prices); | ||
return yield exports.getPrices(country, gameIds, offset + constants_1.PRICE_LIST_LIMIT, accumulatedPrices); | ||
return await exports.getPrices(country, gameIds, offset + constants_1.PRICE_LIST_LIMIT, accumulatedPrices); | ||
} | ||
@@ -57,4 +53,4 @@ else if (response.prices) { | ||
} | ||
}); | ||
}; | ||
exports.getPrices = getPrices; | ||
//# sourceMappingURL=getPrices.js.map |
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -23,3 +14,3 @@ exports.getShopsByCountryCodes = void 0; | ||
*/ | ||
const getShopsByCountryCodes = (countryCodes, gameCode, region) => __awaiter(void 0, void 0, void 0, function* () { | ||
const getShopsByCountryCodes = async (countryCodes, gameCode, region) => { | ||
try { | ||
@@ -30,3 +21,3 @@ const countryList = countryCodes.map((code) => country_data_1.countries.all.filter((country) => country.alpha2 === code)[0]); | ||
try { | ||
const response = yield getPrices_1.getPrices(country.alpha2, gameCode); | ||
const response = await getPrices_1.getPrices(country.alpha2, gameCode); | ||
response.country = country; | ||
@@ -55,4 +46,4 @@ shops.push(response); | ||
} | ||
}); | ||
}; | ||
exports.getShopsByCountryCodes = getShopsByCountryCodes; | ||
//# sourceMappingURL=getShopByCountryCode.js.map |
@@ -17,9 +17,9 @@ "use strict"; | ||
default: | ||
case constants_1.Region.EUROPE: | ||
case 2 /* EUROPE */: | ||
codeParse = constants_1.EU_GAME_CODE_REGEX.exec(game.product_code_txt[0]); | ||
break; | ||
case constants_1.Region.ASIA: | ||
case 3 /* ASIA */: | ||
codeParse = constants_1.JP_GAME_CODE_REGEX.exec(game.InitialCode); | ||
break; | ||
case constants_1.Region.AMERICAS: | ||
case 1 /* AMERICAS */: | ||
return util_1.deprecate(() => { var _a; return (((_a = constants_1.US_GAME_CODE_REGEX.exec(game.game_code)) === null || _a === void 0 ? void 0 : _a.length) || false ? constants_1.US_GAME_CODE_REGEX.exec(game.game_code)[1] : ''); }, 'game_code is no longer returned by the API for American games so it can no longer be parsed from the data.', 'DEP0001')(); | ||
@@ -26,0 +26,0 @@ } |
@@ -14,9 +14,9 @@ "use strict"; | ||
switch (region) { | ||
case constants_1.Region.EUROPE: | ||
case 2 /* EUROPE */: | ||
return game.nsuid_txt ? game.nsuid_txt[0] : null; | ||
case constants_1.Region.ASIA: | ||
case 3 /* ASIA */: | ||
const nsuidParse = constants_1.JP_NSUID_REGEX.exec(game.LinkURL); | ||
return nsuidParse && nsuidParse.length > 0 ? nsuidParse[0] : null; | ||
default: | ||
case constants_1.Region.AMERICAS: | ||
case 1 /* AMERICAS */: | ||
return game.nsuid; | ||
@@ -23,0 +23,0 @@ } |
{ | ||
"name": "nintendo-switch-eshop", | ||
"version": "5.0.0", | ||
"version": "5.1.0", | ||
"description": "Unofficial API lib for Nintendo Switch eShop game listing and pricing information.", | ||
@@ -9,2 +9,6 @@ "author": "lmmfranco", | ||
"types": "dist/index.d.ts", | ||
"exports": { | ||
"import": "./dist/index.mjs", | ||
"require": "./dist/index.js" | ||
}, | ||
"scripts": { | ||
@@ -14,2 +18,3 @@ "test": "jest", | ||
"build": "tsc -b src", | ||
"postbuild": "gen-esm-wrapper dist/index.js dist/index.mjs", | ||
"watch": "tsc -b src -w", | ||
@@ -47,2 +52,3 @@ "clean": "tsc -b src --clean", | ||
"eslint-plugin-prettier": "^3.3.1", | ||
"gen-esm-wrapper": "^1.1.1", | ||
"husky": "^5.1.3", | ||
@@ -49,0 +55,0 @@ "jest": "^26.6.3", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
69
110736
29
1309