Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

candle.bot

Package Overview
Dependencies
Maintainers
2
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

candle.bot - npm Package Compare versions

Comparing version 0.3.4 to 0.3.5

candle.bot.d.ts

74

index.d.ts

@@ -1,70 +0,6 @@

/// <reference types="socket.io-client" />
import { TimeFrame, Market, BithumbCC, BitfinexCC, CandleData, BithumbCandleData } from 'cryptocurrency-crawler.client';
export declare type CandleResponse = {
[id: string]: {
currency: BithumbCC | BitfinexCC;
data: CandleData | BithumbCandleData;
};
};
export interface CandleBotConfig {
timeFrame: TimeFrame;
startTime?: number;
endTime?: number;
progressInterval?: number;
processArg?: any;
markets: ({
id: string;
name: Market.Bithumb;
currency: BithumbCC;
} | {
id: string;
name: Market.Bitfinex;
currency: BitfinexCC;
})[];
export { TimeFrame, Market, BithumbCC, BitfinexCC, CandleData, BithumbCandleData, } from 'cryptocurrency-crawler.client';
export * from './candle.bot';
export declare class ErrorWithStatusCode extends Error {
status: number;
constructor(message: string, status?: number);
}
export interface BotHost {
url: string;
version: string;
key: string;
}
export interface BotStatus {
progress: number;
process: ProcessStatus;
}
export declare enum ProcessStatus {
yet = "yet",
doing = "doing",
done = "done"
}
declare class BaseBot {
readonly name: string;
readonly socket: SocketIOClient.Socket;
protected readonly _ack: (evt: string, ...any: any[]) => Promise<any>;
constructor(name: string, socket: SocketIOClient.Socket);
readonly id: string;
readonly connected: boolean;
readonly disconnected: boolean;
close(): void;
on(event: string, fn: Function): SocketIOClient.Emitter;
once(event: string, fn: Function): SocketIOClient.Emitter;
}
export declare class CandleMasterBot extends BaseBot {
readonly host: BotHost;
constructor(host: BotHost);
open(): Promise<void>;
ids(name?: string): Promise<string[]>;
beBot(name: string): Promise<boolean>;
getBot(name: string): Promise<CandleBot>;
newBot(name: string, config?: CandleBotConfig): Promise<CandleBot>;
}
export declare class CandleBot extends BaseBot {
constructor(name: string, socket: SocketIOClient.Socket);
on(evt: ':progress', cb: (count: number) => void): SocketIOClient.Emitter;
on(evt: ':started', cb: () => void): SocketIOClient.Emitter;
on(evt: ':stoped', cb: () => void): SocketIOClient.Emitter;
on<T>(evt: ':transacted', cb: (result: T) => void): SocketIOClient.Emitter;
start(): Promise<void>;
stop(): Promise<void>;
status(): Promise<BotStatus>;
}
export {};
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
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) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
function __export(m) {
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
}
Object.defineProperty(exports, "__esModule", { value: true });
const Socket = require("socket.io-client");
const fourdollar_promisify_1 = require("fourdollar.promisify");
var ProcessStatus;
(function (ProcessStatus) {
ProcessStatus["yet"] = "yet";
ProcessStatus["doing"] = "doing";
ProcessStatus["done"] = "done";
})(ProcessStatus = exports.ProcessStatus || (exports.ProcessStatus = {}));
function newSocket(host) {
return Socket(host.url, {
path: '/' + host.version,
transportOptions: {
polling: {
extraHeaders: {
'x-access-token': host.key,
},
},
},
autoConnect: false,
});
}
function openSocket(socket, name, config) {
return __awaiter(this, void 0, void 0, function* () {
return new Promise((resolve, reject) => {
socket.once('connect', () => __awaiter(this, void 0, void 0, function* () {
try {
const res = (config) ?
(yield fourdollar_promisify_1.default(socket.emit, socket)(':new.bot', { name, config })) :
(yield fourdollar_promisify_1.default(socket.emit, socket)(':get.bot', name));
if (res === 'ok') {
resolve();
}
else {
throw Error(`':new.bot'에서 '${name}' 이름으로 'ok'하지 않았다.`);
}
}
catch (err) {
socket.close();
reject(err);
}
}));
socket.once('connect_error', reject);
socket.once('connect_timeout', reject);
socket.once('error', reject);
socket.open();
});
});
}
class BaseBot {
constructor(name, socket) {
this.name = name;
this.socket = socket;
this._ack = fourdollar_promisify_1.default(socket.emit, socket);
var cryptocurrency_crawler_client_1 = require("cryptocurrency-crawler.client");
exports.TimeFrame = cryptocurrency_crawler_client_1.TimeFrame;
exports.Market = cryptocurrency_crawler_client_1.Market;
exports.BithumbCC = cryptocurrency_crawler_client_1.BithumbCC;
exports.BitfinexCC = cryptocurrency_crawler_client_1.BitfinexCC;
__export(require("./candle.bot"));
class ErrorWithStatusCode extends Error {
constructor(message, status = 500) {
super(message);
this.status = status;
}
get id() {
return this.socket.id;
}
get connected() {
return this.socket.connected;
}
get disconnected() {
return this.socket.disconnected;
}
close() {
this.socket.close();
}
on(event, fn) {
return this.socket.on(event, fn);
}
once(event, fn) {
return this.socket.on(event, fn);
}
}
class CandleMasterBot extends BaseBot {
constructor(host) {
super('master', newSocket(host));
this.host = host;
}
open() {
return openSocket(this.socket, 'master');
}
ids(name) {
return __awaiter(this, void 0, void 0, function* () {
return this._ack(':ids', name);
});
}
beBot(name) {
return __awaiter(this, void 0, void 0, function* () {
return this._ack(':be.bot', name);
});
}
getBot(name) {
return __awaiter(this, void 0, void 0, function* () {
return this.newBot(name);
});
}
newBot(name, config) {
return __awaiter(this, void 0, void 0, function* () {
if (name === 'master') {
throw Error('master는 일반 bot이 될 수 없다.');
}
const socket = newSocket(this.host);
yield openSocket(socket, name, config);
return new CandleBot(name, socket);
});
}
}
exports.CandleMasterBot = CandleMasterBot;
// interface IMockConstructor<M> {
// new (ref: M): M
// }
class CandleBot extends BaseBot {
constructor(name, socket) {
super(name, socket);
}
// on<M>(evt: ':sold', cb: (mock: M) => void): SocketIOClient.Emitter
// on<M>(evt: ':bought', cb: (mock: M) => void): SocketIOClient.Emitter
on(evt, cb) {
return super.on(evt, cb);
}
// async start<M>(constructor: IMockConstructor<M>): Promise<M> {
// const ref = await this._ack(':start', this.name)
// return new constructor(ref)
// }
start() {
return __awaiter(this, void 0, void 0, function* () {
return this._ack(':start', this.name);
});
}
stop() {
return this._ack(':stop', this.name);
}
status() {
return __awaiter(this, void 0, void 0, function* () {
return this._ack(':status', this.name);
});
}
}
exports.CandleBot = CandleBot;
exports.ErrorWithStatusCode = ErrorWithStatusCode;
//# sourceMappingURL=index.js.map
{
"name": "candle.bot",
"version": "0.3.4",
"version": "0.3.5",
"description": "Cryptocurrency Candle Bot",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"main": "index.js",
"types": "index.d.ts",
"author": {

@@ -8,0 +8,0 @@ "name": "bynaki",

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