@technoeren/tdk-api
Advanced tools
Comparing version 0.1.9 to 0.2.0
@@ -0,4 +1,7 @@ | ||
import { IGetWord } from '../types'; | ||
export declare class TDKAPI { | ||
constructor(); | ||
getWord(word: string): string; | ||
getWord(word: string): Promise<IGetWord>; | ||
isExistWord(word: string): Promise<boolean>; | ||
getProVerbs(value: string): Promise<any>; | ||
} |
"use strict"; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const axios_1 = __importDefault(require("axios")); | ||
const tdk_errors_1 = require("../errors/tdk-errors"); | ||
class TDKAPI { | ||
constructor() { } | ||
getWord(word) { | ||
return word; | ||
async getWord(word) { | ||
if (word.trim().length < 1) | ||
throw new tdk_errors_1.InvalidWord(); | ||
let response = await axios_1.default.get(`https://sozluk.gov.tr/gts?ara=${encodeURI(word)}`); | ||
if (response.data.error) | ||
throw new tdk_errors_1.ValueNotFound(); | ||
let anlamlar = []; | ||
for (const element of response.data[0].anlamlarListe) { | ||
anlamlar.push({ | ||
anlam: element.anlam, | ||
ornek: element.orneklerListe ? element.orneklerListe[0].ornek : null, | ||
}); | ||
} | ||
return { | ||
anlamlar, | ||
atasozu_deyim: response.data[0].atasozu | ||
? response.data[0].atasozu[0].madde | ||
: null, | ||
}; | ||
} | ||
async isExistWord(word) { | ||
if (word.trim().length < 1) | ||
throw new tdk_errors_1.InvalidWord(); | ||
let response = await axios_1.default.get(`https://sozluk.gov.tr/gts?ara=${encodeURI(word)}`); | ||
return response.data.length > 0 ? true : false; | ||
} | ||
async getProVerbs(value) { | ||
if (value.trim().length < 1) | ||
throw new tdk_errors_1.InvalidWord(); | ||
let response = await axios_1.default.get(`https://sozluk.gov.tr/atasozu?ara=${encodeURI(value)}`); | ||
if (response.data.error) | ||
throw new tdk_errors_1.ValueNotFound(); | ||
let proverbs = [{ soz: '', anlam: '', tur: '' }]; | ||
for (const element of response.data) { | ||
proverbs.push({ | ||
soz: element.sozum, | ||
tur: element.turu2, | ||
anlam: element.anlami, | ||
}); | ||
} | ||
return { proverbs }; | ||
} | ||
} | ||
exports.TDKAPI = TDKAPI; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); |
{ | ||
"name": "@technoeren/tdk-api", | ||
"version": "0.1.9", | ||
"version": "0.2.0", | ||
"main": "./dist/index.js", | ||
@@ -5,0 +5,0 @@ "types": "./dist/index.d.ts", |
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
9679
204