Socket
Socket
Sign inDemoInstall

wikipedia

Package Overview
Dependencies
9
Maintainers
1
Versions
25
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.1.0 to 1.1.1

10

dist/index.d.ts
import { pageOptions, searchOptions, geoOptions, listOptions, eventOptions } from './optionTypes';
import Page from './page';
import { coordinatesResult, eventResult, geoSearchResult, imageResult, langLinksResult, languageResult, mobileSections, relatedResult, title, wikiMediaResult, wikiSearchResult, wikiSummary } from './resultTypes';
import { coordinatesResult, eventResult, geoSearchResult, imageResult, langLinksResult, languageResult, mobileSections, relatedResult, title, wikiMediaResult, wikiSearchResult, wikiSummary, notFound } from './resultTypes';
/**

@@ -254,3 +254,11 @@ * The default wiki export

random(format?: "summary" | "related" | "title" | "mobile-sections" | "mobile-sections-lead" | undefined): Promise<wikiSummary | title | relatedResult | mobileSections | string>;
/**
* Returns mobile-optimised HTML of a page
*
* @param title - The title of the page to query
* @param pageOptions - Whether to redirect in case of 302
* @returns Returns HTML string
*/
mobileHtml(title: string, pageOptions?: pageOptions | undefined): Promise<notFound | string>;
};
export default wiki;

@@ -538,2 +538,21 @@ "use strict";

};
/**
* Returns mobile-optimised HTML of a page
*
* @param title - The title of the page to query
* @param pageOptions - Whether to redirect in case of 302
* @returns Returns HTML string
*/
wiki.mobileHtml = async (title, pageOptions) => {
try {
if (pageOptions === null || pageOptions === void 0 ? void 0 : pageOptions.autoSuggest) {
title = await utils_1.setTitleForPage(title);
}
const result = await page_1.mobileHtml(title, pageOptions === null || pageOptions === void 0 ? void 0 : pageOptions.redirect);
return result;
}
catch (error) {
throw new errors_1.htmlError(error);
}
};
exports.default = wiki;

@@ -540,0 +559,0 @@ // For CommonJS default export support

@@ -1,2 +0,2 @@

import { coordinatesResult, imageResult, langLinksResult, pageResult, relatedResult, wikiMediaResult, wikiSummary } from './resultTypes';
import { coordinatesResult, imageResult, langLinksResult, notFound, pageResult, relatedResult, wikiMediaResult, wikiSummary } from './resultTypes';
import { listOptions, pageOptions } from './optionTypes';

@@ -33,2 +33,3 @@ export declare class Page {

_media: wikiMediaResult;
_mobileHtml: string | notFound;
constructor(response: pageResult);

@@ -198,2 +199,10 @@ /**

media: (pageOptions?: pageOptions | undefined) => Promise<wikiMediaResult>;
/**
* Returns mobile-optimised HTML of a page
*
* @param title - The title of the page to query
* @param redirect - Whether to redirect in case of 302
* @returns Returns HTML string
*/
mobileHtml: (pageOptions?: pageOptions | undefined) => Promise<notFound | string>;
runMethod(functionName: string): Promise<any>;

@@ -375,2 +384,10 @@ }

export declare const media: (title: string, redirect?: boolean) => Promise<wikiMediaResult>;
/**
* Returns mobile-optimised HTML of a page
*
* @param title - The title of the page to query
* @param redirect - Whether to redirect in case of 302
* @returns Returns HTML string
*/
export declare const mobileHtml: (title: string, redirect?: boolean) => Promise<notFound | string>;
export default Page;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.media = exports.related = exports.summary = exports.rawInfo = exports.tables = exports.infobox = exports.langLinks = exports.coordinates = exports.references = exports.links = exports.categories = exports.content = exports.html = exports.intro = exports.images = exports.Page = void 0;
exports.mobileHtml = exports.media = exports.related = exports.summary = exports.rawInfo = exports.tables = exports.infobox = exports.langLinks = exports.coordinates = exports.references = exports.links = exports.categories = exports.content = exports.html = exports.intro = exports.images = exports.Page = void 0;
const errors_1 = require("./errors");

@@ -331,2 +331,21 @@ const request_1 = require("./request");

};
/**
* Returns mobile-optimised HTML of a page
*
* @param title - The title of the page to query
* @param redirect - Whether to redirect in case of 302
* @returns Returns HTML string
*/
this.mobileHtml = async (pageOptions) => {
try {
if (!this._mobileHtml) {
const result = await exports.mobileHtml(this.title, pageOptions === null || pageOptions === void 0 ? void 0 : pageOptions.redirect);
this._mobileHtml = result;
}
return this._mobileHtml;
}
catch (error) {
throw new errors_1.htmlError(error);
}
};
this.pageid = response.pageid;

@@ -759,2 +778,19 @@ this.ns = response.ns;

};
/**
* Returns mobile-optimised HTML of a page
*
* @param title - The title of the page to query
* @param redirect - Whether to redirect in case of 302
* @returns Returns HTML string
*/
exports.mobileHtml = async (title, redirect = true) => {
try {
const path = `page/mobile-html/${title}`;
const result = await request_1.makeRestRequest(path, redirect);
return result;
}
catch (error) {
throw new errors_1.htmlError(error);
}
};
exports.default = Page;

9

dist/request.js

@@ -51,4 +51,9 @@ "use strict";

const response = await node_fetch_1.default(encodeURI(REST_API_URL + path), options);
const result = await response.json();
return result;
let result = await response.text();
try {
result = JSON.parse(result);
}
finally {
return result;
}
}

@@ -55,0 +60,0 @@ catch (error) {

@@ -221,1 +221,8 @@ export interface wikiSearchResult {

}
export interface notFound {
type: string;
title: string;
method: string;
detail: string;
uri: string;
}
{
"name": "wikipedia",
"version": "1.1.0",
"version": "1.1.1",
"description": "A JavaScript wrapper for the wikipedia apis",

@@ -5,0 +5,0 @@ "main": "dist",

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc