Comparing version 0.0.18 to 0.0.19
@@ -5,5 +5,5 @@ import { StorageAdapter } from "../interfaces/StorageAdapter"; | ||
constructor(basePath: string); | ||
set(paths: string, value: string): boolean; | ||
get(paths: string): string; | ||
exists(paths: string): boolean; | ||
set(paths: string, value: string): Promise<boolean>; | ||
get(paths: string): Promise<string>; | ||
exists(paths: string): Promise<boolean>; | ||
} |
"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 }); | ||
@@ -12,17 +21,23 @@ exports.NodeFSStorageAdapater = void 0; | ||
set(paths, value) { | ||
try { | ||
fs.writeFileSync(path.join(this.basePath, paths), value, { encoding: 'utf-8' }); | ||
return true; | ||
} | ||
catch (err) { | ||
return false; | ||
} | ||
return __awaiter(this, void 0, void 0, function* () { | ||
try { | ||
fs.writeFileSync(path.join(this.basePath, paths), value, { encoding: 'utf-8' }); | ||
return true; | ||
} | ||
catch (err) { | ||
return false; | ||
} | ||
}); | ||
} | ||
get(paths) { | ||
return fs.readFileSync(path.join(this.basePath, paths), { encoding: 'utf-8' }).toString(); | ||
return __awaiter(this, void 0, void 0, function* () { | ||
return fs.readFileSync(path.join(this.basePath, paths), { encoding: 'utf-8' }).toString(); | ||
}); | ||
} | ||
exists(paths) { | ||
return fs.existsSync(path.join(this.basePath, paths)); | ||
return __awaiter(this, void 0, void 0, function* () { | ||
return fs.existsSync(path.join(this.basePath, paths)); | ||
}); | ||
} | ||
} | ||
exports.NodeFSStorageAdapater = NodeFSStorageAdapater; |
@@ -44,6 +44,6 @@ "use strict"; | ||
console.log(constants_1.CONSOLE_COLORS.fg.cyan + "[AUTHENTICATOR] Initializing Authenticator...", constants_1.CONSOLE_COLORS.reset); | ||
if (this.storageAdapter.exists(TOKEN_FILE)) { | ||
if ((yield this.storageAdapter.exists(TOKEN_FILE))) { | ||
if (constants_1.DEBUG) | ||
console.log(constants_1.CONSOLE_COLORS.fg.magenta + "[AUTHENTICATOR] Found Token File in Storage, reading it...", constants_1.CONSOLE_COLORS.reset); | ||
var str = this.storageAdapter.get(TOKEN_FILE); | ||
var str = yield this.storageAdapter.get(TOKEN_FILE); | ||
if (str) { | ||
@@ -50,0 +50,0 @@ __classPrivateFieldSet(this, _Authenticator_token, JSON.parse(str), "f"); |
export interface StorageAdapter { | ||
set(path: string, value: string): boolean; | ||
get(path: string): string; | ||
exists(path: string): boolean; | ||
set(path: string, value: string): Promise<boolean>; | ||
get(path: string): Promise<string>; | ||
exists(path: string): Promise<boolean>; | ||
} |
{ | ||
"name": "iyoutube", | ||
"version": "0.0.18", | ||
"version": "0.0.19", | ||
"description": "The ultimate unofficial YouTube API Client for Javascript", | ||
@@ -5,0 +5,0 @@ "main": "output/main.js", |
@@ -17,3 +17,3 @@ import { StorageAdapter } from "../interfaces/StorageAdapter"; | ||
set(paths: string, value: string): boolean { | ||
async set(paths: string, value: string) { | ||
try { | ||
@@ -27,7 +27,7 @@ fs.writeFileSync(path.join(this.basePath, paths), value, { encoding: 'utf-8' }); | ||
get(paths: string): string { | ||
async get(paths: string) { | ||
return fs.readFileSync(path.join(this.basePath, paths), { encoding: 'utf-8' }).toString(); | ||
} | ||
exists(paths: string): boolean { | ||
async exists(paths: string) { | ||
return fs.existsSync(path.join(this.basePath, paths)); | ||
@@ -34,0 +34,0 @@ } |
@@ -28,5 +28,5 @@ import { CONSOLE_COLORS, DEBUG } from "./constants"; | ||
if(this.storageAdapter.exists(TOKEN_FILE)) { | ||
if((await this.storageAdapter.exists(TOKEN_FILE))) { | ||
if(DEBUG) console.log(CONSOLE_COLORS.fg.magenta + "[AUTHENTICATOR] Found Token File in Storage, reading it...", CONSOLE_COLORS.reset); | ||
var str = this.storageAdapter.get(TOKEN_FILE); | ||
var str = await this.storageAdapter.get(TOKEN_FILE); | ||
if(str) { | ||
@@ -33,0 +33,0 @@ this.#token = JSON.parse(str); |
export interface StorageAdapter { | ||
set(path: string, value: string):boolean | ||
get(path: string):string | ||
exists(path: string):boolean | ||
set(path: string, value: string):Promise<boolean> | ||
get(path: string):Promise<string> | ||
exists(path: string):Promise<boolean> | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
211952
4125