communitybuilds-node
Version:
Node.js API for Genshin Impact communitiy builds spreadsheet
39 lines • 2.56 kB
JavaScript
import { getBuildsByElementTask, setApiKey, setConfig } from './core/retrieve.js';
import { findArtifacts, findWeapons } from './core/retrieveByScraping.js';
import { pipe } from 'fp-ts/function';
import * as O from 'fp-ts/Option';
import * as TE from 'fp-ts/TaskEither';
export var CommunityBuilds;
(function (CommunityBuilds) {
/**
* Inits the package
* @param key Google spreadsheet API key
* @param config Caching config
*/
function init(key, config = { eludeCaching: false, cacheTTLms: 60 * 1000 }) {
setApiKey(key);
setConfig(config);
}
CommunityBuilds.init = init;
CommunityBuilds.pyro = () => pipe('pyro', getBuildsByElementTask, TE.match((l) => ({ data: [], error: l }), (r) => ({ data: r.data, element: 'pyro' })))();
CommunityBuilds.hydro = () => pipe('hydro', getBuildsByElementTask, TE.match((l) => ({ data: [], error: l }), (r) => ({ data: r.data, element: 'hydro' })))();
CommunityBuilds.anemo = () => pipe('anemo', getBuildsByElementTask, TE.match((l) => ({ data: [], error: l }), (r) => ({ data: r.data, element: 'anemo' })))();
CommunityBuilds.electro = () => pipe('electro', getBuildsByElementTask, TE.match((l) => ({ data: [], error: l }), (r) => ({ data: r.data, element: 'electro' })));
CommunityBuilds.dendro = () => pipe('dendro', getBuildsByElementTask, TE.match((l) => ({ data: [], error: l }), (r) => ({ data: r.data, element: 'dendro' })))();
CommunityBuilds.cryo = () => pipe('cryo', getBuildsByElementTask, TE.match((l) => ({ data: [], error: l }), (r) => ({ data: r.data, element: 'cryo' })))();
CommunityBuilds.geo = () => pipe('geo', getBuildsByElementTask, TE.match((l) => ({ data: [], error: l }), (r) => ({ data: r.data, element: 'geo' })))();
CommunityBuilds.getCharactersByElement = async (element) => pipe(element, getBuildsByElementTask, TE.match((l) => ({ data: [], error: l }), (r) => ({ data: r.data, element })))();
/**
* Retrieves all weapons of a given type
* @deprecated Will be removed next release
* @param type Weapon type
*/
CommunityBuilds.getWeaponsByType = async (type) => pipe(await findWeapons(type), O.map((e) => e.data), O.getOrElse(() => new Array()));
/**
* Retrieves all artifacts sets
* @deprecated Will be removed next release
* @param type Weapon type
*/
CommunityBuilds.getArtifacts = async () => pipe(await findArtifacts(), O.map((e) => e.data), O.getOrElse(() => new Array()));
})(CommunityBuilds || (CommunityBuilds = {}));
//# sourceMappingURL=index.js.map