This commit is contained in:
Sebastian 2023-05-22 13:12:38 -03:00
parent 984cba226f
commit 76d2524b8b
No known key found for this signature in database
GPG Key ID: 173909D1A5F66069
8 changed files with 25 additions and 522 deletions

View File

@ -19,4 +19,4 @@ export function processArgv(): string[];
export function readlinePrompt(prompt: string): Promise<string>;
export function pathBasename(s: string): string;
export function setUnhandledRejectionHandler(h: (e: any) => void): void;
export function getenv(name: string): string | undefined;
export function getenv(name: string): string | undefined;

View File

@ -1,17 +1,25 @@
import { HttpLibArgs } from "./http-common.js";
import { HttpRequestLibrary, HttpRequestOptions, HttpResponse } from "./http.js";
import {
HttpRequestLibrary,
HttpRequestOptions,
HttpResponse,
} from "./http.js";
/**
* Implementation of the HTTP request library interface for node.
*/
export declare class HttpLibImpl implements HttpRequestLibrary {
private throttle;
private throttlingEnabled;
constructor(args?: HttpLibArgs);
/**
* Set whether requests should be throttled.
*/
setThrottling(enabled: boolean): void;
fetch(url: string, opt?: HttpRequestOptions): Promise<HttpResponse>;
get(url: string, opt?: HttpRequestOptions): Promise<HttpResponse>;
postJson(url: string, body: any, opt?: HttpRequestOptions): Promise<HttpResponse>;
private throttle;
private throttlingEnabled;
constructor(args?: HttpLibArgs);
/**
* Set whether requests should be throttled.
*/
setThrottling(enabled: boolean): void;
fetch(url: string, opt?: HttpRequestOptions): Promise<HttpResponse>;
get(url: string, opt?: HttpRequestOptions): Promise<HttpResponse>;
postJson(
url: string,
body: any,
opt?: HttpRequestOptions,
): Promise<HttpResponse>;
}

View File

@ -30,7 +30,8 @@ import * as common from "./http-common.js";
export * from "./http-common.js";
export function createPlatformHttpLib(args?: common.HttpLibArgs): common.HttpRequestLibrary {
export function createPlatformHttpLib(
args?: common.HttpLibArgs,
): common.HttpRequestLibrary {
return new impl.HttpLibImpl(args);
}

View File

@ -23,8 +23,6 @@ test("iban validation", (t) => {
t.assert(validateIban("NL71RABO9996666779").type === "invalid");
});
test("iban generation", (t) => {
let iban1 = generateIban("DE", 10);
console.log("generated IBAN", iban1);

View File

@ -276,7 +276,7 @@ export function generateIban(countryCode: string, length: number): string {
for (let i = 0; i < length; i++) {
const cc = ccZero + (Math.floor(Math.random() * 100) % 10);
appendDigit(digits, cc)
appendDigit(digits, cc);
ibanSuffix += String.fromCharCode(cc);
}

View File

@ -191,7 +191,6 @@ export interface WaitingForRetryNotification {
numDue: number;
}
export interface ExchangeAddedNotification {
type: NotificationType.ExchangeAdded;
}

View File

@ -1,10 +1,8 @@
// @ts-ignore
import * as _qjsOsImp from "os";
// @ts-ignore
import * as _qjsStdImp from "std";
export interface QjsHttpResp {
status: number;
data: ArrayBuffer;
@ -17,7 +15,6 @@ export interface QjsHttpOptions {
headers?: string[];
}
export interface QjsOsLib {
fetchHttp(url: string, options?: QjsHttpOptions): Promise<QjsHttpResp>;
postMessageToHost(s: string): void;
@ -34,4 +31,4 @@ export interface QjsStdLib {
// This is not the nodejs "os" module, but the qjs "os" module.
export const qjsOs: QjsOsLib = _qjsOsImp as any;
export const qjsStd: QjsStdLib = _qjsStdImp as any;
export const qjsStd: QjsStdLib = _qjsStdImp as any;

File diff suppressed because it is too large Load Diff