Socket
Socket
Sign inDemoInstall

bahamut-anime

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bahamut-anime - npm Package Compare versions

Comparing version 1.1.0 to 1.2.0

42

lib/index.d.ts
declare type NumericString = `${number}`;
/**
* 動畫類型
*/
declare enum AnimeCategory {

@@ -18,2 +21,5 @@ "所有動畫" = 0,

}
/**
* 動畫中對不同類型集數的分類
*/
declare enum VolumeType {

@@ -330,10 +336,34 @@ "本篇" = 0,

/**
* Fetcher with internal cache
*/
declare class Fetcher {
base: string;
/**
* Internal cache
*/
private cache;
/**
* Event listeners
*/
listeners: Map<string, Set<(...args: unknown[]) => void>>;
/**
* @param base API base URL
*/
constructor(base?: string);
/**
* Clear cache
*/
prune(): void;
/**
* Get parsed json data from endpoint
* @param endpoint Endpoint path
*/
get<T extends EndpointList>(endpoint: T): Promise<EndpointResult<T>>;
get<T extends string>(endpoint: T): Promise<unknown>;
/**
* Add a listener for an event
* @param event Event name
* @param listener Listener function
*/
on(event: "cache-hit", listener: (endpoint: string) => void): void;

@@ -344,2 +374,7 @@ on(event: "cache-miss", listener: (endpoint: string) => void): void;

on(event: "json-parse", listener: (url: string, json: Record<string, unknown>) => void): void;
/**
* Remove a listener for an event
* @param event Event name
* @param listener Listener function
*/
off(event: "cache-hit", listener: (endpoint: string) => void): void;

@@ -350,2 +385,6 @@ off(event: "cache-miss", listener: (endpoint: string) => void): void;

off(event: "json-parse", listener: (url: string, json: Record<string, unknown>) => void): void;
/**
* Emit an event
* @param event Event name
*/
protected emit(event: "cache-hit", endpoint: string): void;

@@ -357,2 +396,5 @@ protected emit(event: "cache-miss", endpoint: string): void;

}
/**
* The default fetcher instance
*/
declare const fetcher: Fetcher;

@@ -359,0 +401,0 @@

7

lib/index.js

@@ -77,5 +77,6 @@ "use strict";

async get(endpoint) {
if (this.cache.has(endpoint)) {
const cached = this.cache.get(endpoint);
if (cached && cached[0] >= Date.now()) {
this.emit("cache-hit", endpoint);
return this.cache.get(endpoint);
return cached[1];
}

@@ -89,3 +90,3 @@ this.emit("cache-miss", endpoint);

this.emit("json-parse", url, json);
this.cache.set(endpoint, json);
this.cache.set(endpoint, [Date.now() + 6e4, json]);
return json;

@@ -92,0 +93,0 @@ }

{
"name": "bahamut-anime",
"version": "1.1.0",
"version": "1.2.0",
"description": "Interact with the Bahamut Anime API in a simple and easy way.",

@@ -5,0 +5,0 @@ "keywords": [

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc