mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-03 22:37:03 +00:00
Merge branch 'master' of github.com:DefinitelyTyped/DefinitelyTyped into expo-from-janaagaard75
This commit is contained in:
@@ -558,6 +558,12 @@
|
||||
"sourceRepoURL": "http://arshaw.com/fullcalendar/",
|
||||
"asOfVersion": "3.8.0"
|
||||
},
|
||||
{
|
||||
"libraryName": "fuse",
|
||||
"typingsPackageName": "fuse",
|
||||
"sourceRepoURL": "https://github.com/krisk/Fuse",
|
||||
"asOfVersion": "2.6.0"
|
||||
},
|
||||
{
|
||||
"libraryName": "gaea-model",
|
||||
"typingsPackageName": "gaea-model",
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
import * as fs from 'fs';
|
||||
import * as path from 'path';
|
||||
|
||||
const home = path.join(__dirname, '..');
|
||||
const home = path.join(__dirname, "..", "types");
|
||||
|
||||
for (const dirName of fs.readdirSync(home)) {
|
||||
if (dirName.startsWith(".") || dirName === "node_modules" || dirName === "scripts") {
|
||||
|
||||
Vendored
+42
-3
@@ -12,36 +12,75 @@ declare namespace accepts {
|
||||
interface Accepts {
|
||||
/**
|
||||
* Return the first accepted charset. If nothing in `charsets` is accepted, then `false` is returned.
|
||||
* If no charsets are supplied, all accepted charsets are returned, in the order of the client's preference
|
||||
* (most preferred first).
|
||||
*/
|
||||
charset(): string[];
|
||||
charset(charsets: string[]): string | false;
|
||||
charset(...charsets: string[]): string | false;
|
||||
|
||||
/**
|
||||
* Return the charsets that the request accepts, in the order of the client's preference (most preferred first).
|
||||
* Return the first accepted charset. If nothing in `charsets` is accepted, then `false` is returned.
|
||||
* If no charsets are supplied, all accepted charsets are returned, in the order of the client's preference
|
||||
* (most preferred first).
|
||||
*/
|
||||
charsets(): string[];
|
||||
charsets(charsets: string[]): string | false;
|
||||
charsets(...charsets: string[]): string | false;
|
||||
|
||||
/**
|
||||
* Return the first accepted encoding. If nothing in `encodings` is accepted, then `false` is returned.
|
||||
* If no encodings are supplied, all accepted encodings are returned, in the order of the client's preference
|
||||
* (most preferred first).
|
||||
*/
|
||||
encoding(): string[];
|
||||
encoding(encodings: string[]): string | false;
|
||||
encoding(...encodings: string[]): string | false;
|
||||
|
||||
/**
|
||||
* Return the encodings that the request accepts, in the order of the client's preference (most preferred first).
|
||||
* Return the first accepted encoding. If nothing in `encodings` is accepted, then `false` is returned.
|
||||
* If no encodings are supplied, all accepted encodings are returned, in the order of the client's preference
|
||||
* (most preferred first).
|
||||
*/
|
||||
encodings(): string[];
|
||||
encodings(encodings: string[]): string | false;
|
||||
encodings(...encodings: string[]): string | false;
|
||||
|
||||
/**
|
||||
* Return the first accepted language. If nothing in `languages` is accepted, then `false` is returned.
|
||||
* If no languaes are supplied, all accepted languages are returned, in the order of the client's preference
|
||||
* (most preferred first).
|
||||
*/
|
||||
language(): string[];
|
||||
language(languages: string[]): string | false;
|
||||
language(...languages: string[]): string | false;
|
||||
|
||||
/**
|
||||
* Return the languages that the request accepts, in the order of the client's preference (most preferred first).
|
||||
* Return the first accepted language. If nothing in `languages` is accepted, then `false` is returned.
|
||||
* If no languaes are supplied, all accepted languages are returned, in the order of the client's preference
|
||||
* (most preferred first).
|
||||
*/
|
||||
languages(): string[];
|
||||
languages(languages: string[]): string | false;
|
||||
languages(...languages: string[]): string | false;
|
||||
|
||||
/**
|
||||
* Return the first accepted language. If nothing in `languages` is accepted, then `false` is returned.
|
||||
* If no languaes are supplied, all accepted languages are returned, in the order of the client's preference
|
||||
* (most preferred first).
|
||||
*/
|
||||
lang(): string[];
|
||||
lang(languages: string[]): string | false;
|
||||
lang(...languages: string[]): string | false;
|
||||
|
||||
/**
|
||||
* Return the first accepted language. If nothing in `languages` is accepted, then `false` is returned.
|
||||
* If no languaes are supplied, all accepted languages are returned, in the order of the client's preference
|
||||
* (most preferred first).
|
||||
*/
|
||||
langs(): string[];
|
||||
langs(languages: string[]): string | false;
|
||||
langs(...languages: string[]): string | false;
|
||||
|
||||
/**
|
||||
* Return the first accepted type (and it is returned as the same text as what appears in the `types` array). If nothing in `types` is accepted, then `false` is returned.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { ActionsSdkApp, ActionsSdkAppOptions, DialogflowApp, DialogflowAppOptions, AssistantApp,
|
||||
Responses, Transactions } from 'actions-on-google';
|
||||
import * as express from 'express';
|
||||
import express = require('express');
|
||||
|
||||
function testActionsSdk(request: express.Request, response: express.Response) {
|
||||
const app = new ActionsSdkApp({request, response});
|
||||
|
||||
Vendored
+1
-1
@@ -1,4 +1,4 @@
|
||||
// Type definitions for actions-on-google 1.7
|
||||
// Type definitions for actions-on-google 1.8
|
||||
// Project: https://github.com/actions-on-google/actions-on-google-nodejs
|
||||
// Definitions by: Joel Hegg <https://github.com/joelhegg>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
+3
-1
@@ -20,7 +20,9 @@ export enum ImageDisplays {
|
||||
*/
|
||||
WHITE,
|
||||
/**
|
||||
* Image is centered and resized so the image fits perfectly in the container.
|
||||
* Image is scaled such that the image width matches the container width. This may crop the top
|
||||
* and bottom of the image if the scaled image height is greater than the container height. This
|
||||
* is similar to "Zoom Mode" on a widescreen TV when playing a 4:3 video.
|
||||
*/
|
||||
CROPPED
|
||||
}
|
||||
|
||||
+6
-1
@@ -594,7 +594,12 @@ export namespace TransactionValues {
|
||||
/**
|
||||
* Use external payment gateway tokenization API to tokenize selected payment method.
|
||||
*/
|
||||
PAYMENT_GATEWAY
|
||||
PAYMENT_GATEWAY,
|
||||
/**
|
||||
* Allows payment service to pass public key for payment info encryption and receive encrypted
|
||||
* response.
|
||||
*/
|
||||
DIRECT
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -25,4 +25,4 @@
|
||||
"transactions.d.ts",
|
||||
"actions-on-google-tests.ts"
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,10 @@
|
||||
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": ["es5", "scripthost"],
|
||||
"lib": [
|
||||
"es5",
|
||||
"scripthost"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
|
||||
Vendored
+349
-112
File diff suppressed because it is too large
Load Diff
@@ -1,6 +1,3 @@
|
||||
{
|
||||
"extends": "dtslint/dt.json",
|
||||
"rules": {
|
||||
"no-const-enum": false
|
||||
}
|
||||
"extends": "dtslint/dt.json"
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ const getServer = () => {
|
||||
return server;
|
||||
};
|
||||
|
||||
(() => {
|
||||
{
|
||||
// https://msdn.microsoft.com/en-us/library/windows/desktop/ms693376(v=vs.85).aspx
|
||||
const server = new ActiveXObject('FaxComEx.FaxServer');
|
||||
const document = new ActiveXObject('FaxComEx.FaxDocument');
|
||||
@@ -35,10 +35,10 @@ const getServer = () => {
|
||||
// https://msdn.microsoft.com/en-us/library/windows/desktop/ms692919(v=vs.85).aspx
|
||||
server.Connect('');
|
||||
server.Connect('computername');
|
||||
})();
|
||||
}
|
||||
|
||||
// https://msdn.microsoft.com/en-us/library/windows/desktop/ms693502(v=vs.85).aspx
|
||||
(() => {
|
||||
{
|
||||
const getInitializedDevice = () => {
|
||||
const ret = getServer().GetDevices().ItemById(1);
|
||||
ret.ReceiveMode = FAXCOMEXLib.FAX_DEVICE_RECEIVE_MODE_ENUM.fdrmAUTO_ANSWER;
|
||||
@@ -54,17 +54,17 @@ const getServer = () => {
|
||||
// abandoning changes to configuration, using the Refresh method
|
||||
device = getInitializedDevice();
|
||||
device.Refresh();
|
||||
})();
|
||||
}
|
||||
|
||||
// https://msdn.microsoft.com/en-us/library/windows/desktop/ms693502(v=vs.85).aspx
|
||||
(() => {
|
||||
{
|
||||
const incomingJob = getServer().Folders.IncomingQueue.GetJobs().Item(1);
|
||||
incomingJob.Refresh();
|
||||
const currentPage = incomingJob.CurrentPage;
|
||||
})();
|
||||
}
|
||||
|
||||
// https://msdn.microsoft.com/en-us/library/windows/desktop/ms692922(v=vs.85).aspx
|
||||
(() => {
|
||||
{
|
||||
const server = getServer();
|
||||
|
||||
WScript.Echo(`Server information:
|
||||
@@ -72,10 +72,10 @@ API Version: ${server.APIVersion}
|
||||
Debug: ${server.Debug}
|
||||
Build and version: ${server.MajorBuild}.${server.MinorBuild}.${server.MajorVersion}.${server.MinorVersion}
|
||||
Server name: ${server.ServerName}`);
|
||||
})();
|
||||
}
|
||||
|
||||
// https://msdn.microsoft.com/en-us/library/windows/desktop/ms693455(v=vs.85).aspx
|
||||
(() => {
|
||||
{
|
||||
const activity = getServer().Activity;
|
||||
activity.Refresh();
|
||||
|
||||
@@ -84,10 +84,10 @@ ${activity.IncomingMessages} incoming messages
|
||||
${activity.OutgoingMessages} outgoing messages
|
||||
${activity.RoutingMessages} routing messages
|
||||
${activity.QueuedMessages} queued messages`);
|
||||
})();
|
||||
}
|
||||
|
||||
// https://msdn.microsoft.com/en-us/library/windows/desktop/ms693400(v=vs.85).aspx
|
||||
(() => {
|
||||
{
|
||||
const device = getServer().GetDevices().Item(1);
|
||||
device.CSID = 'Accounts payable';
|
||||
device.Description = 'Primary fax device';
|
||||
@@ -96,10 +96,10 @@ ${activity.QueuedMessages} queued messages`);
|
||||
device.SendEnabled = true;
|
||||
device.TSID = 'Accounts payable';
|
||||
device.Save();
|
||||
})();
|
||||
}
|
||||
|
||||
// https://msdn.microsoft.com/en-us/library/windows/desktop/ms692985(v=vs.85).aspx
|
||||
(() => {
|
||||
{
|
||||
const devices = getServer().GetDevices();
|
||||
WScript.Echo(`This server has ${devices.Count} fax devices`);
|
||||
for (let i = 1; i <= devices.Count; i++) {
|
||||
@@ -124,10 +124,10 @@ Sending now: ${device.SendingNow}`);
|
||||
device.UseRoutingMethod(routingMethods[0], false);
|
||||
device.Save();
|
||||
});
|
||||
})();
|
||||
}
|
||||
|
||||
// https://msdn.microsoft.com/en-us/library/windows/desktop/ms693486(v=vs.85).aspx
|
||||
(() => {
|
||||
{
|
||||
const outputRuleInfo = (rule: FAXCOMEXLib.FaxOutboundRoutingRule, index?: number) => {
|
||||
WScript.Echo(`
|
||||
Outbound routing rule number: ${index || 'unknown'}
|
||||
@@ -193,13 +193,11 @@ Input 1, 2, 3, 4, or 0 to exit
|
||||
areaCode = parseInt(VB.InputBox('Enter the area code'), 10);
|
||||
rule = outboundRoutingRules.Add(countryCode, areaCode, true, '', id);
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
})();
|
||||
}
|
||||
|
||||
// https://msdn.microsoft.com/en-us/library/windows/desktop/ms693408(v=vs.85).aspx
|
||||
(() => {
|
||||
{
|
||||
const server = getServer();
|
||||
const outboundRouting = server.OutboundRouting;
|
||||
const outboundRoutingGroups = outboundRouting.GetGroups();
|
||||
@@ -233,13 +231,14 @@ Device status: ${routingGroup.Status}
|
||||
});
|
||||
|
||||
// allow user to remove a routing group
|
||||
if (VB.InputBox('Do you want to remove a routing group (Y/N)?') === 'N') { return; }
|
||||
const itemNumber = VB.InputBox('Enter the item number for the group you want to remove');
|
||||
outboundRoutingGroups.Remove(itemNumber);
|
||||
})();
|
||||
if (VB.InputBox('Do you want to remove a routing group (Y/N)?') === 'Y') {
|
||||
const itemNumber = VB.InputBox('Enter the item number for the group you want to remove');
|
||||
outboundRoutingGroups.Remove(itemNumber);
|
||||
}
|
||||
}
|
||||
|
||||
// https://msdn.microsoft.com/en-us/library/windows/desktop/aa964960(v=vs.85).aspx
|
||||
(() => {
|
||||
{
|
||||
const accountSet = getServer().FaxAccountSet;
|
||||
const accounts = collectionToArray(accountSet.GetAccounts());
|
||||
WScript.Echo(`Number of accounts: ${accounts.length}`);
|
||||
@@ -248,10 +247,10 @@ Device status: ${routingGroup.Status}
|
||||
const accountName = VB.InputBox('Enter an account name');
|
||||
accountSet.AddAccount(accountName);
|
||||
accountSet.RemoveAccount(accountName);
|
||||
})();
|
||||
}
|
||||
|
||||
// https://msdn.microsoft.com/en-us/library/windows/desktop/ms692952(v=vs.85).aspx
|
||||
(() => {
|
||||
{
|
||||
const incomingJobs = collectionToArray(getServer().Folders.IncomingQueue.GetJobs());
|
||||
WScript.Echo(`There are ${incomingJobs.length} jobs in the incoming queue.`);
|
||||
const n = parseInt(VB.InputBox('Input the number of a job for which you want information'), 10);
|
||||
@@ -284,10 +283,10 @@ TSID: ${job.TSID}
|
||||
job.CopyTiff(fileName);
|
||||
new ActiveXObject('WScript.Shell').Run(fileName);
|
||||
}
|
||||
})();
|
||||
}
|
||||
|
||||
// https://msdn.microsoft.com/en-us/library/windows/desktop/ms692914(v=vs.85).aspx
|
||||
(() => {
|
||||
{
|
||||
const server = new ActiveXObject('FaxComEx.FaxServer');
|
||||
server.Connect('');
|
||||
const outgoingQueue = server.Folders.OutgoingQueue;
|
||||
@@ -300,10 +299,10 @@ TSID: ${job.TSID}
|
||||
outgoingQueue.DiscountRateStart = new Date(0, 0, 0, 1).getVarDate();
|
||||
outgoingQueue.UseDeviceTSID = true;
|
||||
outgoingQueue.Save();
|
||||
})();
|
||||
}
|
||||
|
||||
// https://msdn.microsoft.com/en-us/library/windows/desktop/ms693393(v=vs.85).aspx
|
||||
(() => {
|
||||
{
|
||||
const outgoingQueue = getServer().Folders.OutgoingQueue;
|
||||
outgoingQueue.Refresh();
|
||||
WScript.Echo(`There are ${outgoingQueue.GetJobs().Count} faxes in the outgoing queue`);
|
||||
@@ -357,10 +356,10 @@ the job?
|
||||
job.Resume();
|
||||
break;
|
||||
}
|
||||
})();
|
||||
}
|
||||
|
||||
// https://msdn.microsoft.com/en-us/library/windows/desktop/ms692936(v=vs.85).aspx
|
||||
(() => {
|
||||
{
|
||||
const document = new ActiveXObject('FaxComEx.FaxDocument');
|
||||
document.Body = 'C:\\docs\\body.txt';
|
||||
document.DocumentName = 'My First Fax';
|
||||
@@ -401,10 +400,10 @@ the job?
|
||||
WScript.Echo(`The job ID is ${jobID}`);
|
||||
|
||||
server.Disconnect();
|
||||
})();
|
||||
}
|
||||
|
||||
// https://msdn.microsoft.com/en-us/library/windows/desktop/ms693479(v=vs.85).aspx
|
||||
(() => {
|
||||
{
|
||||
const document = new ActiveXObject('FaxComEx.FaxDocument');
|
||||
document.Body = 'C:\\docs\\body.txt';
|
||||
document.DocumentName = 'My First Fax';
|
||||
@@ -428,10 +427,10 @@ the job?
|
||||
while (recipients.Count > 0) {
|
||||
recipients.Remove(1);
|
||||
}
|
||||
})();
|
||||
}
|
||||
|
||||
// https://msdn.microsoft.com/en-us/library/windows/desktop/aa964962(v=vs.85).aspx
|
||||
(() => {
|
||||
{
|
||||
const server = getServer();
|
||||
const prefetchCount = parseInt(VB.InputBox('How many messages should be prefetched?'), 10);
|
||||
server.CurrentAccount.Folders.IncomingArchive.Refresh();
|
||||
@@ -442,7 +441,7 @@ the job?
|
||||
const message = messageIterator.Message as FAXCOMEXLib.FaxIncomingMessage;
|
||||
if (messageIterator.AtEOF) {
|
||||
WScript.Echo(`End of file reached`);
|
||||
return;
|
||||
break;
|
||||
}
|
||||
if (!message.WasReAssigned) {
|
||||
if (VB.InputBox('Message not reassigned. Reassign (Y/N)?') === 'Y') {
|
||||
@@ -455,10 +454,10 @@ the job?
|
||||
}
|
||||
messageIterator.MoveNext();
|
||||
}
|
||||
})();
|
||||
}
|
||||
|
||||
// https://msdn.microsoft.com/en-us/library/windows/desktop/ms693402(v=vs.85).aspx
|
||||
(() => {
|
||||
{
|
||||
const server = getServer();
|
||||
const prefetchCount = parseInt(VB.InputBox('How many messages should be prefetched?'), 10);
|
||||
server.Folders.OutgoingArchive.Refresh();
|
||||
@@ -468,7 +467,7 @@ the job?
|
||||
if (i > 1 && VB.InputBox('View next message? (Y/N)') !== 'Y') { break; }
|
||||
if (messageIterator.AtEOF) {
|
||||
WScript.Echo(`End of file reached`);
|
||||
return;
|
||||
break;
|
||||
}
|
||||
const message = messageIterator.Message as FAXCOMEXLib.FaxOutgoingMessage;
|
||||
|
||||
@@ -498,10 +497,10 @@ TSID: ${message.TSID}`);
|
||||
message.Delete();
|
||||
}
|
||||
}
|
||||
})();
|
||||
}
|
||||
|
||||
// https://msdn.microsoft.com/en-us/library/windows/desktop/ms693472(v=vs.85).aspx
|
||||
(() => {
|
||||
{
|
||||
const server = getServer();
|
||||
const outgoingArchive = server.Folders.OutgoingArchive;
|
||||
WScript.Echo(`
|
||||
@@ -526,12 +525,11 @@ Is archive used? ${outgoingArchive.UseArchive}`.trim()
|
||||
outgoingArchive.GetMessage(messageID).CopyTiff(fileName);
|
||||
new ActiveXObject('WScript.Shell').Run(fileName);
|
||||
}
|
||||
})();
|
||||
}
|
||||
|
||||
(() => {
|
||||
{
|
||||
const server = getServer();
|
||||
const messageIterator = server.Folders.OutgoingArchive.GetMessages();
|
||||
if (messageIterator.AtEOF) { return; }
|
||||
messageIterator.MoveFirst();
|
||||
while (!messageIterator.AtEOF) {
|
||||
const message = messageIterator.Message;
|
||||
@@ -543,10 +541,10 @@ Transmission start: ${new Date(message.TransmissionStart)}
|
||||
`.trim());
|
||||
messageIterator.MoveNext();
|
||||
}
|
||||
})();
|
||||
}
|
||||
|
||||
// https://msdn.microsoft.com/en-us/library/windows/desktop/ms692976(v=vs.85).aspx
|
||||
(() => {
|
||||
{
|
||||
const server = getServer();
|
||||
const prefetchCount = parseInt(VB.InputBox('How many messages should be prefetched?'), 10);
|
||||
server.Folders.IncomingArchive.Refresh();
|
||||
@@ -557,7 +555,7 @@ Transmission start: ${new Date(message.TransmissionStart)}
|
||||
const message = messageIterator.Message as FAXCOMEXLib.FaxIncomingMessage;
|
||||
if (messageIterator.AtEOF) {
|
||||
WScript.Echo(`End of file reached`);
|
||||
return;
|
||||
break;
|
||||
}
|
||||
const fileName = VB.InputBox('Enter path to save TIFF file');
|
||||
message.CopyTiff(fileName);
|
||||
@@ -565,10 +563,10 @@ Transmission start: ${new Date(message.TransmissionStart)}
|
||||
|
||||
messageIterator.MoveNext();
|
||||
}
|
||||
})();
|
||||
}
|
||||
|
||||
// https://msdn.microsoft.com/en-us/library/windows/desktop/ms693406(v=vs.85).aspx
|
||||
(() => {
|
||||
{
|
||||
const server = getServer();
|
||||
const incomingArchive = server.Folders.IncomingArchive;
|
||||
incomingArchive.Refresh();
|
||||
@@ -587,9 +585,9 @@ Is archive used? ${incomingArchive.UseArchive}
|
||||
incomingArchive.Save();
|
||||
|
||||
const messageID = VB.InputBox('Message ID to retrieve information? (Leave empty, or Cancel, to exit)');
|
||||
if (messageID === '') { return; }
|
||||
const message = incomingArchive.GetMessage(messageID);
|
||||
WScript.Echo(`
|
||||
if (messageID !== '') {
|
||||
const message = incomingArchive.GetMessage(messageID);
|
||||
WScript.Echo(`
|
||||
Caller ID: ${message.CallerId}
|
||||
CSID: ${message.CSID}
|
||||
Device name: ${message.DeviceName}
|
||||
@@ -603,13 +601,14 @@ Transmission end: ${new Date(message.TransmissionEnd)}
|
||||
TSID: ${message.TSID}
|
||||
`.trim());
|
||||
|
||||
if (VB.InputBox('Delete this message from the archive (Y/N)?') === 'Y') {
|
||||
message.Delete();
|
||||
if (VB.InputBox('Delete this message from the archive (Y/N)?') === 'Y') {
|
||||
message.Delete();
|
||||
}
|
||||
}
|
||||
})();
|
||||
}
|
||||
|
||||
// https://msdn.microsoft.com/en-us/library/windows/desktop/ms693401(v=vs.85).aspx
|
||||
(() => {
|
||||
{
|
||||
const server = getServer();
|
||||
const loggingOptions = server.LoggingOptions;
|
||||
const activityLogging = loggingOptions.ActivityLogging;
|
||||
@@ -626,10 +625,10 @@ TSID: ${message.TSID}
|
||||
eventLogging.InitEventsLevel = FAXCOMEXLib.FAX_LOG_LEVEL_ENUM.fllMAX;
|
||||
eventLogging.OutboundEventsLevel = FAXCOMEXLib.FAX_LOG_LEVEL_ENUM.fllNONE;
|
||||
eventLogging.Save();
|
||||
})();
|
||||
}
|
||||
|
||||
// https://msdn.microsoft.com/en-us/library/windows/desktop/ms693387(v=vs.85).aspx
|
||||
(() => {
|
||||
{
|
||||
const server = getServer();
|
||||
const receiptOptions = server.ReceiptOptions;
|
||||
receiptOptions.Refresh();
|
||||
@@ -649,10 +648,10 @@ Use for inbound routing? ${receiptOptions.UseForInboundRouting}
|
||||
receiptOptions.SMTPServer = 'My SMTP Server';
|
||||
receiptOptions.UseForInboundRouting = true;
|
||||
receiptOptions.Save();
|
||||
})();
|
||||
}
|
||||
|
||||
// https://msdn.microsoft.com/en-us/library/windows/desktop/ms693462(v=vs.85).aspx
|
||||
(() => {
|
||||
{
|
||||
const server = getServer();
|
||||
collectionToArray(server.GetDeviceProviders()).forEach((provider, index) => {
|
||||
WScript.Echo(`
|
||||
@@ -668,29 +667,29 @@ Unique name: ${provider.UniqueName}
|
||||
|
||||
new VBArray(provider.DeviceIds).toArray().forEach(id => WScript.Echo(id));
|
||||
});
|
||||
})();
|
||||
}
|
||||
|
||||
// https://msdn.microsoft.com/en-us/library/windows/desktop/ms693437(v=vs.85).aspx -- for a fax device
|
||||
(() => {
|
||||
{
|
||||
const server = getServer();
|
||||
const device = server.GetDevices().Item(1);
|
||||
const deviceProperty = toSafeArray(1, 2, 3);
|
||||
const propertyName = '{B1F944B9-9A16-45d1-933A-4060A4871AB0}';
|
||||
device.SetExtensionProperty(propertyName, deviceProperty);
|
||||
new VBArray(device.GetExtensionProperty(propertyName)).toArray().forEach(x => WScript.Echo(x));
|
||||
})();
|
||||
}
|
||||
|
||||
// https://msdn.microsoft.com/en-us/library/windows/desktop/ms693437(v=vs.85).aspx -- for a fax device
|
||||
(() => {
|
||||
{
|
||||
const server = getServer();
|
||||
const serverProperty = toSafeArray(4, 2, 3);
|
||||
const propertyName = `{AC7D0DEE-B6E5-4a44-AF45-835C58CB44D2}`;
|
||||
server.SetExtensionProperty(propertyName, serverProperty);
|
||||
new VBArray(server.GetExtensionProperty(propertyName)).toArray().forEach(x => WScript.Echo(x));
|
||||
})();
|
||||
}
|
||||
|
||||
// https://msdn.microsoft.com/en-us/library/windows/desktop/ms693013(v=vs.85).aspx
|
||||
(() => {
|
||||
{
|
||||
const server = getServer();
|
||||
|
||||
ActiveXObject.on(server, 'OnOutgoingJobAdded', ['pFaxServer', 'bstrJobId'], prm => WScript.Echo('New job added to queue'));
|
||||
@@ -727,4 +726,4 @@ TSID: ${status.TSID}
|
||||
FAXCOMEXLib.FAX_SERVER_EVENTS_TYPE_ENUM.fsetFXSSVC_ENDED +
|
||||
FAXCOMEXLib.FAX_SERVER_EVENTS_TYPE_ENUM.fsetOUT_QUEUE
|
||||
);
|
||||
})();
|
||||
}
|
||||
|
||||
Vendored
+46
-79
@@ -7,7 +7,7 @@
|
||||
/// <reference types="activex-stdole" />
|
||||
|
||||
declare namespace FAXCOMEXLib {
|
||||
// tslint:disable-next-line no-const-enum
|
||||
// tslint:disable-next-line:no-const-enum
|
||||
const enum FAX_ACCESS_RIGHTS_ENUM {
|
||||
farMANAGE_CONFIG = 64,
|
||||
farMANAGE_IN_ARCHIVE = 256,
|
||||
@@ -22,7 +22,7 @@ declare namespace FAXCOMEXLib {
|
||||
farSUBMIT_NORMAL = 2,
|
||||
}
|
||||
|
||||
// tslint:disable-next-line no-const-enum
|
||||
// tslint:disable-next-line:no-const-enum
|
||||
const enum FAX_ACCESS_RIGHTS_ENUM_2 {
|
||||
far2MANAGE_ARCHIVES = 256,
|
||||
far2MANAGE_CONFIG = 64,
|
||||
@@ -36,7 +36,7 @@ declare namespace FAXCOMEXLib {
|
||||
far2SUBMIT_NORMAL = 2,
|
||||
}
|
||||
|
||||
// tslint:disable-next-line no-const-enum
|
||||
// tslint:disable-next-line:no-const-enum
|
||||
const enum FAX_ACCOUNT_EVENTS_TYPE_ENUM {
|
||||
faetFXSSVC_ENDED = 16,
|
||||
faetIN_ARCHIVE = 4,
|
||||
@@ -46,21 +46,21 @@ declare namespace FAXCOMEXLib {
|
||||
faetOUT_QUEUE = 2,
|
||||
}
|
||||
|
||||
// tslint:disable-next-line no-const-enum
|
||||
// tslint:disable-next-line:no-const-enum
|
||||
const enum FAX_COVERPAGE_TYPE_ENUM {
|
||||
fcptLOCAL = 1,
|
||||
fcptNONE = 0,
|
||||
fcptSERVER = 2,
|
||||
}
|
||||
|
||||
// tslint:disable-next-line no-const-enum
|
||||
// tslint:disable-next-line:no-const-enum
|
||||
const enum FAX_DEVICE_RECEIVE_MODE_ENUM {
|
||||
fdrmAUTO_ANSWER = 1,
|
||||
fdrmMANUAL_ANSWER = 2,
|
||||
fdrmNO_ANSWER = 0,
|
||||
}
|
||||
|
||||
// tslint:disable-next-line no-const-enum
|
||||
// tslint:disable-next-line:no-const-enum
|
||||
const enum FAX_GROUP_STATUS_ENUM {
|
||||
fgsALL_DEV_NOT_VALID = 2,
|
||||
fgsALL_DEV_VALID = 0,
|
||||
@@ -68,7 +68,7 @@ declare namespace FAXCOMEXLib {
|
||||
fgsSOME_DEV_NOT_VALID = 3,
|
||||
}
|
||||
|
||||
// tslint:disable-next-line no-const-enum
|
||||
// tslint:disable-next-line:no-const-enum
|
||||
const enum FAX_JOB_EXTENDED_STATUS_ENUM {
|
||||
fjesANSWERED = 5,
|
||||
fjesBAD_ADDRESS = 10,
|
||||
@@ -93,7 +93,7 @@ declare namespace FAXCOMEXLib {
|
||||
fjesTRANSMITTING = 4,
|
||||
}
|
||||
|
||||
// tslint:disable-next-line no-const-enum
|
||||
// tslint:disable-next-line:no-const-enum
|
||||
const enum FAX_JOB_OPERATIONS_ENUM {
|
||||
fjoDELETE = 16,
|
||||
fjoPAUSE = 2,
|
||||
@@ -104,7 +104,7 @@ declare namespace FAXCOMEXLib {
|
||||
fjoVIEW = 1,
|
||||
}
|
||||
|
||||
// tslint:disable-next-line no-const-enum
|
||||
// tslint:disable-next-line:no-const-enum
|
||||
const enum FAX_JOB_STATUS_ENUM {
|
||||
fjsCANCELED = 512,
|
||||
fjsCANCELING = 1024,
|
||||
@@ -119,14 +119,14 @@ declare namespace FAXCOMEXLib {
|
||||
fjsROUTING = 2048,
|
||||
}
|
||||
|
||||
// tslint:disable-next-line no-const-enum
|
||||
// tslint:disable-next-line:no-const-enum
|
||||
const enum FAX_JOB_TYPE_ENUM {
|
||||
fjtRECEIVE = 1,
|
||||
fjtROUTING = 2,
|
||||
fjtSEND = 0,
|
||||
}
|
||||
|
||||
// tslint:disable-next-line no-const-enum
|
||||
// tslint:disable-next-line:no-const-enum
|
||||
const enum FAX_LOG_LEVEL_ENUM {
|
||||
fllMAX = 3,
|
||||
fllMED = 2,
|
||||
@@ -134,14 +134,14 @@ declare namespace FAXCOMEXLib {
|
||||
fllNONE = 0,
|
||||
}
|
||||
|
||||
// tslint:disable-next-line no-const-enum
|
||||
// tslint:disable-next-line:no-const-enum
|
||||
const enum FAX_PRIORITY_TYPE_ENUM {
|
||||
fptHIGH = 2,
|
||||
fptLOW = 0,
|
||||
fptNORMAL = 1,
|
||||
}
|
||||
|
||||
// tslint:disable-next-line no-const-enum
|
||||
// tslint:disable-next-line:no-const-enum
|
||||
const enum FAX_PROVIDER_STATUS_ENUM {
|
||||
fpsBAD_GUID = 2,
|
||||
fpsBAD_VERSION = 3,
|
||||
@@ -152,19 +152,19 @@ declare namespace FAXCOMEXLib {
|
||||
fpsSUCCESS = 0,
|
||||
}
|
||||
|
||||
// tslint:disable-next-line no-const-enum
|
||||
// tslint:disable-next-line:no-const-enum
|
||||
const enum FAX_RECEIPT_TYPE_ENUM {
|
||||
frtMAIL = 1,
|
||||
frtMSGBOX = 4,
|
||||
frtNONE = 0,
|
||||
}
|
||||
|
||||
// tslint:disable-next-line no-const-enum
|
||||
// tslint:disable-next-line:no-const-enum
|
||||
const enum FAX_ROUTING_RULE_CODE_ENUM {
|
||||
frrcANY_CODE = 0,
|
||||
}
|
||||
|
||||
// tslint:disable-next-line no-const-enum
|
||||
// tslint:disable-next-line:no-const-enum
|
||||
const enum FAX_RULE_STATUS_ENUM {
|
||||
frsALL_GROUP_DEV_NOT_VALID = 2,
|
||||
frsBAD_DEVICE = 4,
|
||||
@@ -173,14 +173,14 @@ declare namespace FAXCOMEXLib {
|
||||
frsVALID = 0,
|
||||
}
|
||||
|
||||
// tslint:disable-next-line no-const-enum
|
||||
// tslint:disable-next-line:no-const-enum
|
||||
const enum FAX_SCHEDULE_TYPE_ENUM {
|
||||
fstDISCOUNT_PERIOD = 2,
|
||||
fstNOW = 0,
|
||||
fstSPECIFIC_TIME = 1,
|
||||
}
|
||||
|
||||
// tslint:disable-next-line no-const-enum
|
||||
// tslint:disable-next-line:no-const-enum
|
||||
const enum FAX_SERVER_APIVERSION_ENUM {
|
||||
fsAPI_VERSION_0 = 0,
|
||||
fsAPI_VERSION_1 = 65536,
|
||||
@@ -188,7 +188,7 @@ declare namespace FAXCOMEXLib {
|
||||
fsAPI_VERSION_3 = 196608,
|
||||
}
|
||||
|
||||
// tslint:disable-next-line no-const-enum
|
||||
// tslint:disable-next-line:no-const-enum
|
||||
const enum FAX_SERVER_EVENTS_TYPE_ENUM {
|
||||
fsetACTIVITY = 8,
|
||||
fsetCONFIG = 4,
|
||||
@@ -203,14 +203,14 @@ declare namespace FAXCOMEXLib {
|
||||
fsetQUEUE_STATE = 16,
|
||||
}
|
||||
|
||||
// tslint:disable-next-line no-const-enum
|
||||
// tslint:disable-next-line:no-const-enum
|
||||
const enum FAX_SMTP_AUTHENTICATION_TYPE_ENUM {
|
||||
fsatANONYMOUS = 0,
|
||||
fsatBASIC = 1,
|
||||
fsatNTLM = 2,
|
||||
}
|
||||
|
||||
// tslint:disable-next-line no-const-enum
|
||||
// tslint:disable-next-line:no-const-enum
|
||||
const enum FaxConstants {
|
||||
bstrGROUPNAME_ALLDEVICES = '<All Devices>',
|
||||
lDEFAULT_PREFETCH_SIZE = 100,
|
||||
@@ -326,11 +326,10 @@ declare namespace FAXCOMEXLib {
|
||||
}
|
||||
|
||||
/** FaxAccounts Class */
|
||||
class FaxAccounts {
|
||||
private 'FAXCOMEXLib.FaxAccounts_typekey': FaxAccounts;
|
||||
private constructor();
|
||||
interface FaxAccounts {
|
||||
readonly Count: number;
|
||||
Item(vIndex: any): FaxAccount;
|
||||
(vIndex: any): FaxAccount;
|
||||
}
|
||||
|
||||
/** FaxAccountSet Class */
|
||||
@@ -535,10 +534,7 @@ declare namespace FAXCOMEXLib {
|
||||
}
|
||||
|
||||
/** FaxDeviceIds Class */
|
||||
class FaxDeviceIds {
|
||||
private 'FAXCOMEXLib.FaxDeviceIds_typekey': FaxDeviceIds;
|
||||
private constructor();
|
||||
|
||||
interface FaxDeviceIds {
|
||||
/** Add a device */
|
||||
Add(lDeviceId: number): void;
|
||||
readonly Count: number;
|
||||
@@ -549,6 +545,7 @@ declare namespace FAXCOMEXLib {
|
||||
|
||||
/** Set order of the device */
|
||||
SetOrder(lDeviceId: number, lNewOrder: number): void;
|
||||
(lIndex: number): number;
|
||||
}
|
||||
|
||||
/** FaxDeviceProvider Class */
|
||||
@@ -594,22 +591,20 @@ declare namespace FAXCOMEXLib {
|
||||
}
|
||||
|
||||
/** FaxDeviceProviders Class */
|
||||
class FaxDeviceProviders {
|
||||
private 'FAXCOMEXLib.FaxDeviceProviders_typekey': FaxDeviceProviders;
|
||||
private constructor();
|
||||
interface FaxDeviceProviders {
|
||||
readonly Count: number;
|
||||
Item(vIndex: any): FaxDeviceProvider;
|
||||
(vIndex: any): FaxDeviceProvider;
|
||||
}
|
||||
|
||||
/** FaxDevices Class */
|
||||
class FaxDevices {
|
||||
private 'FAXCOMEXLib.FaxDevices_typekey': FaxDevices;
|
||||
private constructor();
|
||||
interface FaxDevices {
|
||||
readonly Count: number;
|
||||
Item(vIndex: any): FaxDevice;
|
||||
|
||||
/** Get device by its ID */
|
||||
ItemById(lId: number): FaxDevice;
|
||||
(vIndex: any): FaxDevice;
|
||||
}
|
||||
|
||||
/** FaxDocument Class */
|
||||
@@ -630,10 +625,10 @@ declare namespace FAXCOMEXLib {
|
||||
CallHandle: number;
|
||||
|
||||
/** Submit the fax document on the already connected server */
|
||||
ConnectedSubmit(pFaxServer: IFaxServer): any;
|
||||
ConnectedSubmit(pFaxServer: IFaxServer): SafeArray<string>;
|
||||
|
||||
/** Submit the fax document on the already connected server */
|
||||
ConnectedSubmit2(pFaxServer: IFaxServer, pvFaxOutgoingJobIDs: any): number;
|
||||
ConnectedSubmit2(pFaxServer: IFaxServer, pvFaxOutgoingJobIDs: SafeArray<string>): number;
|
||||
|
||||
/** Cover page file path */
|
||||
CoverPage: string;
|
||||
@@ -765,7 +760,7 @@ declare namespace FAXCOMEXLib {
|
||||
readonly MajorVersion: number;
|
||||
|
||||
/** Array of methods exposed by extension */
|
||||
readonly Methods: any;
|
||||
readonly Methods: SafeArray<string>;
|
||||
|
||||
/** The minor part of extension's build number */
|
||||
readonly MinorBuild: number;
|
||||
@@ -781,11 +776,10 @@ declare namespace FAXCOMEXLib {
|
||||
}
|
||||
|
||||
/** FaxInboundRoutingExtensions Class */
|
||||
class FaxInboundRoutingExtensions {
|
||||
private 'FAXCOMEXLib.FaxInboundRoutingExtensions_typekey': FaxInboundRoutingExtensions;
|
||||
private constructor();
|
||||
interface FaxInboundRoutingExtensions {
|
||||
readonly Count: number;
|
||||
Item(vIndex: any): FaxInboundRoutingExtension;
|
||||
(vIndex: any): FaxInboundRoutingExtension;
|
||||
}
|
||||
|
||||
/** FaxInboundRoutingMethod Class */
|
||||
@@ -819,11 +813,10 @@ declare namespace FAXCOMEXLib {
|
||||
}
|
||||
|
||||
/** FaxInboundRoutingMethods Class */
|
||||
class FaxInboundRoutingMethods {
|
||||
private 'FAXCOMEXLib.FaxInboundRoutingMethods_typekey': FaxInboundRoutingMethods;
|
||||
private constructor();
|
||||
interface FaxInboundRoutingMethods {
|
||||
readonly Count: number;
|
||||
Item(vIndex: any): FaxInboundRoutingMethod;
|
||||
(vIndex: any): FaxInboundRoutingMethod;
|
||||
}
|
||||
|
||||
/** FaxIncomingArchive Class */
|
||||
@@ -935,11 +928,10 @@ declare namespace FAXCOMEXLib {
|
||||
}
|
||||
|
||||
/** FaxIncomingJobs Class */
|
||||
class FaxIncomingJobs {
|
||||
private 'FAXCOMEXLib.FaxIncomingJobs_typekey': FaxIncomingJobs;
|
||||
private constructor();
|
||||
interface FaxIncomingJobs {
|
||||
readonly Count: number;
|
||||
Item(vIndex: any): FaxIncomingJob;
|
||||
(vIndex: any): FaxIncomingJob;
|
||||
}
|
||||
|
||||
/** FaxIncomingMessage Class */
|
||||
@@ -1117,10 +1109,7 @@ declare namespace FAXCOMEXLib {
|
||||
}
|
||||
|
||||
/** FaxOutboundRoutingGroups Class */
|
||||
class FaxOutboundRoutingGroups {
|
||||
private 'FAXCOMEXLib.FaxOutboundRoutingGroups_typekey': FaxOutboundRoutingGroups;
|
||||
private constructor();
|
||||
|
||||
interface FaxOutboundRoutingGroups {
|
||||
/** Add a group */
|
||||
Add(bstrName: string): FaxOutboundRoutingGroup;
|
||||
readonly Count: number;
|
||||
@@ -1128,6 +1117,7 @@ declare namespace FAXCOMEXLib {
|
||||
|
||||
/** Remove a group */
|
||||
Remove(vIndex: number | string): void;
|
||||
(vIndex: number | string): FaxOutboundRoutingGroup;
|
||||
}
|
||||
|
||||
/** FaxOutboundRoutingRule Class */
|
||||
@@ -1161,10 +1151,7 @@ declare namespace FAXCOMEXLib {
|
||||
}
|
||||
|
||||
/** FaxOutboundRoutingRules Class */
|
||||
class FaxOutboundRoutingRules {
|
||||
private 'FAXCOMEXLib.FaxOutboundRoutingRules_typekey': FaxOutboundRoutingRules;
|
||||
private constructor();
|
||||
|
||||
interface FaxOutboundRoutingRules {
|
||||
/** Add a rule */
|
||||
Add(lCountryCode: number, lAreaCode: number, bUseDevice: boolean, bstrGroupName: string, lDeviceId: number): FaxOutboundRoutingRule;
|
||||
readonly Count: number;
|
||||
@@ -1178,6 +1165,7 @@ declare namespace FAXCOMEXLib {
|
||||
|
||||
/** Remove a rule by criteria */
|
||||
RemoveByCountryAndArea(lCountryCode: number, lAreaCode: number): void;
|
||||
(lIndex: number): FaxOutboundRoutingRule;
|
||||
}
|
||||
|
||||
/** FaxOutgoingArchive Class */
|
||||
@@ -1334,11 +1322,10 @@ declare namespace FAXCOMEXLib {
|
||||
}
|
||||
|
||||
/** FaxOutgoingJobs Class */
|
||||
class FaxOutgoingJobs {
|
||||
private 'FAXCOMEXLib.FaxOutgoingJobs_typekey': FaxOutgoingJobs;
|
||||
private constructor();
|
||||
interface FaxOutgoingJobs {
|
||||
readonly Count: number;
|
||||
Item(vIndex: any): IFaxOutgoingJob;
|
||||
(vIndex: any): IFaxOutgoingJob;
|
||||
}
|
||||
|
||||
/** FaxOutgoingMessage Class */
|
||||
@@ -1486,10 +1473,7 @@ declare namespace FAXCOMEXLib {
|
||||
}
|
||||
|
||||
/** FaxRecipients Class */
|
||||
class FaxRecipients {
|
||||
private 'FAXCOMEXLib.FaxRecipients_typekey': FaxRecipients;
|
||||
private constructor();
|
||||
|
||||
interface FaxRecipients {
|
||||
/**
|
||||
* Add a recipient
|
||||
* @param string [bstrRecipientName='']
|
||||
@@ -1500,6 +1484,7 @@ declare namespace FAXCOMEXLib {
|
||||
|
||||
/** Remove a recipient */
|
||||
Remove(lIndex: number): void;
|
||||
(lIndex: number): FaxRecipient;
|
||||
}
|
||||
|
||||
/** FaxSecurity Class */
|
||||
@@ -2033,21 +2018,3 @@ interface ActiveXObjectNameMap {
|
||||
'FaxComEx.FaxDocument': FAXCOMEXLib.FaxDocument;
|
||||
'FaxComEx.FaxServer': FAXCOMEXLib.FaxServer;
|
||||
}
|
||||
|
||||
interface EnumeratorConstructor {
|
||||
new(col: FAXCOMEXLib.FaxAccounts): Enumerator<FAXCOMEXLib.FaxAccount>;
|
||||
new(col: FAXCOMEXLib.FaxDeviceIds): Enumerator<number>;
|
||||
new(col: FAXCOMEXLib.FaxDeviceProviders): Enumerator<FAXCOMEXLib.FaxDeviceProvider>;
|
||||
new(col: FAXCOMEXLib.FaxDevices): Enumerator<FAXCOMEXLib.FaxDevice>;
|
||||
new(col: FAXCOMEXLib.FaxInboundRoutingExtensions): Enumerator<FAXCOMEXLib.FaxInboundRoutingExtension>;
|
||||
new(col: FAXCOMEXLib.FaxInboundRoutingMethods): Enumerator<FAXCOMEXLib.FaxInboundRoutingMethod>;
|
||||
new(col: FAXCOMEXLib.FaxIncomingJobs): Enumerator<FAXCOMEXLib.FaxIncomingJob>;
|
||||
new(col: FAXCOMEXLib.FaxOutboundRoutingGroups): Enumerator<FAXCOMEXLib.FaxOutboundRoutingGroup>;
|
||||
new(col: FAXCOMEXLib.FaxOutboundRoutingRules): Enumerator<FAXCOMEXLib.FaxOutboundRoutingRule>;
|
||||
new(col: FAXCOMEXLib.FaxOutgoingJobs): Enumerator<FAXCOMEXLib.IFaxOutgoingJob>;
|
||||
new(col: FAXCOMEXLib.FaxRecipients): Enumerator<FAXCOMEXLib.FaxRecipient>;
|
||||
}
|
||||
|
||||
interface SafeArray<T = any> {
|
||||
_brand: SafeArray<T>;
|
||||
}
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": ["es5", "scripthost"],
|
||||
"lib": [
|
||||
"es5",
|
||||
"scripthost"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
|
||||
@@ -4,11 +4,11 @@ const wshn = new ActiveXObject('WScript.Network');
|
||||
// https://msdn.microsoft.com/en-us/library/wck0hkd7(v=vs.84).aspx
|
||||
// https://msdn.microsoft.com/en-us/library/tte130y1(v=vs.84).aspx
|
||||
// https://msdn.microsoft.com/en-us/library/3fxhka75(v=vs.84).aspx
|
||||
(() => {
|
||||
{
|
||||
WScript.Echo('Domain = ' + wshn.UserDomain);
|
||||
WScript.Echo('Computer Name = ' + wshn.ComputerName);
|
||||
WScript.Echo('User Name = ' + wshn.UserName);
|
||||
})();
|
||||
}
|
||||
|
||||
// https://msdn.microsoft.com/en-us/library/zsdh7hkb(v=vs.84).aspx
|
||||
wshn.AddWindowsPrinterConnection('\\\\printserv\\DefaultPrinter');
|
||||
@@ -18,7 +18,7 @@ wshn.AddPrinterConnection("LPT1", "\\\\Server\\Print1");
|
||||
|
||||
// https://msdn.microsoft.com/en-us/library/t9zt39at(v=vs.84).aspx
|
||||
// https://msdn.microsoft.com/en-us/library/zhds6k80(v=vs.84).aspx
|
||||
(() => {
|
||||
{
|
||||
const drives = wshn.EnumNetworkDrives();
|
||||
const printers = wshn.EnumPrinterConnections();
|
||||
WScript.Echo("Network drive mappings:");
|
||||
@@ -30,7 +30,7 @@ wshn.AddPrinterConnection("LPT1", "\\\\Server\\Print1");
|
||||
for (let i = 0; i < printers.length; i += 2) {
|
||||
WScript.Echo(`Port ${printers.Item(i)} = ${printers.Item(i + 1)}`);
|
||||
}
|
||||
})();
|
||||
}
|
||||
|
||||
// https://msdn.microsoft.com/en-us/library/8kst88h6(v=vs.84).aspx
|
||||
wshn.MapNetworkDrive('E:', '\\\\Server\\Public');
|
||||
@@ -42,8 +42,8 @@ wshn.RemoveNetworkDrive('E:');
|
||||
wshn.RemovePrinterConnection('\\\\PRN-CORP1\\B41-4523-A', true, true);
|
||||
|
||||
// https://msdn.microsoft.com/en-us/library/2ccwwdct(v=vs.84).aspx
|
||||
(() => {
|
||||
{
|
||||
const printerPath = "\\\\research\\library1";
|
||||
wshn.AddWindowsPrinterConnection(printerPath);
|
||||
wshn.SetDefaultPrinter(printerPath);
|
||||
})();
|
||||
}
|
||||
|
||||
+125
-24
@@ -5,6 +5,9 @@
|
||||
// TypeScript Version: 2.6
|
||||
|
||||
declare namespace IWshRuntimeLibrary {
|
||||
type WindowStyle = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10;
|
||||
type ShortcutWindowStyle = 1 | 3 | 7;
|
||||
|
||||
// tslint:disable-next-line no-const-enum
|
||||
const enum ButtonType {
|
||||
OK,
|
||||
@@ -16,6 +19,16 @@ declare namespace IWshRuntimeLibrary {
|
||||
CancelTryagainContinue
|
||||
}
|
||||
|
||||
// tslint:disable-next-line no-const-enum
|
||||
const enum EventType {
|
||||
AuditFailure = 5,
|
||||
AuditSuccess = 4,
|
||||
Error = 1,
|
||||
Information = 3,
|
||||
Success = 0,
|
||||
Warning = 2
|
||||
}
|
||||
|
||||
// tslint:disable-next-line no-const-enum
|
||||
const enum IconType {
|
||||
Stop = 16,
|
||||
@@ -85,22 +98,20 @@ declare namespace IWshRuntimeLibrary {
|
||||
}
|
||||
|
||||
/** Generic Collection Object */
|
||||
class WshCollection {
|
||||
private 'IWshRuntimeLibrary.WshCollection_typekey': WshCollection;
|
||||
private constructor();
|
||||
interface WshCollection {
|
||||
Count(): number;
|
||||
Item(Index: any): any;
|
||||
readonly length: number;
|
||||
(Index: any): any;
|
||||
}
|
||||
|
||||
/** Environment Variables Collection Object */
|
||||
class WshEnvironment {
|
||||
private 'IWshRuntimeLibrary.WshEnvironment_typekey': WshEnvironment;
|
||||
private constructor();
|
||||
interface WshEnvironment {
|
||||
Count(): number;
|
||||
Item(Name: string): string;
|
||||
readonly length: number;
|
||||
Remove(Name: string): void;
|
||||
(Name: string): string;
|
||||
}
|
||||
|
||||
/** WSHExec object */
|
||||
@@ -161,7 +172,7 @@ declare namespace IWshRuntimeLibrary {
|
||||
* @param Force [false] Remove the connections even if the resource is in use
|
||||
* @param UpdateProfile [false] Remove the mapping from the user's profile
|
||||
*/
|
||||
RemoveNetworkDrive(Name: string, Force?: any, UpdateProfile?: any): void;
|
||||
RemoveNetworkDrive(Name: string, Force?: boolean, UpdateProfile?: boolean): void;
|
||||
|
||||
/**
|
||||
* Removes a shared network printer connection from your computer system
|
||||
@@ -173,7 +184,7 @@ declare namespace IWshRuntimeLibrary {
|
||||
* _Name_ must be the printer's local name. If the printer was connected using the **AddWindowsPrinterConnection** method or was added manually (using the Add Printer wizard),
|
||||
* then _Name_ must be the printer's UNC name.
|
||||
*/
|
||||
RemovePrinterConnection(Name: string, Force?: any, UpdateProfile?: any): void;
|
||||
RemovePrinterConnection(Name: string, Force?: true, UpdateProfile?: true): void;
|
||||
SetDefaultPrinter(Name: string): void;
|
||||
readonly Site: string;
|
||||
readonly UserDomain: string;
|
||||
@@ -185,21 +196,107 @@ declare namespace IWshRuntimeLibrary {
|
||||
class WshShell {
|
||||
private 'IWshRuntimeLibrary.WshShell_typekey': WshShell;
|
||||
private constructor();
|
||||
AppActivate(App: any, Wait?: any): boolean;
|
||||
CreateShortcut(PathLink: string): any;
|
||||
|
||||
/**
|
||||
* Activates an application window
|
||||
* @param App Title of application as it appears in the title bar, or the process ID
|
||||
* @param Wait
|
||||
*
|
||||
* This method changes the focus to the named application or window. The window must be attached to the calling thread's message queue. It does not affect whether it is maximized or
|
||||
* minimized. Focus moves from the activated application window when the user takes action to change the focus (or closes the window).
|
||||
*
|
||||
* In determining which application to activate, the specified title is compared to the title string of each running application. If no exact match exists, any application whose title
|
||||
* string begins with title is activated. If an application still cannot be found, any application whose title string ends with title is activated. If more than one instance of the
|
||||
* application named by title exists, one instance is arbitrarily activated.
|
||||
*
|
||||
* The method might return `false` under the following conditions:
|
||||
*
|
||||
* * The window is not brought to the foreground.
|
||||
* * The window is brought to the foreground but is not given keyboard focus.
|
||||
* * A Command Prompt window (`cmd.exe`) is brought to the foreground and is given keyboard focus.
|
||||
*/
|
||||
AppActivate(App: string | number, Wait?: any): boolean;
|
||||
|
||||
/**
|
||||
* Creates a shortcut
|
||||
* @param PathLink Path where the shortcut should be created
|
||||
*
|
||||
* The shortcut object exists in memory until you save it to disk with the **Save** method.
|
||||
*/
|
||||
CreateShortcut(PathLink: string): WshShortcut | WshURLShortcut;
|
||||
CurrentDirectory: string;
|
||||
Environment(Type?: any): WshEnvironment;
|
||||
|
||||
/**
|
||||
* Note that **Environment** doesn't actually return a callable object; the call is only usable in the context of the **Environment** property. The following:
|
||||
*
|
||||
* let env = new ActiveXObject('WScript.Shell').Environment;
|
||||
* WScript.Echo(env('System'));
|
||||
*
|
||||
* will return an empty string, unless there is an environment variable named `System`
|
||||
*/
|
||||
Environment: WshEnvironment & ((Type: 'System' | 'User' | 'Process' | 'Volatile') => WshEnvironment);
|
||||
Exec(Command: string): WshExec;
|
||||
ExpandEnvironmentStrings(Src: string): string;
|
||||
|
||||
/** @param string [Target=''] */
|
||||
LogEvent(Type: any, Message: string, Target?: string): boolean;
|
||||
Popup(Text: any, SecondsToWait?: number, Title?: string, Type?: ButtonType | IconType | PopupType): PopupSelection;
|
||||
/** @param string [Target=''] Name of the computer system where the event should be logged; default is the local computer system */
|
||||
LogEvent(Type: EventType, Message: string, Target?: string): boolean;
|
||||
Popup(Text: string, SecondsToWait?: number, Title?: string, Type?: ButtonType | IconType | PopupType): PopupSelection;
|
||||
RegDelete(Name: string): void;
|
||||
RegRead(Name: string): any;
|
||||
RegWrite(Name: string, Value: any, Type?: any): void;
|
||||
Run(Command: string, WindowStyle?: any, WaitOnReturn?: any): number;
|
||||
SendKeys(Keys: string, Wait?: any): void;
|
||||
|
||||
/**
|
||||
* Returns the value of a key or value-name from the registry
|
||||
* @param Name Key (ends with a final `\`) or value-name (doesn't end with a final `\`)
|
||||
*
|
||||
* Returns one of the following, based on the registry value type:
|
||||
*
|
||||
* * **REG_SZ** -- a string
|
||||
* * **REG_DWORD** -- a number
|
||||
* * **REG_SBINARY** -- a binary value, as a COM SafeArray containing integers
|
||||
* * **REG_EXPAND_SZ** -- an expandable string
|
||||
* * **REG_MULTI_SZ** -- an array of srings, as a COM SafeArray
|
||||
*/
|
||||
RegRead(Name: string): string | number | SafeArray<string> | SafeArray<number>;
|
||||
|
||||
/**
|
||||
* Creates a new key, adds another value-name to an existing key and assigns it a value, or changes the value of an existing value-name
|
||||
* @param Name Key (ends with a final `\`) or value-name (doesn't end with a final `\`)
|
||||
* @param Value Will be coerced to `string` or `integer` based on the value-name type:
|
||||
* `REG_SZ | REG_EXPAND_SZ` will be converted to `string`;
|
||||
* `REG_DWORD | REG_BINARY` will be converted to `integer`
|
||||
* @param Type
|
||||
*/
|
||||
RegWrite(Name: string, Value: any, Type?: 'REG_SZ' | 'REG_DWORD' | 'REG_BINARY' | 'REG_EXPAND_SZ'): void;
|
||||
|
||||
/**
|
||||
* Runs a program in a new process.
|
||||
* @param Command Command-line, including any parameters you want to pass to the executable file.
|
||||
* @param WindowStyle Appearance of the program window. Not all programs make use of this information.
|
||||
* @param WaitOnReturn Block script until program finishes executing.
|
||||
*
|
||||
* If `false` is passed into **WaitOnReturn**, the **Run** method will return 0 immediately. If `true` is passed in, **Run** will return the program's error code, if any.
|
||||
*
|
||||
* Environment variables will be expanded within the command line.
|
||||
*
|
||||
* Passing a registered file type will automatically open the program registered to the file type.
|
||||
*
|
||||
* Possible values for **WindowStyle**:
|
||||
*
|
||||
* * **0** -- Hides the window and activates another window.
|
||||
* * **1** -- Activates and displays a window. If the window is minimized or maximized, the system restores it to its original size and position. An application should specify this flag
|
||||
* when displaying the window for the first time.
|
||||
* * **2** -- Activates the window and displays it as a minimized window.
|
||||
* * **3** -- Activates the window and displays it as a maximized window.
|
||||
* * **4** -- Displays a window in its most recent size and position. The active window remains active.
|
||||
* * **5** -- Activates the window and displays it in its current size and position.
|
||||
* * **6** -- Minimizes the specified window and activates the next top-level window in the Z order.
|
||||
* * **7** -- Displays the window as a minimized window. The active window remains active.
|
||||
* * **8** -- Displays the window in its current state. The active window remains active.
|
||||
* * **9** -- Activates and displays the window. If the window is minimized or maximized, the system restores it to its original size and position. An application should specify this flag
|
||||
* when restoring a minimized window.
|
||||
* * **10** -- Sets the show-state based on the state of the program that started the application.
|
||||
*/
|
||||
Run(Command: string, WindowStyle?: WindowStyle, WaitOnReturn?: boolean): number;
|
||||
SendKeys(Keys: string, Wait?: boolean): void;
|
||||
readonly SpecialFolders: WshCollection;
|
||||
}
|
||||
|
||||
@@ -216,7 +313,16 @@ declare namespace IWshRuntimeLibrary {
|
||||
readonly RelativePath: string;
|
||||
Save(): void;
|
||||
TargetPath: string;
|
||||
WindowStyle: number;
|
||||
|
||||
/**
|
||||
* Possible values:
|
||||
*
|
||||
* * **1** -- Activates and displays a window. If the window is minimized or maximized, the system restores it to its original size and position. An application should specify this flag
|
||||
* when displaying the window for the first time.
|
||||
* * **3** -- Activates the window and displays it as a maximized window.
|
||||
* * **7** -- Displays the window as a minimized window. The active window remains active.
|
||||
*/
|
||||
WindowStyle: ShortcutWindowStyle;
|
||||
WorkingDirectory: string;
|
||||
}
|
||||
|
||||
@@ -240,8 +346,3 @@ interface ActiveXObjectNameMap {
|
||||
'WScript.Network': IWshRuntimeLibrary.WshNetwork;
|
||||
'WScript.Shell': IWshRuntimeLibrary.WshShell;
|
||||
}
|
||||
|
||||
interface EnumeratorConstructor {
|
||||
new(col: IWshRuntimeLibrary.WshCollection): Enumerator;
|
||||
new(col: IWshRuntimeLibrary.WshEnvironment): Enumerator<string>;
|
||||
}
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": ["es5", "scripthost"],
|
||||
"lib": [
|
||||
"es5",
|
||||
"scripthost"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
|
||||
@@ -1,60 +1,324 @@
|
||||
// source -- https://msdn.microsoft.com/en-us/library/ebkhfaaz.aspx
|
||||
// Note -- running these tests under cscript requires some ES5 polyfills
|
||||
|
||||
// Generates a string describing the drive type of a given Drive object.
|
||||
function showDriveType(drive: Scripting.Drive) {
|
||||
switch (drive.DriveType) {
|
||||
case Scripting.DriveTypeConst.Removable:
|
||||
return 'Removeable';
|
||||
case Scripting.DriveTypeConst.Fixed:
|
||||
return 'Fixecd';
|
||||
case Scripting.DriveTypeConst.Remote:
|
||||
return 'Network';
|
||||
case Scripting.DriveTypeConst.CDRom:
|
||||
return 'CD-ROM';
|
||||
case Scripting.DriveTypeConst.RamDisk:
|
||||
return 'RAM Disk';
|
||||
default:
|
||||
return 'Unknown';
|
||||
const collectionToArray = <T>(col: { Item(key: any): T }): T[] => {
|
||||
const results: T[] = [];
|
||||
const enumerator = new Enumerator<T>(col);
|
||||
enumerator.moveFirst();
|
||||
while (!enumerator.atEnd()) {
|
||||
results.push(enumerator.item());
|
||||
enumerator.moveNext();
|
||||
}
|
||||
}
|
||||
return results;
|
||||
};
|
||||
|
||||
// Generates a string describing the attributes of a file or folder.
|
||||
function showFileAttributes(file: Scripting.File) {
|
||||
const attr = file.Attributes;
|
||||
if (attr === 0) {
|
||||
return 'Normal';
|
||||
const fso = new ActiveXObject('Scripting.FileSystemObject');
|
||||
|
||||
// https://msdn.microsoft.com/en-us/library/ebkhfaaz(v=vs.84).aspx
|
||||
{
|
||||
/** Generates a string describing the drive type of a given Drive object. */
|
||||
const driveTypeString = (drive: Scripting.Drive) => {
|
||||
switch (drive.DriveType) {
|
||||
case Scripting.DriveTypeConst.Removable:
|
||||
return 'Removeable';
|
||||
case Scripting.DriveTypeConst.Fixed:
|
||||
return 'Fixecd';
|
||||
case Scripting.DriveTypeConst.Remote:
|
||||
return 'Network';
|
||||
case Scripting.DriveTypeConst.CDRom:
|
||||
return 'CD-ROM';
|
||||
case Scripting.DriveTypeConst.RamDisk:
|
||||
return 'RAM Disk';
|
||||
default:
|
||||
return 'Unknown';
|
||||
}
|
||||
};
|
||||
|
||||
/** Generates a string describing the attributes of a file or folder. */
|
||||
const attributesString = (f: Scripting.File | Scripting.Folder) => {
|
||||
const attr = f.Attributes;
|
||||
if (attr === 0) {
|
||||
return 'Normal';
|
||||
}
|
||||
const attributeStrings: string[] = [];
|
||||
if (attr & Scripting.FileAttribute.Directory) { attributeStrings.push('Directory'); }
|
||||
if (attr & Scripting.FileAttribute.ReadOnly) { attributeStrings.push('Read-only'); }
|
||||
if (attr & Scripting.FileAttribute.Hidden) { attributeStrings.push('Hidden'); }
|
||||
if (attr & Scripting.FileAttribute.System) { attributeStrings.push('System'); }
|
||||
if (attr & Scripting.FileAttribute.Volume) { attributeStrings.push('Volume'); }
|
||||
if (attr & Scripting.FileAttribute.Archive) { attributeStrings.push('Archive'); }
|
||||
if (attr & Scripting.FileAttribute.Alias) { attributeStrings.push('Alias'); }
|
||||
if (attr & Scripting.FileAttribute.Compressed) { attributeStrings.push('Compressed'); }
|
||||
return attributeStrings.join(',');
|
||||
};
|
||||
|
||||
const drivesInfoReport = () => {
|
||||
const driveLine = (d: Scripting.Drive) => {
|
||||
let parts: Array<string | number> = [
|
||||
d.DriveLetter,
|
||||
d.Path,
|
||||
driveTypeString(d),
|
||||
d.IsReady ? 'true' : 'false'
|
||||
];
|
||||
if (d.IsReady) {
|
||||
parts = parts.concat([
|
||||
d.DriveType === Scripting.DriveTypeConst.Remote ? d.ShareName : d.VolumeName,
|
||||
d.FileSystem,
|
||||
d.TotalSize,
|
||||
d.FreeSpace,
|
||||
d.AvailableSpace,
|
||||
d.SerialNumber.toString(16)
|
||||
]);
|
||||
}
|
||||
return parts.join(' ');
|
||||
};
|
||||
|
||||
const ret = `
|
||||
Number of drives: ${fso.Drives.Count}
|
||||
|
||||
Drive File Total Free Available Serial
|
||||
Letter Path Type Ready? Name System Space Space Space Number
|
||||
${new Array(106).join('-')}
|
||||
${collectionToArray(fso.Drives).map(driveLine).join('\n')}`
|
||||
.trim().replace(' ', '\t');
|
||||
};
|
||||
|
||||
type fiileFolderKey = keyof Scripting.File & keyof Scripting.Folder;
|
||||
type keys = fiileFolderKey | 'Attribs' | 'Created' | 'Accessed' | 'Modified';
|
||||
const detailBuilder = (f: Scripting.File | Scripting.Folder, x: fiileFolderKey | 'Attribs' | 'Created' | 'Accessed' | 'Modified') => {
|
||||
if (x === 'Attribs') { return attributesString(f); }
|
||||
const label = x;
|
||||
switch (x) {
|
||||
case 'Created':
|
||||
x = 'DateCreated';
|
||||
break;
|
||||
case 'Accessed':
|
||||
x = 'DateLastAccessed';
|
||||
break;
|
||||
case 'Modified':
|
||||
x = 'DateLastModified';
|
||||
break;
|
||||
}
|
||||
return `${label}\t${f[x]}\n`;
|
||||
};
|
||||
|
||||
const fileDetailsString = (f: Scripting.File) => {
|
||||
const keys: keys[] = ['Path', 'Name', 'Type', 'Attribs', 'Created', 'Accessed', 'Modified', 'Size'];
|
||||
return keys.map(x => detailBuilder(f, x)).join('');
|
||||
};
|
||||
|
||||
const folderDetailsString = (f: Scripting.Folder) => {
|
||||
const keys: keys[] = ['Path', 'Name', 'Attribs', 'Created', 'Accessed', 'Modified', 'Size'];
|
||||
return keys.map(x => detailBuilder(f, x)).join('');
|
||||
};
|
||||
|
||||
const folderContentsString = (f: Scripting.Folder): string => {
|
||||
const files = collectionToArray(f.Files);
|
||||
const subfolders = collectionToArray(f.SubFolders);
|
||||
return `
|
||||
Folder: ${f.Path}
|
||||
|
||||
There ${files.length === 1 ? 'is 1 file' : `are ${files.length} files`}
|
||||
${files.map(fileDetailsString).join('')}
|
||||
|
||||
There ${subfolders.length === 1 ? 'is 1 subfolder' : `are ${subfolders.length} subfolders`}
|
||||
${subfolders.map(folderDetailsString).join('')}
|
||||
${subfolders.map(folderContentsString).join('')}`
|
||||
.trim().replace(' ', '\t');
|
||||
};
|
||||
|
||||
const testDrive = 'C:\\';
|
||||
const testPath = 'C:\\test';
|
||||
const testfolderInfo = () => {
|
||||
if (!fso.DriveExists(testDrive) || !fso.FolderExists(testPath)) { return ''; }
|
||||
return folderContentsString(fso.GetFolder(testPath));
|
||||
};
|
||||
|
||||
const deleteTestFolder = () => {
|
||||
// two ways to delete a file:
|
||||
const filepathToDelete = `${testPath}\\LoremIpsum\\Paragraph1.txt`;
|
||||
fso.DeleteFile(filepathToDelete);
|
||||
// fso.GetFile(filepathToDelete).Delete();
|
||||
|
||||
// two ways to delete a folder:
|
||||
fso.DeleteFolder(`${testPath}\\LoremIpsum`);
|
||||
fso.GetFolder(testPath).Delete();
|
||||
};
|
||||
|
||||
const createLyrics = (folder: Scripting.Folder) => {
|
||||
let stream = folder.CreateTextFile('Paragraph1.txt');
|
||||
stream.Write('Lorem Ipsum - Paragraph 1');
|
||||
stream.WriteBlankLines(1);
|
||||
stream.WriteLine('Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Maecenas sem.');
|
||||
stream.WriteLine('Donec ante. Nulla facilisi. Phasellus interdum nulla a nunc. Morbi laoreet nunc.');
|
||||
stream.WriteBlankLines(2);
|
||||
stream.Close();
|
||||
|
||||
stream = folder.CreateTextFile('Paragraph2.txt');
|
||||
stream.WriteLine('Lorem Ipsum - Paragraph 2');
|
||||
stream.WriteBlankLines(1);
|
||||
stream.WriteLine('Nullam nulla quam, sollicitudin ut, lobortis ornare, tristique a, augue.');
|
||||
stream.WriteLine('Vestibulum sem felis, fermentum eu, volutpat eu, vulputate eget, elit. ');
|
||||
stream.WriteBlankLines(2);
|
||||
stream.Close();
|
||||
};
|
||||
|
||||
const getLyrics = () => {
|
||||
const folderPath = `${testPath}\\LoremIpsum`;
|
||||
let lyrics = '';
|
||||
|
||||
// One way to read from a file
|
||||
let stream = fso.OpenTextFile(fso.BuildPath(folderPath, 'Paragraph1.txt'));
|
||||
lyrics = stream.ReadAll() + '\n\n';
|
||||
stream.Close();
|
||||
|
||||
// Another way to read from a file
|
||||
stream = fso.GetFile(fso.BuildPath(folderPath, 'Paragraph2.txt')).OpenAsTextStream();
|
||||
while (!stream.AtEndOfStream) {
|
||||
lyrics += stream.ReadLine() + '\n';
|
||||
}
|
||||
stream.Close();
|
||||
|
||||
return lyrics;
|
||||
};
|
||||
|
||||
const buildTestFolder = () => {
|
||||
// Bail out if the drive doesn't exists ...
|
||||
if (!fso.DriveExists(testDrive)) { return false; }
|
||||
// or the directory already exists
|
||||
if (fso.FolderExists(testPath)) { return false; }
|
||||
|
||||
const testFolder = fso.CreateFolder(testPath);
|
||||
|
||||
const stream = fso.CreateTextFile(fso.BuildPath(testPath, 'readme.txt'));
|
||||
stream.WriteLine('My sample text collection');
|
||||
stream.Close();
|
||||
|
||||
const subfolder = testFolder.SubFolders.Add('LoremIpsum');
|
||||
createLyrics(subfolder);
|
||||
return true;
|
||||
};
|
||||
|
||||
const echoLines = (linecount = 1) => new Array(linecount).forEach(() => WScript.Echo(''));
|
||||
|
||||
if (!buildTestFolder()) {
|
||||
WScript.Echo('Test directory already exists or cannot be created. Cannot continue.');
|
||||
} else {
|
||||
drivesInfoReport();
|
||||
echoLines(2);
|
||||
WScript.Echo(testfolderInfo());
|
||||
echoLines(2);
|
||||
WScript.Echo(getLyrics());
|
||||
echoLines(2);
|
||||
deleteTestFolder();
|
||||
}
|
||||
const attributeStrings: string[] = [];
|
||||
if (attr & Scripting.FileAttribute.Directory) { attributeStrings.push('Directory'); }
|
||||
if (attr & Scripting.FileAttribute.ReadOnly) { attributeStrings.push('Read-only'); }
|
||||
if (attr & Scripting.FileAttribute.Hidden) { attributeStrings.push('Hidden'); }
|
||||
if (attr & Scripting.FileAttribute.System) { attributeStrings.push('System'); }
|
||||
if (attr & Scripting.FileAttribute.Volume) { attributeStrings.push('Volume'); }
|
||||
if (attr & Scripting.FileAttribute.Archive) { attributeStrings.push('Archive'); }
|
||||
if (attr & Scripting.FileAttribute.Alias) { attributeStrings.push('Alias'); }
|
||||
if (attr & Scripting.FileAttribute.Compressed) { attributeStrings.push('Compressed'); }
|
||||
return attributeStrings.join(',');
|
||||
}
|
||||
|
||||
// source --https://msdn.microsoft.com/en-us/library/ts2t8ybh(v=vs.84).aspx
|
||||
function showFreeSpace(drvPath: string) {
|
||||
const fso = new ActiveXObject('Scripting.FileSystemObject');
|
||||
const d = fso.GetDrive(fso.GetDriveName(drvPath));
|
||||
let s = `Drive ${drvPath} - `;
|
||||
s += d.VolumeName + '<br>';
|
||||
s += `Free Space: ${d.FreeSpace / 1024} Kbytes`;
|
||||
return (s);
|
||||
{
|
||||
const showFreeSpace = (drvPath: string) => {
|
||||
const d = fso.GetDrive(fso.GetDriveName(drvPath));
|
||||
let s = `Drive ${drvPath} - `;
|
||||
s += d.VolumeName + '<br>';
|
||||
s += `Free Space: ${d.FreeSpace / 1024} Kbytes`;
|
||||
return (s);
|
||||
};
|
||||
}
|
||||
|
||||
// source -- https://msdn.microsoft.com/en-us/library/kaf6yaft(v=vs.84).aspx
|
||||
function getALine(filespec: string) {
|
||||
const fso = new ActiveXObject('Scripting.FileSystemObject');
|
||||
const file = fso.OpenTextFile(filespec, Scripting.IOMode.ForReading, false);
|
||||
{
|
||||
const getALine = (filespec: string) => {
|
||||
const file = fso.OpenTextFile(filespec, Scripting.IOMode.ForReading, false);
|
||||
|
||||
let s = '';
|
||||
while (!file.AtEndOfLine) {
|
||||
s += file.Read(1);
|
||||
}
|
||||
file.Close();
|
||||
return (s);
|
||||
let s = '';
|
||||
while (!file.AtEndOfLine) {
|
||||
s += file.Read(1);
|
||||
}
|
||||
file.Close();
|
||||
return (s);
|
||||
};
|
||||
}
|
||||
|
||||
// https://msdn.microsoft.com/en-us/library/ch28h2s7(v=vs.84).aspx
|
||||
{
|
||||
const showDriveInfo = (path: string) => {
|
||||
const bytesPerGB = 1024 * 1024 * 1024;
|
||||
const drv = fso.GetDrive(fso.GetDriveName(path));
|
||||
const ret =
|
||||
drv.IsReady ?
|
||||
`${drv.Path} - ${drv.FreeSpace / bytesPerGB} GB free of ${drv.TotalSize / bytesPerGB} GB` :
|
||||
'Not ready';
|
||||
WScript.Echo(ret);
|
||||
};
|
||||
|
||||
const showFolderInfo = () => {
|
||||
const fldr = fso.GetFolder("c:\\");
|
||||
let ret = `
|
||||
Folder: ${fldr.Path}
|
||||
Drive: ${fldr.Drive}
|
||||
${fldr.IsRootFolder ? 'Is root folder' : `Parent folder: ${fldr.ParentFolder}`}
|
||||
`.trim();
|
||||
|
||||
// Create and delete a folder.
|
||||
const newFolderName = 'C:\\TempFolder1';
|
||||
fso.CreateFolder(newFolderName);
|
||||
ret += `Base Name of Added Folder: ${fso.GetBaseName(newFolderName)}`;
|
||||
fso.DeleteFolder(newFolderName);
|
||||
|
||||
WScript.Echo(ret);
|
||||
};
|
||||
}
|
||||
|
||||
// https://msdn.microsoft.com/en-us/library/czxefwt8(v=vs.84).aspx
|
||||
{
|
||||
const readFiles = () => {
|
||||
const file = fso.CreateTextFile("c:\\testfile.txt", true);
|
||||
|
||||
// Write a line.
|
||||
WScript.Echo('Writing file');
|
||||
file.WriteLine("Hello World");
|
||||
file.WriteBlankLines(1);
|
||||
file.Close();
|
||||
|
||||
// Read the contents of the file.
|
||||
WScript.Echo('Reading file');
|
||||
const textStream = fso.OpenTextFile("c:\\testfile.txt", Scripting.IOMode.ForReading);
|
||||
WScript.Echo(`File contents = "${textStream.ReadLine()}"`);
|
||||
textStream.Close();
|
||||
};
|
||||
|
||||
const manipulateFiles = () => {
|
||||
const file = fso.CreateTextFile("c:\\testfile.txt", true);
|
||||
|
||||
WScript.Echo('Writing file');
|
||||
|
||||
// Write a line.
|
||||
file.Write("This is a test.");
|
||||
|
||||
// Close the file to writing.
|
||||
file.Close();
|
||||
|
||||
WScript.Echo('Moving file to c:\\tmp');
|
||||
|
||||
// Get a handle to the file in root of C:\.
|
||||
let file2 = fso.GetFile("c:\\testfile.txt");
|
||||
|
||||
// Move the file to \tmp directory.
|
||||
file2.Move("c:\\tmp\\testfile.txt");
|
||||
|
||||
WScript.Echo('Copying file to c:\\temp <br>');
|
||||
|
||||
// Copy the file to \temp.
|
||||
file2.Copy('c:\\temp\\testfile.txt');
|
||||
|
||||
WScript.Echo('Deleting files <br>');
|
||||
|
||||
// Get handles to files' current location.
|
||||
file2 = fso.GetFile('c:\\tmp\\testfile.txt');
|
||||
const file3 = fso.GetFile('c:\\temp\\testfile.txt');
|
||||
|
||||
// Delete the files.
|
||||
file2.Delete();
|
||||
file3.Delete();
|
||||
WScript.Echo('All done!');
|
||||
};
|
||||
}
|
||||
|
||||
Vendored
+80
-45
@@ -1,24 +1,28 @@
|
||||
// Type definitions for Microsoft Scripting Runtime 1.0
|
||||
// Project: https://msdn.microsoft.com/en-us/library/bstcxhf7.aspx
|
||||
// Project: https://msdn.microsoft.com/en-us/library/bstcxhf7(v=vs.84).aspx
|
||||
// Definitions by: Zev Spitz <https://github.com/zspitz>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.6
|
||||
|
||||
declare namespace Scripting {
|
||||
// tslint:disable-next-line:no-const-enum
|
||||
const enum CompareMethod {
|
||||
BinaryCompare = 0,
|
||||
DatabaseCompare = 2,
|
||||
TextCompare = 1
|
||||
TextCompare = 1,
|
||||
}
|
||||
|
||||
// tslint:disable-next-line:no-const-enum
|
||||
const enum DriveTypeConst {
|
||||
CDRom = 4,
|
||||
Fixed = 2,
|
||||
RamDisk = 5,
|
||||
Remote = 3,
|
||||
Removable = 1,
|
||||
UnknownType = 0
|
||||
UnknownType = 0,
|
||||
}
|
||||
|
||||
// tslint:disable-next-line:no-const-enum
|
||||
const enum FileAttribute {
|
||||
Alias = 1024,
|
||||
Archive = 32,
|
||||
@@ -28,38 +32,42 @@ declare namespace Scripting {
|
||||
Normal = 0,
|
||||
ReadOnly = 1,
|
||||
System = 4,
|
||||
Volume = 8
|
||||
Volume = 8,
|
||||
}
|
||||
|
||||
// tslint:disable-next-line:no-const-enum
|
||||
const enum IOMode {
|
||||
ForAppending = 8,
|
||||
ForReading = 1,
|
||||
ForWriting = 2
|
||||
ForWriting = 2,
|
||||
}
|
||||
|
||||
// tslint:disable-next-line:no-const-enum
|
||||
const enum SpecialFolderConst {
|
||||
SystemFolder = 1,
|
||||
TemporaryFolder = 2,
|
||||
WindowsFolder = 0
|
||||
WindowsFolder = 0,
|
||||
}
|
||||
|
||||
// tslint:disable-next-line:no-const-enum
|
||||
const enum StandardStreamTypes {
|
||||
StdErr = 2,
|
||||
StdIn = 0,
|
||||
StdOut = 1
|
||||
StdOut = 1,
|
||||
}
|
||||
|
||||
// tslint:disable-next-line:no-const-enum
|
||||
const enum Tristate {
|
||||
TristateFalse = 0,
|
||||
TristateMixed = -2,
|
||||
TristateTrue = -1,
|
||||
TristateUseDefault = -2
|
||||
TristateUseDefault = -2,
|
||||
}
|
||||
|
||||
/** Scripting.Dictionary */
|
||||
interface Dictionary {
|
||||
interface Dictionary<TKey = any, TItem = any> {
|
||||
/** Add a new key and item to the dictionary. */
|
||||
Add(Key: any, Item: any): void;
|
||||
Add(Key: TKey, Item: TItem): void;
|
||||
|
||||
/** Set or get the string comparison method. */
|
||||
CompareMode: CompareMethod;
|
||||
@@ -68,32 +76,38 @@ declare namespace Scripting {
|
||||
readonly Count: number;
|
||||
|
||||
/** Determine if a given key is in the dictionary. */
|
||||
Exists(Key: any): boolean;
|
||||
HashVal(Key: any): any;
|
||||
Exists(Key: TKey): boolean;
|
||||
HashVal(Key: TKey): any;
|
||||
|
||||
/** Set or get the item for a given key */
|
||||
Item(Key: any): any;
|
||||
Item(Key: TKey): TItem;
|
||||
|
||||
/** Get an array containing all items in the dictionary. */
|
||||
Items(): any;
|
||||
Items(): SafeArray<TItem>;
|
||||
|
||||
/** Change a key to a different key. */
|
||||
Key(Key: any): any;
|
||||
Key(Key: TKey): TKey;
|
||||
|
||||
/** Get an array containing all keys in the dictionary. */
|
||||
Keys(): any;
|
||||
Keys(): SafeArray<TKey>;
|
||||
|
||||
/** Remove a given key from the dictionary. */
|
||||
Remove(Key: any): void;
|
||||
Remove(Key: TKey): void;
|
||||
|
||||
/** Remove all information from the dictionary. */
|
||||
RemoveAll(): void;
|
||||
|
||||
/** Set or get the item for a given key */
|
||||
(Key: TKey): TItem;
|
||||
}
|
||||
|
||||
/** Drive Object */
|
||||
interface Drive {
|
||||
class Drive {
|
||||
private constructor();
|
||||
private 'Scripting.Drive_typekey': Drive;
|
||||
|
||||
/** Get available space */
|
||||
readonly AvailableSpace: any;
|
||||
readonly AvailableSpace: number;
|
||||
|
||||
/** Drive letter */
|
||||
readonly DriveLetter: string;
|
||||
@@ -105,7 +119,7 @@ declare namespace Scripting {
|
||||
readonly FileSystem: string;
|
||||
|
||||
/** Get drive free space */
|
||||
readonly FreeSpace: any;
|
||||
readonly FreeSpace: number;
|
||||
|
||||
/** Check if disk is available */
|
||||
readonly IsReady: boolean;
|
||||
@@ -123,7 +137,7 @@ declare namespace Scripting {
|
||||
readonly ShareName: string;
|
||||
|
||||
/** Get total drive size */
|
||||
readonly TotalSize: any;
|
||||
readonly TotalSize: number;
|
||||
|
||||
/** Name of volume */
|
||||
VolumeName: string;
|
||||
@@ -134,18 +148,27 @@ declare namespace Scripting {
|
||||
/** Number of drives */
|
||||
readonly Count: number;
|
||||
|
||||
/** Get drive */
|
||||
Item(Key: any): Drive;
|
||||
/** Get drive using the drive letter (`C`) or path (`C:\\`) */
|
||||
Item(Key: string): Drive;
|
||||
|
||||
/** Get drive using the drive letter (`C`) or path (`C:\\`) */
|
||||
(Key: string): Drive;
|
||||
}
|
||||
|
||||
/** Script Encoder Object */
|
||||
interface Encoder {
|
||||
/** Call the Encoder determined by szExt, passing bstrStreamIn and optional arguments */
|
||||
EncodeScriptFile(szExt: string, bstrStreamIn: string, cFlags: number, bstrDefaultLang: string): string;
|
||||
|
||||
/** Call the Encoder determined by szExt, passing bstrStreamIn and optional arguments */
|
||||
(szExt: string, bstrStreamIn: string, cFlags: number, bstrDefaultLang: string): string;
|
||||
}
|
||||
|
||||
/** File object */
|
||||
interface File {
|
||||
class File {
|
||||
private constructor();
|
||||
private 'Scripting.File_typekey': File;
|
||||
|
||||
/** File attributes */
|
||||
Attributes: FileAttribute;
|
||||
|
||||
@@ -166,7 +189,7 @@ declare namespace Scripting {
|
||||
|
||||
/**
|
||||
* Delete this file
|
||||
* @param boolean [Force=false]
|
||||
* @param boolean [Force=false] Pass `true` to delete the file even if the read-only attribute is set
|
||||
*/
|
||||
Delete(Force?: boolean): void;
|
||||
|
||||
@@ -199,7 +222,7 @@ declare namespace Scripting {
|
||||
readonly ShortPath: string;
|
||||
|
||||
/** File size */
|
||||
readonly Size: any;
|
||||
readonly Size: number;
|
||||
|
||||
/** Type description */
|
||||
readonly Type: string;
|
||||
@@ -210,12 +233,18 @@ declare namespace Scripting {
|
||||
/** Number of folders */
|
||||
readonly Count: number;
|
||||
|
||||
/** Get file object using the name and extension of the file */
|
||||
Item(Key: string): File;
|
||||
|
||||
/** Get file */
|
||||
Item(Key: any): File;
|
||||
(Key: string): File;
|
||||
}
|
||||
|
||||
/** FileSystem Object */
|
||||
interface FileSystemObject {
|
||||
class FileSystemObject {
|
||||
private constructor();
|
||||
private 'Scripting.FileSystemObject_typekey': FileSystemObject;
|
||||
|
||||
/** Generate a path from an existing path and a name */
|
||||
BuildPath(Path: string, Name: string): string;
|
||||
|
||||
@@ -243,13 +272,13 @@ declare namespace Scripting {
|
||||
|
||||
/**
|
||||
* Delete a file
|
||||
* @param boolean [Force=false]
|
||||
* @param boolean [Force=false] Pass `true` to also delete files with the read-only attribute set
|
||||
*/
|
||||
DeleteFile(FileSpec: string, Force?: boolean): void;
|
||||
|
||||
/**
|
||||
* Delete a folder
|
||||
* @param boolean [Force=false]
|
||||
* @param boolean [Force=false] Pass `true` to also delete folders with the read-only attribute set
|
||||
*/
|
||||
DeleteFolder(FolderSpec: string, Force?: boolean): void;
|
||||
|
||||
@@ -317,13 +346,16 @@ declare namespace Scripting {
|
||||
* Open a file as a TextStream
|
||||
* @param Scripting.IOMode [IOMode=1]
|
||||
* @param boolean [Create=false]
|
||||
* @param Scripting.Tristate [Format=0]
|
||||
* @param Scripting.Tristate [Format=0] **TristateTrue** opens the file as Unicode; **TristateFalse** opens the file as ASCII; **TristateUseDefault** opens the file with the system default
|
||||
*/
|
||||
OpenTextFile(FileName: string, IOMode?: IOMode, Create?: boolean, Format?: Tristate): TextStream;
|
||||
}
|
||||
|
||||
/** Folder object */
|
||||
interface Folder {
|
||||
class Folder {
|
||||
private constructor();
|
||||
private 'Scripting.Folder_typekey': Folder;
|
||||
|
||||
/** Folder attributes */
|
||||
Attributes: FileAttribute;
|
||||
|
||||
@@ -351,7 +383,7 @@ declare namespace Scripting {
|
||||
|
||||
/**
|
||||
* Delete this folder
|
||||
* @param boolean [Force=false]
|
||||
* @param boolean [Force=false] Pass `true` to delete the folder even if the read-only attribute set
|
||||
*/
|
||||
Delete(Force?: boolean): void;
|
||||
|
||||
@@ -383,7 +415,7 @@ declare namespace Scripting {
|
||||
readonly ShortPath: string;
|
||||
|
||||
/** Sum of files and subfolders */
|
||||
readonly Size: any;
|
||||
readonly Size: number;
|
||||
|
||||
/** Get folders collection */
|
||||
readonly SubFolders: Folders;
|
||||
@@ -400,12 +432,18 @@ declare namespace Scripting {
|
||||
/** Number of folders */
|
||||
readonly Count: number;
|
||||
|
||||
/** Get folder */
|
||||
Item(Key: any): Folder;
|
||||
/** Get folder in collection using the folder's name */
|
||||
Item(Key: string): Folder;
|
||||
|
||||
/** Get folder in collection using the folder's name */
|
||||
(Key: string): Folder;
|
||||
}
|
||||
|
||||
/** TextStream object */
|
||||
interface TextStream {
|
||||
class TextStream {
|
||||
private constructor();
|
||||
private 'Scripting.TextStream_typekey': TextStream;
|
||||
|
||||
/** Is the current position at the end of a line? */
|
||||
readonly AtEndOfLine: boolean;
|
||||
|
||||
@@ -451,15 +489,12 @@ declare namespace Scripting {
|
||||
}
|
||||
|
||||
interface ActiveXObject {
|
||||
new <K extends keyof ActiveXObjectNameMap = any>(progid: K): ActiveXObjectNameMap[K];
|
||||
set(obj: Scripting.Dictionary, propertyName: 'Item', parameterTypes: [any], newValue: any): void;
|
||||
new(progid: 'Scripting.Dictionary'): Scripting.Dictionary;
|
||||
new(progid: 'Scripting.Encoder'): Scripting.Encoder;
|
||||
new(progid: 'Scripting.FileSystemObject'): Scripting.FileSystemObject;
|
||||
}
|
||||
|
||||
interface EnumeratorConstructor {
|
||||
new(col: Scripting.Dictionary): any;
|
||||
new(col: Scripting.Drives): Scripting.Drive;
|
||||
new(col: Scripting.Files): Scripting.File;
|
||||
new(col: Scripting.Folders): Scripting.Folder;
|
||||
interface ActiveXObjectNameMap {
|
||||
'Scripting.Dictionary': Scripting.Dictionary;
|
||||
'Scripting.Encoder': Scripting.Encoder;
|
||||
'Scripting.FileSystemObject': Scripting.FileSystemObject;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,3 @@
|
||||
{
|
||||
"extends": "dtslint/dt.json",
|
||||
"rules": {
|
||||
"no-const-enum": false
|
||||
}
|
||||
"extends": "dtslint/dt.json"
|
||||
}
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": ["es5", "scripthost"],
|
||||
"lib": [
|
||||
"es5",
|
||||
"scripthost"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
|
||||
@@ -59,7 +59,7 @@ shell.ShowBrowserBar(Shell32.ExplorerBarCLSID.Favorites, true);
|
||||
|
||||
// https://msdn.microsoft.com/en-us/library/windows/desktop/bb774107(v=vs.85).aspx
|
||||
const wshShell = new ActiveXObject('WScript.Shell');
|
||||
wshShell.Popup(shell.Windows().Count);
|
||||
wshShell.Popup(shell.Windows().Count.toString());
|
||||
|
||||
// https://msdn.microsoft.com/en-us/library/windows/desktop/bb787866(v=vs.85).aspx
|
||||
shell.NameSpace(`c:\\windows`)!.CopyHere('c:\\autoexec.bat');
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": ["es5", "scripthost"],
|
||||
"lib": [
|
||||
"es5",
|
||||
"scripthost"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
|
||||
@@ -20,4 +20,4 @@
|
||||
"index.d.ts",
|
||||
"add-zero-tests.ts"
|
||||
]
|
||||
}
|
||||
}
|
||||
Vendored
-1965
File diff suppressed because it is too large
Load Diff
+44
@@ -0,0 +1,44 @@
|
||||
declare namespace adone.collection {
|
||||
/**
|
||||
* Respresetns a data structure which is a combination of an array and a set.
|
||||
* Adding a new member is O(1), testing for membership is O(1),
|
||||
* and finding the index of an element is O(1).
|
||||
*/
|
||||
class ArraySet<T = any> {
|
||||
/**
|
||||
* The number of unique items in this ArraySet.
|
||||
* If duplicates have been added, than those do not count towards the size.
|
||||
*/
|
||||
readonly length: number;
|
||||
|
||||
/**
|
||||
* Adds the given value to this set.
|
||||
*
|
||||
* @param allowDuplicates Whether to allow duplicates in the set, false by default
|
||||
*/
|
||||
add(value: T, allowDuplicates?: boolean): this;
|
||||
|
||||
/**
|
||||
* Checks whether the given value is a member of the set
|
||||
*/
|
||||
has(value: T): boolean;
|
||||
|
||||
/**
|
||||
* Returns the index of the given element.
|
||||
* If the value is not present it will return -1
|
||||
*/
|
||||
indexOf(value: T): number;
|
||||
|
||||
/**
|
||||
* Converts the set to an array
|
||||
*/
|
||||
toArray(): T[];
|
||||
|
||||
/**
|
||||
* Creates an ArraySet from the given iterable object
|
||||
*
|
||||
* @param allowDuplicates Whether to allow duplicates in the set, false by default
|
||||
*/
|
||||
static from<T>(iterable: Iterable<T>, allowDuplicates?: boolean): ArraySet<T>;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
declare namespace adone.collection {
|
||||
/**
|
||||
* Represents an asynchronous queue, each pop is a promise
|
||||
* that is resolved with an existing element or an element that will be pushed in the future
|
||||
*/
|
||||
class AsyncQueue<T = any> extends Queue<T, Promise<T>> {
|
||||
/**
|
||||
* Returns a promise that will be resolved with an existing element or an element that will be pushed in the future
|
||||
*/
|
||||
pop(): Promise<T>;
|
||||
}
|
||||
}
|
||||
+48
@@ -0,0 +1,48 @@
|
||||
declare namespace adone.collection {
|
||||
/**
|
||||
* Represents an AVL tree, a self-balancing binary search tree
|
||||
*/
|
||||
class AVLTree<K = any, V = any> {
|
||||
constructor(options?: I.BinarySearchTree.ConstructorOptions<K, V, AVLTree<K, V>>);
|
||||
|
||||
/**
|
||||
* Checks whether the tree is an avl tree
|
||||
*/
|
||||
checkIsAVLT(): void;
|
||||
|
||||
/**
|
||||
* Inserts a new key/value
|
||||
*/
|
||||
insert(key: K, value: V): void;
|
||||
|
||||
/**
|
||||
* Deletes the given key/value from the tree
|
||||
*/
|
||||
delete(key: K, value?: V): void;
|
||||
|
||||
/**
|
||||
* Returns the of keys in the tree
|
||||
*/
|
||||
getNumberOFKeys(): number;
|
||||
|
||||
/**
|
||||
* Searches the given key in the tree
|
||||
*/
|
||||
search(key: K): V[];
|
||||
|
||||
/**
|
||||
* Returns all the values from the given key bounds
|
||||
*/
|
||||
betweenBounds(query: I.BinarySearchTree.Query<K>): V[];
|
||||
|
||||
/**
|
||||
* Executed the given callback for each node from left to right
|
||||
*/
|
||||
executeOnEveryNode(fn: (tree: AVLTree<K, V>) => void): void;
|
||||
|
||||
/**
|
||||
* Prints the tree
|
||||
*/
|
||||
prettyPrint(printDate?: boolean, spacing?: string): void;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,110 @@
|
||||
declare namespace adone.collection {
|
||||
namespace I.BinarySearchTree {
|
||||
interface ConstructorOptions<K, V, Tree> {
|
||||
/**
|
||||
* The parent tree
|
||||
*/
|
||||
parent?: Tree;
|
||||
|
||||
/**
|
||||
* Value to keep in this node
|
||||
*/
|
||||
value?: V;
|
||||
|
||||
/**
|
||||
* WHether the values must be unique, false by default.
|
||||
* If false you can store many values for same keys, otherwise only one
|
||||
*/
|
||||
unique?: boolean;
|
||||
|
||||
/**
|
||||
* Custom keys comparator, by default if a > b => -1, a < b -1, a === b => 0
|
||||
*/
|
||||
compareKeys?(a: K, b: K): number;
|
||||
|
||||
/**
|
||||
* Function that defines whether 2 values are the same, by default a === b
|
||||
*/
|
||||
checkValueEquality?(a: V, b: V): boolean;
|
||||
}
|
||||
|
||||
interface Query<K> {
|
||||
$lt?: K;
|
||||
$lte?: K;
|
||||
$gt?: K;
|
||||
$gte?: K;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents a binary search tree
|
||||
*/
|
||||
class BinarySearchTree<K = any, V = any> {
|
||||
constructor(options?: I.BinarySearchTree.ConstructorOptions<K, V, BinarySearchTree<K, V>>);
|
||||
|
||||
/**
|
||||
* Returns the max descendant tree
|
||||
*/
|
||||
getMaxKeyDescendant(): BinarySearchTree<K, V>;
|
||||
|
||||
/**
|
||||
* Returns the maximum key
|
||||
*/
|
||||
getMaxKey(): K;
|
||||
|
||||
/**
|
||||
* Returns the min descendant tree
|
||||
*/
|
||||
getMinKeyDescendant(): BinarySearchTree<K, V>;
|
||||
|
||||
/**
|
||||
* Returns the minumum key
|
||||
*/
|
||||
getMinKey(): K;
|
||||
|
||||
/**
|
||||
* Traverses the tree and calls the given function for each node
|
||||
*/
|
||||
checkAllNodesFullfillCondition(test: (key: K, value: V) => void): void;
|
||||
|
||||
/**
|
||||
* Checks whether the tree is a binary search tree
|
||||
*/
|
||||
checkIsBST(): void;
|
||||
|
||||
/**
|
||||
* Returns the of keys in the tree
|
||||
*/
|
||||
getNumberOfKeys(): number;
|
||||
|
||||
/**
|
||||
* Inserts a new key/value
|
||||
*/
|
||||
insert(key: K, value: V): void;
|
||||
|
||||
/**
|
||||
* Searches the given key in the tree
|
||||
*/
|
||||
search(key: K): V[];
|
||||
|
||||
/**
|
||||
* Returns all the values from the given key bounds
|
||||
*/
|
||||
betweenBounds(query: I.BinarySearchTree.Query<K>): V[];
|
||||
|
||||
/**
|
||||
* Deletes the given key/value from the tree
|
||||
*/
|
||||
delete(key: K, value?: V): void;
|
||||
|
||||
/**
|
||||
* Executed the given callback for each node from left to right
|
||||
*/
|
||||
executeOnEveryNode(fn: (tree: BinarySearchTree<K, V>) => void): void;
|
||||
|
||||
/**
|
||||
* Prints the tree
|
||||
*/
|
||||
prettyPrint(printData?: boolean, spacing?: string): void;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
declare namespace adone.collection {
|
||||
namespace I.BufferList {
|
||||
type Appendable = Buffer | BufferList | string | number | Array<Buffer | BufferList | string | number>;
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents a Node.js Buffer list collector, reader and streamer with callback/promise interface support
|
||||
*/
|
||||
class BufferList extends std.stream.Duplex implements PromiseLike<Buffer> {
|
||||
/**
|
||||
* Creates a new buffer list
|
||||
*/
|
||||
constructor();
|
||||
|
||||
/**
|
||||
* Creates a new buffer list and initiates with the given value
|
||||
*/
|
||||
constructor(buffer: I.BufferList.Appendable);
|
||||
|
||||
/**
|
||||
* Creates a new buffer list and subscribes the given callback on the end/error event
|
||||
*/
|
||||
constructor(callback: (err: any, data: Buffer) => void);
|
||||
|
||||
/**
|
||||
* Adds an additional buffer or BufferList to the internal list
|
||||
*/
|
||||
append(buf: I.BufferList.Appendable): this;
|
||||
|
||||
/**
|
||||
* Ends the stream
|
||||
*/
|
||||
end(chunk?: Buffer): void;
|
||||
end(chunk?: () => void): void;
|
||||
|
||||
/**
|
||||
* Returns the byte at the specified index
|
||||
*/
|
||||
get(idx: number): number;
|
||||
|
||||
/**
|
||||
* Returns a new Buffer object containing the bytes within the range specified.
|
||||
*/
|
||||
slice(start?: number, end?: number): Buffer;
|
||||
|
||||
/**
|
||||
* Copies the content of the list in the dest buffer
|
||||
* starting from destStart and containing the bytes within the range specified with srcStart to srcEnd
|
||||
*
|
||||
* @param dstStart writes from this position
|
||||
* @param srcStart reads bytes from this position
|
||||
* @param srcEnd read bytes to this position
|
||||
*/
|
||||
copy<T extends Buffer = Buffer>(dst: T, dstStart?: number, srcStart?: number, srcEnd?: number): T;
|
||||
|
||||
/**
|
||||
* Returns a new BufferList object containing the bytes within the range specified.
|
||||
* No copies will be performed. All buffers in the result share memory with the original list.
|
||||
*
|
||||
* @param start slice from
|
||||
* @param end slice to
|
||||
*/
|
||||
shallowSlice(start?: number, end?: number): BufferList;
|
||||
|
||||
/**
|
||||
* Return a string representation of the buffer
|
||||
*/
|
||||
toString(encoding?: fs.I.Encoding, start?: number, end?: number): string;
|
||||
|
||||
/**
|
||||
* Shifts bytes off the start of the list
|
||||
*/
|
||||
consume(bytes: number): this;
|
||||
|
||||
/**
|
||||
* Performs a shallow-copy of the list.
|
||||
*/
|
||||
duplicate(): BufferList;
|
||||
|
||||
/**
|
||||
* Destroys the stream
|
||||
*/
|
||||
destroy(): void;
|
||||
|
||||
then<T1 = Buffer, T2 = never>(
|
||||
onfulfilled?: ((value: Buffer) => T1 | PromiseLike<T1>) | null,
|
||||
onrejected?: ((reason: any) => T2 | PromiseLike<T2>) | null
|
||||
): PromiseLike<T1 | T2>;
|
||||
|
||||
catch<T>(onrejected?: ((reason: any) => T | PromiseLike<T>) | null): PromiseLike<T | Buffer>;
|
||||
}
|
||||
}
|
||||
+892
@@ -0,0 +1,892 @@
|
||||
declare namespace adone.collection {
|
||||
namespace I {
|
||||
type Long = math.Long;
|
||||
|
||||
type Longable = math.I.Longable;
|
||||
|
||||
namespace ByteArray {
|
||||
interface Varint32 {
|
||||
value: number;
|
||||
length: number;
|
||||
}
|
||||
|
||||
interface Varint64 {
|
||||
value: Long;
|
||||
length: number;
|
||||
}
|
||||
|
||||
interface String {
|
||||
string: string;
|
||||
length: number;
|
||||
}
|
||||
|
||||
type Wrappable = string | ByteArray | Buffer | Uint8Array | ArrayBuffer;
|
||||
|
||||
type Metrics = "b" | "c";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents an array of bytes, enhanced Node.js Buffer
|
||||
*/
|
||||
class ByteArray {
|
||||
readonly woffset: number;
|
||||
|
||||
readonly roffset: number;
|
||||
|
||||
readonly buffer: Buffer;
|
||||
|
||||
readonly noAssert: boolean;
|
||||
|
||||
/**
|
||||
* Constructs a new ByteArray
|
||||
*
|
||||
* @param capacity Initial capacity. Defaults to ByteArray.DEFAULT_CAPACITY(64)
|
||||
* @param noAssert Whether to skip assertions of offsets and values. Defaults to ByteArray.DEFAULT_NOASSERT(false)
|
||||
*/
|
||||
constructor(capacity?: number, noAssert?: boolean);
|
||||
|
||||
/**
|
||||
* Reads a BitSet as an array of booleans.
|
||||
*
|
||||
* @param offset Offset to read from. Will use and increase offset by length if omitted.
|
||||
*/
|
||||
readBitSet(offset?: number): boolean[];
|
||||
|
||||
/**
|
||||
* Reads the specified number of bytes.
|
||||
*
|
||||
* @param length Number of bytes to read
|
||||
* @param offset Offset to read from. Will use and increase offset by length if omitted.
|
||||
*/
|
||||
read(length: number, offset?: number): ByteArray;
|
||||
|
||||
/**
|
||||
* Reads an 8bit signed integer
|
||||
*
|
||||
* @param offset Offset to read from
|
||||
*/
|
||||
readInt8(offset?: number): number;
|
||||
|
||||
/**
|
||||
* Reads an 8bit unsigned integer
|
||||
*
|
||||
* @param offset Offset to read from
|
||||
*/
|
||||
readUInt8(offset?: number): number;
|
||||
|
||||
/**
|
||||
* Reads a 16bit signed le integer
|
||||
*
|
||||
* @param offset Offset to read from
|
||||
*/
|
||||
readInt16LE(offset?: number): number;
|
||||
|
||||
/**
|
||||
* Reads a 16bit unsigned le integer
|
||||
*
|
||||
* @param offset Offset to read from
|
||||
*/
|
||||
readUInt16LE(offset?: number): number;
|
||||
|
||||
/**
|
||||
* Reads a 16bit signed be integer
|
||||
*
|
||||
* @param offset Offset to read from
|
||||
*/
|
||||
readInt16BE(offset?: number): number;
|
||||
|
||||
/**
|
||||
* Reads a 16bit unsigned be integer
|
||||
*
|
||||
* @param offset Offset to read from
|
||||
*/
|
||||
readUInt16BE(offset?: number): number;
|
||||
|
||||
/**
|
||||
* Reads a 32bit signed le integer
|
||||
*
|
||||
* @param offset Offset to read from
|
||||
*/
|
||||
readInt32LE(offset?: number): number;
|
||||
|
||||
/**
|
||||
* Reads a 32bit unsigned le integer
|
||||
*
|
||||
* @param offset Offset to read from
|
||||
*/
|
||||
readUInt32LE(offset?: number): number;
|
||||
|
||||
/**
|
||||
* Reads a 32bit signed be integer
|
||||
*
|
||||
* @param offset Offset to read from
|
||||
*/
|
||||
readInt32BE(offset?: number): number;
|
||||
|
||||
/**
|
||||
* Reads a 32bit unsigned be integer
|
||||
*
|
||||
* @param offset Offset to read from
|
||||
*/
|
||||
readUInt32BE(offset?: number): number;
|
||||
|
||||
/**
|
||||
* Reads a 64bit signed le integer as math.Long
|
||||
*
|
||||
* @param offset Offset to read from
|
||||
*/
|
||||
readInt64LE(offset?: number): math.Long;
|
||||
|
||||
/**
|
||||
* Reads a 64bit unsigned le integer as math.Long
|
||||
*
|
||||
* @param offset Offset to read from
|
||||
*/
|
||||
readUInt64LE(offset?: number): math.Long;
|
||||
|
||||
/**
|
||||
* Reads a 64bit signed be integer as math.Long
|
||||
*
|
||||
* @param offset Offset to read from
|
||||
*/
|
||||
readInt64BE(offset?: number): math.Long;
|
||||
|
||||
/**
|
||||
* Reads a 64bit unsigned be integer as math.Long
|
||||
*
|
||||
* @param offset Offset to read from
|
||||
*/
|
||||
readUInt64BE(offset?: number): math.Long;
|
||||
|
||||
/**
|
||||
* Reads a 32bit le float
|
||||
*
|
||||
* @param offset Offset to read from
|
||||
*/
|
||||
readFloatLE(offset?: number): number;
|
||||
|
||||
/**
|
||||
* Reads a 32bit be float
|
||||
*
|
||||
* @param offset Offset to read from
|
||||
*/
|
||||
readFloatBE(offset?: number): number;
|
||||
|
||||
/**
|
||||
* Reads a 64bit le float
|
||||
*
|
||||
* @param offset Offset to read from
|
||||
*/
|
||||
readDoubleLE(offset?: number): number;
|
||||
|
||||
/**
|
||||
* Reads a 64bit be float
|
||||
*
|
||||
* @param offset Offset to read from
|
||||
*/
|
||||
readDoubleBE(offset?: number): number;
|
||||
|
||||
/**
|
||||
* Appends some data to this ByteArray.
|
||||
* This will overwrite any contents behind the specified offset up to the appended data's length.
|
||||
*
|
||||
* @param source The source write from
|
||||
* @param offset Offset to write at
|
||||
* @param length length to read from the source
|
||||
* @param encoding encoding to use for wrapping the source in bytearray
|
||||
*/
|
||||
write(source: I.ByteArray.Wrappable, offset?: number, length?: number, encoding?: string): this;
|
||||
|
||||
/**
|
||||
* Writes the array as a bitset.
|
||||
* @param value Array of booleans to write
|
||||
*/
|
||||
writeBitSet(value: number[]): this;
|
||||
|
||||
/**
|
||||
* Writes the array as a bitset.
|
||||
* @param value Array of booleans to write
|
||||
* @param offset Offset to write at
|
||||
*/
|
||||
writeBitSet(value: number[], offset: number): number;
|
||||
|
||||
/**
|
||||
* Writes a buffer at the given offset
|
||||
* @param buf Buffer to write
|
||||
* @param offset Offset to write at
|
||||
*/
|
||||
writeBuffer(buf: Buffer, offset?: number): this;
|
||||
|
||||
/**
|
||||
* Writes an 8bit signed integer
|
||||
*
|
||||
* @param offset Offset to write at
|
||||
*/
|
||||
writeInt8(value: number, offset?: number): this;
|
||||
|
||||
/**
|
||||
* Writes an 8bit unsigned integer
|
||||
*
|
||||
* @param offset Offset to write at
|
||||
*/
|
||||
writeUInt8(value: number, offset?: number): this;
|
||||
|
||||
/**
|
||||
* Writes a 16bit signed le integer
|
||||
*
|
||||
* @param offset Offset to write at
|
||||
*/
|
||||
writeInt16LE(value: number, offset?: number): this;
|
||||
|
||||
/**
|
||||
* Writes a 16bit signed be integer
|
||||
*
|
||||
* @param offset Offset to write at
|
||||
*/
|
||||
writeInt16BE(value: number, offset?: number): this;
|
||||
|
||||
/**
|
||||
* Writes a 16bit unsigned le integer
|
||||
*
|
||||
* @param offset Offset to write at
|
||||
*/
|
||||
writeUInt16LE(value: number, offset?: number): this;
|
||||
|
||||
/**
|
||||
* Writes a 16bit unsigned be integer
|
||||
*
|
||||
* @param offset Offset to write at
|
||||
*/
|
||||
writeUInt16BE(value: number, offset?: number): this;
|
||||
|
||||
/**
|
||||
* Writes a 32bit signed le integer
|
||||
*
|
||||
* @param offset Offset to write at
|
||||
*/
|
||||
writeInt32LE(value: number, offset?: number): this;
|
||||
|
||||
/**
|
||||
* Writes a 32bit signed be integer
|
||||
*
|
||||
* @param offset Offset to write at
|
||||
*/
|
||||
writeInt32BE(value: number, offset?: number): this;
|
||||
|
||||
/**
|
||||
* Writes a 32bit unsigned le integer
|
||||
*
|
||||
* @param offset Offset to write at
|
||||
*/
|
||||
writeUInt32LE(value: number, offset?: number): this;
|
||||
|
||||
/**
|
||||
* Writes a 32bit unsigned be integer
|
||||
*
|
||||
* @param offset Offset to write at
|
||||
*/
|
||||
writeUInt32BE(value: number, offset?: number): this;
|
||||
|
||||
/**
|
||||
* Writes a 64bit signed le long integer
|
||||
*
|
||||
* @param offset Offset to write at
|
||||
*/
|
||||
writeInt64LE(value: math.Long | string | number, offset?: number): this;
|
||||
|
||||
/**
|
||||
* Writes a 64bit signed be long integer
|
||||
*
|
||||
* @param offset Offset to write at
|
||||
*/
|
||||
writeInt64BE(value: math.Long | string | number, offset?: number): this;
|
||||
|
||||
/**
|
||||
* Writes a 64bit unsigned le long integer
|
||||
*
|
||||
* @param offset Offset to write at
|
||||
*/
|
||||
writeUInt64LE(value: math.Long | string | number, offset?: number): this;
|
||||
|
||||
/**
|
||||
* Writes a 64bit unsigned be long integer
|
||||
*
|
||||
* @param offset Offset to write at
|
||||
*/
|
||||
writeUInt64BE(value: math.Long | string | number, offset?: number): this;
|
||||
|
||||
/**
|
||||
* Writes a 32bit le float
|
||||
*
|
||||
* @param offset Offset to write at
|
||||
*/
|
||||
writeFloatLE(value: number, offset?: number): this;
|
||||
|
||||
/**
|
||||
* Writes a 32bit be float
|
||||
*
|
||||
* @param offset Offset to write at
|
||||
*/
|
||||
writeFloatBE(value: number, offset?: number): this;
|
||||
|
||||
/**
|
||||
* Writes a 64bit le float
|
||||
*
|
||||
* @param offset Offset to write at
|
||||
*/
|
||||
writeDoubleLE(value: number, offset?: number): this;
|
||||
|
||||
/**
|
||||
* Writes a 64bit be float
|
||||
*
|
||||
* @param offset Offset to write at
|
||||
*/
|
||||
writeDoubleBE(value: number, offset?: number): this;
|
||||
|
||||
/**
|
||||
* Writes a 32bit base 128 variable-length integer
|
||||
*/
|
||||
writeVarint32(value: number): this;
|
||||
|
||||
/**
|
||||
* Writes a 32bit base 128 variable-length integer
|
||||
*
|
||||
* @param offset Offset to write at
|
||||
*/
|
||||
writeVarint32(value: number, offset: number): number;
|
||||
|
||||
/**
|
||||
* Writes a zig-zag encoded 32bit base 128 variable-length integer
|
||||
*/
|
||||
writeVarint32ZigZag(value: number): this;
|
||||
|
||||
/**
|
||||
* Writes a zig-zag encoded 32bit base 128 variable-length integer
|
||||
*
|
||||
* @param offset Offset to write at
|
||||
*/
|
||||
writeVarint32ZigZag(value: number, offset: number): number;
|
||||
|
||||
/**
|
||||
* Reads a 32bit base 128 variable-length integer
|
||||
*/
|
||||
readVarint32(): number;
|
||||
|
||||
/**
|
||||
* Reads a 32bit base 128 variable-length integer
|
||||
*
|
||||
* @param offset Offset to read from
|
||||
*/
|
||||
readVarint32(offset: number): I.ByteArray.Varint32;
|
||||
|
||||
/**
|
||||
* Reads a zig-zag encoded 32bit base 128 variable-length integer
|
||||
*/
|
||||
readVarint32ZigZag(): number;
|
||||
|
||||
/**
|
||||
* Reads a zig-zag encoded 32bit base 128 variable-length integer
|
||||
*
|
||||
* @param offset Offset to read from
|
||||
*/
|
||||
readVarint32ZigZag(offset: number): I.ByteArray.Varint32;
|
||||
|
||||
/**
|
||||
* Writes a 64bit base 128 variable-length integer
|
||||
*/
|
||||
writeVarint64(value: math.Long | string | number): this;
|
||||
|
||||
/**
|
||||
* Writes a 64bit base 128 variable-length integer
|
||||
*
|
||||
* @param offset Offset to write at
|
||||
*/
|
||||
writeVarint64(value: math.Long | string | number, offset: number): number;
|
||||
|
||||
/**
|
||||
* Writes a zig-zag encoded 64bit base 128 variable-length integer
|
||||
*/
|
||||
writeVarint64ZigZag(value: math.Long | string | number): this;
|
||||
|
||||
/**
|
||||
* Writes a zig-zag encoded 64bit base 128 variable-length integer
|
||||
*
|
||||
* @param offset Offset to write at
|
||||
*/
|
||||
writeVarint64ZigZag(value: math.Long | string | number, offset: number): number;
|
||||
|
||||
/**
|
||||
* Reads a 64bit base 128 variable-length integer
|
||||
*/
|
||||
readVarint64(): I.Long;
|
||||
|
||||
/**
|
||||
* Reads a 64bit base 128 variable-length integer
|
||||
*
|
||||
* @param offset Offset to read from
|
||||
*/
|
||||
readVarint64(offset: number): I.ByteArray.Varint64;
|
||||
|
||||
/**
|
||||
* Reads a zig-zag encoded 64bit base 128 variable-length integer
|
||||
*/
|
||||
readVarint64ZigZag(): math.Long;
|
||||
|
||||
/**
|
||||
* Reads a zig-zag encoded 64bit base 128 variable-length integer
|
||||
*
|
||||
* @param offset Offset to read from
|
||||
*/
|
||||
readVarint64ZigZag(offset: number): I.ByteArray.Varint64;
|
||||
|
||||
/**
|
||||
* Writes a NULL-terminated UTF8 encoded string.
|
||||
* For this to work the specified string must not contain any NULL characters itself
|
||||
*/
|
||||
writeCString(str: string): this;
|
||||
|
||||
/**
|
||||
* Writes a NULL-terminated UTF8 encoded string.
|
||||
* For this to work the specified string must not contain any NULL characters itself
|
||||
*
|
||||
* @param offset Offset to write at
|
||||
*/
|
||||
writeCString(str: string, offset: number): number;
|
||||
|
||||
/**
|
||||
* Reads a NULL-terminated UTF8 encoded string.
|
||||
* For this to work the string read must not contain any NULL characters itself
|
||||
*/
|
||||
readCString(): string;
|
||||
|
||||
/**
|
||||
* Reads a NULL-terminated UTF8 encoded string.
|
||||
* For this to work the string read must not contain any NULL characters itself
|
||||
*
|
||||
* @param offset Offset to read from
|
||||
*/
|
||||
readCString(offset: number): I.ByteArray.String;
|
||||
|
||||
/**
|
||||
* Writes an UTF8 encoded string
|
||||
*/
|
||||
writeString(str: string): this;
|
||||
|
||||
/**
|
||||
* Writes an UTF8 encoded string
|
||||
*
|
||||
* @param offset Offset to write at
|
||||
*/
|
||||
writeString(str: string, offset: number): number;
|
||||
|
||||
/**
|
||||
* Reads an UTF8 encoded string
|
||||
*
|
||||
* @param length Number of characters or bytes to read
|
||||
* @param metrics Metrics specifying what n is meant to count. Defaults to ByteArray.METRICS_CHARS("c")
|
||||
*/
|
||||
readString(length: number, metrics?: I.ByteArray.Metrics): string;
|
||||
|
||||
/**
|
||||
* Reads an UTF8 encoded string
|
||||
*
|
||||
* @param length Number of characters or bytes to read
|
||||
* @param metrics Metrics specifying what n is meant to count. Defaults to ByteArray.METRICS_CHARS("c")
|
||||
* @param offset Offset to read from
|
||||
*/
|
||||
readString(length: number, metrics: I.ByteArray.Metrics, offset: number): I.ByteArray.String;
|
||||
|
||||
/**
|
||||
* Reads an UTF8 encoded string
|
||||
*
|
||||
* @param length Number of characters or bytes to read
|
||||
* @param offset Offset to read from
|
||||
*/
|
||||
readString(length: number, offset: number): I.ByteArray.String;
|
||||
|
||||
/**
|
||||
* Writes a length as varint32 prefixed UTF8 encoded string
|
||||
*/
|
||||
writeVString(str: string): this;
|
||||
|
||||
/**
|
||||
* Writes a length as varint32 prefixed UTF8 encoded string
|
||||
*
|
||||
* @param offset Offset to read from
|
||||
*/
|
||||
writeVString(str: string, offset: number): number;
|
||||
|
||||
/**
|
||||
* Reads a length as varint32 prefixed UTF8 encoded string
|
||||
*/
|
||||
readVString(): string;
|
||||
|
||||
/**
|
||||
* Reads a length as varint32 prefixed UTF8 encoded string
|
||||
*
|
||||
* @param offset Offset to read from
|
||||
*/
|
||||
readVString(offset: number): I.ByteArray.String;
|
||||
|
||||
/**
|
||||
* Appends this ByteArray's contents to another ByteArray.
|
||||
* This will overwrite any contents behind the specified offset up to the length of this ByteArray's data
|
||||
*
|
||||
* @param offset Offset to append to
|
||||
*/
|
||||
appendTo(target: ByteArray, offset?: number): this;
|
||||
|
||||
/**
|
||||
* Enables or disables assertions of argument types and offsets.
|
||||
* Assertions are enabled by default but you can opt to disable them if your code already makes sure that everything is valid
|
||||
*/
|
||||
assert(assert?: boolean): this;
|
||||
|
||||
/**
|
||||
* Gets the capacity of this ByteArray's backing buffer
|
||||
*/
|
||||
capacity(): number;
|
||||
|
||||
/**
|
||||
* Clears this ByteArray's offsets by setting offset to 0 and limit to the backing buffer's capacity
|
||||
*/
|
||||
clear(): this;
|
||||
|
||||
/**
|
||||
* Creates a cloned instance of this ByteArray,
|
||||
* preset with this ByteArray's values for offset, markedOffset and limit
|
||||
*
|
||||
* @param copy Whether to copy the backing buffer or to return another view on the same, false by default
|
||||
*/
|
||||
clone(copy?: boolean): ByteArray;
|
||||
|
||||
/**
|
||||
* Compacts this ByteArray to be backed by a buffer of its contents' length.
|
||||
* Will set offset = 0 and limit = capacity and adapt markedOffset to the same relative position if set
|
||||
*
|
||||
* @param begin Offset to start at, buffer offset by default
|
||||
* @param end Offset to end at, buffer limit by default
|
||||
*/
|
||||
compact(begin?: number, end?: number): this;
|
||||
|
||||
/**
|
||||
* Creates a copy of this ByteArray's contents.
|
||||
*
|
||||
* @param begin Begin offset, buffer offset by default
|
||||
* @param end End offset, buffer limit by default
|
||||
*/
|
||||
copy(begin?: number, end?: number): ByteArray;
|
||||
|
||||
/**
|
||||
* Copies this ByteArray's contents to another ByteArray.
|
||||
*
|
||||
* @param targetOffset Offset to copy to. Will use and increase the target's offset by the number of bytes copied if omitted
|
||||
* @param sourceOffset Offset to start copying from. Will use and increase offset by the number of bytes copied if omitted
|
||||
* @param sourceLimit Offset to end copying from, defaults to the buffer limit
|
||||
*/
|
||||
copyTo(target: ByteArray, targetOffset?: number, souceOffset?: number, sourceLimit?: number): this | ByteArray;
|
||||
|
||||
/**
|
||||
* Makes sure that this ByteArray is backed by a ByteArray#buffer of at least the specified capacity.
|
||||
* If the current capacity is exceeded, it will be doubled.
|
||||
* If double the current capacity is less than the required capacity, the required capacity will be used instead
|
||||
*/
|
||||
ensureCapacity(capacity: number): this;
|
||||
|
||||
/**
|
||||
* Overwrites this ByteArray's contents with the specified value.
|
||||
*
|
||||
* @param value Byte value to fill with. If given as a string, the first character is used
|
||||
* @param begin Begin offset. Will use and increase offset by the number of bytes written if omitted. defaults to offset
|
||||
* @param end End offset, defaults to limit.
|
||||
*/
|
||||
fill(value: string | number, begin?: number, end?: number): this;
|
||||
|
||||
/**
|
||||
* Makes this ByteArray ready for a new sequence of write or relative read operations.
|
||||
* Sets limit = offset and offset = 0.
|
||||
* Make sure always to flip a ByteArray when all relative read or write operations are complete
|
||||
*/
|
||||
flip(): this;
|
||||
|
||||
/**
|
||||
* Marks an offset on this ByteArray to be used later
|
||||
*
|
||||
* @param offset Offset to mark. Defaults to offset.
|
||||
*/
|
||||
mark(offset?: number): this;
|
||||
|
||||
/**
|
||||
* Prepends some data to this ByteArray.
|
||||
* This will overwrite any contents before the specified offset up to the prepended data's length.
|
||||
* If there is not enough space available before the specified offset,
|
||||
* the backing buffer will be resized and its contents moved accordingly
|
||||
*
|
||||
* @param source Data to prepend
|
||||
* @param offset Offset to prepend at. Will use and decrease offset by the number of bytes prepended if omitted.
|
||||
*/
|
||||
prepend(source: I.ByteArray.Wrappable, offset: number): this;
|
||||
|
||||
/**
|
||||
* Prepends some data to this ByteArray.
|
||||
* This will overwrite any contents before the specified offset up to the prepended data's length.
|
||||
* If there is not enough space available before the specified offset,
|
||||
* the backing buffer will be resized and its contents moved accordingly
|
||||
*
|
||||
* @param source Data to prepend
|
||||
* @param encoding Encoding if data is a string
|
||||
* @param offset Offset to prepend at. Will use and decrease offset by the number of bytes prepended if omitted.
|
||||
*/
|
||||
prepend(source: I.ByteArray.Wrappable, encoding?: string, offset?: number): this;
|
||||
|
||||
/**
|
||||
* Prepends this ByteArray to another ByteArray.
|
||||
* This will overwrite any contents before the specified offset up to the prepended data's length.
|
||||
* If there is not enough space available before the specified offset,
|
||||
* the backing buffer will be resized and its contents moved accordingly
|
||||
*
|
||||
* @param offset Offset to prepend at
|
||||
*/
|
||||
prependTo(target: ByteArray, offset?: number): this;
|
||||
|
||||
/**
|
||||
* Gets the number of remaining readable bytes
|
||||
*/
|
||||
remaining(): number;
|
||||
|
||||
/**
|
||||
* Resets this ByteArray's offset.
|
||||
* If an offset has been marked through mark before, offset will be set to markedOffset, which will then be discarded.
|
||||
* If no offset has been marked, sets offset = 0
|
||||
*/
|
||||
reset(): this;
|
||||
|
||||
/**
|
||||
* Resizes this ByteArray to be backed by a buffer of at least the given capacity.
|
||||
* Will do nothing if already that large or larger.
|
||||
*
|
||||
* @param capacity Capacity required
|
||||
*/
|
||||
resize(capacity: number): this;
|
||||
|
||||
/**
|
||||
* Reverses this ByteArray's contents.
|
||||
*
|
||||
* @param begin Offset to start at, defaults to offset
|
||||
* @param end Offset to end at, defaults to limit
|
||||
*/
|
||||
reverse(begin?: number, end?: number): this;
|
||||
|
||||
/**
|
||||
* Skips the next length bytes. This will just advance
|
||||
*/
|
||||
skip(length: number): this;
|
||||
|
||||
/**
|
||||
* Slices this ByteArray by creating a cloned instance with offset = begin and limit = end
|
||||
*
|
||||
* @param begin Begin offset, defaults to offset
|
||||
* @param end End offset, defaults to limit
|
||||
*/
|
||||
slice(begin?: number, end?: number): ByteArray;
|
||||
|
||||
/**
|
||||
* Returns a copy of the backing buffer that contains this ByteArray's contents.
|
||||
*
|
||||
* @param forceCopy If true returns a copy, otherwise returns a view referencing the same memory if possible, false by default
|
||||
* @param begin Begin offset, offset by default
|
||||
* @param end End offset, limit by default
|
||||
*/
|
||||
toBuffer(forceCopy?: boolean, begin?: number, end?: number): Buffer;
|
||||
|
||||
/**
|
||||
* Returns a raw buffer compacted to contain this ByteArray's contents
|
||||
*/
|
||||
toArrayBuffer(): ArrayBuffer;
|
||||
|
||||
/**
|
||||
* Converts the ByteArray's contents to a string
|
||||
*
|
||||
* @param encoding Output encoding
|
||||
* @param begin Begin offset, offset by default
|
||||
* @param end End offset, limit by default
|
||||
*/
|
||||
toString(encoding?: string, begin?: number, end?: number): string;
|
||||
|
||||
/**
|
||||
* Encodes this ByteArray's contents to a base64 encoded string
|
||||
*
|
||||
* @param begin Begin offset, offset by default
|
||||
* @param end End offset, limit by default
|
||||
*/
|
||||
toBase64(begin?: number, end?: number): string;
|
||||
|
||||
/**
|
||||
* Encodes this ByteArray to a binary encoded string, that is using only characters 0x00-0xFF as bytes
|
||||
*
|
||||
* @param begin Begin offset, offset by default
|
||||
* @param end End offset, limit by default
|
||||
*/
|
||||
toBinary(begin?: number, end?: number): string;
|
||||
|
||||
/**
|
||||
* Encodes this ByteArray to a hex encoded string with marked offsets
|
||||
*
|
||||
* @param columns If true returns two columns hex + ascii, defaults to false
|
||||
*/
|
||||
toDebug(columns?: boolean): string;
|
||||
|
||||
/**
|
||||
* Encodes this ByteArray's contents to a hex encoded string
|
||||
*
|
||||
* @param begin Begin offset, offset by default
|
||||
* @param end End offset, limit by default
|
||||
*/
|
||||
toHex(begin?: number, end?: number): string;
|
||||
|
||||
/**
|
||||
* Encodes this ByteArray's contents to an UTF8 encoded string
|
||||
*
|
||||
* @param begin Begin offset, offset by default
|
||||
* @param end End offset, limit by default
|
||||
*/
|
||||
toUTF8(begin?: number, end?: number): string;
|
||||
|
||||
static accessor(): typeof Buffer;
|
||||
|
||||
/**
|
||||
* Allocates a new ByteArray backed by a buffer of the specified capacity.
|
||||
*
|
||||
* @param capacity Initial capacity. Defaults to ByteArray.DEFAULT_CAPACITY(64)
|
||||
* @param noAssert Whether to skip assertions of offsets and values. Defaults to ByteArray.DEFAULT_NOASSERT(false)
|
||||
*/
|
||||
static allocate(capacity?: number, noAssert?: boolean): ByteArray;
|
||||
|
||||
/**
|
||||
* Concatenates multiple ByteArrays into one
|
||||
*
|
||||
* @param encoding Encoding for strings
|
||||
* @param noAssert Whether to skip assertions of offsets and values. Defaults to ByteArray.DEFAULT_NOASSERT(false)
|
||||
*/
|
||||
static concat(buffers: I.ByteArray.Wrappable[], encoding?: string, noAssert?: boolean): ByteArray;
|
||||
|
||||
static type(): typeof Buffer;
|
||||
|
||||
/**
|
||||
* Wraps a buffer or a string.
|
||||
* Sets the allocated ByteArray's offset to 0 and its limit to the length of the wrapped data
|
||||
*
|
||||
* @param encoding Encoding for strings
|
||||
* @param noAssert Whether to skip assertions of offsets and values. Defaults to ByteArray.DEFAULT_NOASSERT(false)
|
||||
*/
|
||||
static wrap(buffer: I.ByteArray.Wrappable, encoding?: string, noAssert?: boolean): ByteArray;
|
||||
|
||||
/**
|
||||
* Calculates the actual number of bytes required to store a 32bit base 128 variable-length integer
|
||||
*/
|
||||
static calculateVarint32(value: number): number;
|
||||
|
||||
/**
|
||||
* Zigzag encodes a signed 32bit integer so that it can be effectively used with varint encoding
|
||||
*/
|
||||
static zigZagEncode32(n: number): number;
|
||||
|
||||
/**
|
||||
* Decodes a zigzag encoded signed 32bit integer
|
||||
*/
|
||||
static zigZagDecode32(n: number): number;
|
||||
|
||||
/**
|
||||
* Calculates the actual number of bytes required to store a 64bit base 128 variable-length integer
|
||||
*/
|
||||
static calculateVarint64(value: number | string): number;
|
||||
|
||||
/**
|
||||
* Zigzag encodes a signed 64bit integer so that it can be effectively used with varint encoding
|
||||
*/
|
||||
static zigZagEncode64(value: number | string | I.Long): I.Long;
|
||||
|
||||
/**
|
||||
* Decodes a zigzag encoded signed 64bit integer.
|
||||
*/
|
||||
static zigZagDecode64(value: number | string | I.Long): I.Long;
|
||||
|
||||
/**
|
||||
* Calculates the number of UTF8 characters of a string.
|
||||
* JavaScript itself uses UTF-16,
|
||||
* so that a string's length property does not reflect its actual UTF8 size if it contains code points larger than 0xFFFF
|
||||
*/
|
||||
static calculateUTF8Chars(str: string): number;
|
||||
|
||||
/**
|
||||
* Calculates the number of UTF8 bytes of a string.
|
||||
*/
|
||||
static calculateString(str: string): number;
|
||||
|
||||
/**
|
||||
* Decodes a base64 encoded string to a ByteArray
|
||||
*/
|
||||
static fromBase64(str: string): ByteArray;
|
||||
|
||||
/**
|
||||
* Encodes a binary string to base64 like window.btoa does
|
||||
*/
|
||||
static btoa(str: string): string;
|
||||
|
||||
/**
|
||||
* Decodes a base64 encoded string to binary like window.atob does
|
||||
*/
|
||||
static atob(b64: string): string;
|
||||
|
||||
/**
|
||||
* Decodes a binary encoded string, that is using only characters 0x00-0xFF as bytes, to a ByteArray
|
||||
*/
|
||||
static fromBinary(str: string): ByteArray;
|
||||
|
||||
/**
|
||||
* Decodes a hex encoded string with marked offsets to a ByteArray
|
||||
*/
|
||||
static fromDebug(str: string, noAssert?: boolean): ByteArray;
|
||||
|
||||
/**
|
||||
* Decodes a hex encoded string to a ByteArray
|
||||
*/
|
||||
static fromHex(str: string, noAssert?: boolean): ByteArray;
|
||||
|
||||
/**
|
||||
* Decodes an UTF8 encoded string to a ByteArray
|
||||
*/
|
||||
static fromUTF8(str: string, noAssert?: boolean): ByteArray;
|
||||
|
||||
/**
|
||||
* Default initial capacity
|
||||
*/
|
||||
static DEFAULT_CAPACITY: number;
|
||||
|
||||
/**
|
||||
* Default no assertions flag
|
||||
*/
|
||||
static DEFAULT_NOASSERT: boolean;
|
||||
|
||||
/**
|
||||
* Maximum number of bytes required to store a 32bit base 128 variable-length integer
|
||||
*/
|
||||
static MAX_VARINT32_BYTES: number;
|
||||
|
||||
/**
|
||||
* Maximum number of bytes required to store a 64bit base 128 variable-length integer
|
||||
*/
|
||||
static MAX_VARINT64_BYTES: number;
|
||||
|
||||
/**
|
||||
* Metrics representing number of UTF8 characters. Evaluates to `c`.
|
||||
*/
|
||||
static METRICS_CHARS: string;
|
||||
|
||||
/**
|
||||
* Metrics representing number of bytes. Evaluates to `b`.
|
||||
*/
|
||||
static METRICS_BYTES: string;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
declare namespace adone.collection {
|
||||
/**
|
||||
* Represents a Map that has a default values factory object or function.
|
||||
* Each get of non-existent key goes through the factory
|
||||
*/
|
||||
class DefaultMap<K = string, V = any> extends Map<K, V> {
|
||||
constructor(factory?: ((key: K) => V) | { [key: string]: V }, iterable?: Iterable<[K, V]>);
|
||||
}
|
||||
}
|
||||
+61
@@ -0,0 +1,61 @@
|
||||
declare namespace adone.collection {
|
||||
/**
|
||||
* Represents a faster LRU cache but with less functionality
|
||||
*/
|
||||
class FastLRU<K = any, V = any> {
|
||||
/**
|
||||
* @param size Cache size, unlimited by default
|
||||
*/
|
||||
constructor(size?: number, options?: {
|
||||
/**
|
||||
* Function that is called when a value is deleted
|
||||
*/
|
||||
dispose?(key: K, value: V): void
|
||||
});
|
||||
|
||||
/**
|
||||
* The actual size of the cache
|
||||
*/
|
||||
readonly size: number;
|
||||
|
||||
/**
|
||||
* Gets the value by the given key
|
||||
*/
|
||||
get(key: K): V | undefined;
|
||||
|
||||
/**
|
||||
* Sets a new value for the given key
|
||||
*/
|
||||
set(key: K, value: V): void;
|
||||
|
||||
/**
|
||||
* Deletes the given key from the cache
|
||||
*/
|
||||
delete(key: K): boolean;
|
||||
|
||||
/**
|
||||
* Checks whether the cache has an element with the given key
|
||||
*/
|
||||
has(key: K): boolean;
|
||||
|
||||
/**
|
||||
* Returns the keys iterator
|
||||
*/
|
||||
keys(): IterableIterator<K>;
|
||||
|
||||
/**
|
||||
* Returns the values iterator
|
||||
*/
|
||||
values(): IterableIterator<V>;
|
||||
|
||||
/**
|
||||
* Returns the entries iterator
|
||||
*/
|
||||
entries(): IterableIterator<[K, V]>;
|
||||
|
||||
/**
|
||||
* Clears the cache
|
||||
*/
|
||||
clear(): void;
|
||||
}
|
||||
}
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
/// <reference path="./array_set.d.ts" />
|
||||
/// <reference path="./async_queue.d.ts" />
|
||||
/// <reference path="./avl_tree.d.ts" />
|
||||
/// <reference path="./binary_search_tree.d.ts" />
|
||||
/// <reference path="./buffer_list.d.ts" />
|
||||
/// <reference path="./byte_array.d.ts" />
|
||||
/// <reference path="./default_map.d.ts" />
|
||||
/// <reference path="./fast_lru.d.ts" />
|
||||
/// <reference path="./linked_list.d.ts" />
|
||||
/// <reference path="./lru.d.ts" />
|
||||
/// <reference path="./map_cache.d.ts" />
|
||||
/// <reference path="./ns_cache.d.ts" />
|
||||
/// <reference path="./priority_queue.d.ts" />
|
||||
/// <reference path="./queue.d.ts" />
|
||||
/// <reference path="./rb_tree.d.ts" />
|
||||
/// <reference path="./refcounted_cache.d.ts" />
|
||||
/// <reference path="./set.d.ts" />
|
||||
/// <reference path="./stack.d.ts" />
|
||||
/// <reference path="./timedout_map.d.ts" />
|
||||
|
||||
declare namespace adone {
|
||||
/**
|
||||
* Data structures
|
||||
*/
|
||||
namespace collection {
|
||||
//
|
||||
}
|
||||
}
|
||||
+150
@@ -0,0 +1,150 @@
|
||||
declare namespace adone.collection {
|
||||
namespace I.LinkedList {
|
||||
/**
|
||||
* Represents the node of a linked list
|
||||
*/
|
||||
interface Node<T> {
|
||||
/**
|
||||
* The next node
|
||||
*/
|
||||
next?: Node<T>;
|
||||
|
||||
/**
|
||||
* The previous node
|
||||
*/
|
||||
prev?: Node<T>;
|
||||
|
||||
/**
|
||||
* The value this node contains
|
||||
*/
|
||||
value: T;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents a linked list
|
||||
*/
|
||||
class LinkedList<T = any> {
|
||||
/**
|
||||
* The maximum length of the list
|
||||
*/
|
||||
readonly maxLength: number;
|
||||
|
||||
/**
|
||||
* Current length of the list
|
||||
*/
|
||||
readonly length: number;
|
||||
|
||||
/**
|
||||
* Whether the list is autoresizable
|
||||
*/
|
||||
readonly autoresize: boolean;
|
||||
|
||||
/**
|
||||
* @param maxLength Maximum length of the linked list
|
||||
*/
|
||||
constructor(maxLength?: number);
|
||||
|
||||
/**
|
||||
* Whether the list is full
|
||||
*/
|
||||
readonly full: boolean;
|
||||
|
||||
/**
|
||||
* Whether the list is empty
|
||||
*/
|
||||
readonly empty: boolean;
|
||||
|
||||
/**
|
||||
* Resizes the list
|
||||
*/
|
||||
resize(newLength: number): this;
|
||||
|
||||
/**
|
||||
* Adds a new node to the end
|
||||
*
|
||||
* @returns Added node
|
||||
*/
|
||||
push(value: T): I.LinkedList.Node<T>;
|
||||
|
||||
/**
|
||||
* Removes the last node, returns undefined if the list is empty
|
||||
*/
|
||||
pop(): T | undefined;
|
||||
|
||||
/**
|
||||
* Removes the first node, returns undefined if the list is empty
|
||||
*/
|
||||
shift(): T | undefined;
|
||||
|
||||
/**
|
||||
* Inserts a new node at the beginning of the list
|
||||
*
|
||||
* @returns Added node
|
||||
*/
|
||||
unshift(value: T): I.LinkedList.Node<T>;
|
||||
|
||||
/**
|
||||
* Moves the given node to the end of the list
|
||||
*/
|
||||
pushNode(node: I.LinkedList.Node<T>): void;
|
||||
|
||||
/**
|
||||
* Moved the given node to the beginning of the list
|
||||
*/
|
||||
unshiftNode(node: I.LinkedList.Node<T>): void;
|
||||
|
||||
/**
|
||||
* Removes the given node from the list
|
||||
*/
|
||||
removeNode(node: I.LinkedList.Node<T>): void;
|
||||
|
||||
/**
|
||||
* Clears the list
|
||||
*
|
||||
* @param strong Whether to reset all the node's values
|
||||
*/
|
||||
clear(strong?: boolean): void;
|
||||
|
||||
/**
|
||||
* Convers the list to an array
|
||||
*/
|
||||
toArray(): T[];
|
||||
|
||||
/**
|
||||
* The first element of the list
|
||||
*/
|
||||
readonly front: T;
|
||||
|
||||
/**
|
||||
* The last element of the list
|
||||
*/
|
||||
readonly back: T;
|
||||
|
||||
/**
|
||||
* Returns an iterator over the list elements
|
||||
*/
|
||||
[Symbol.iterator](): IterableIterator<T>;
|
||||
|
||||
/**
|
||||
* Returns the next node for the given node
|
||||
*/
|
||||
nextNode(node: I.LinkedList.Node<T>): I.LinkedList.Node<T>;
|
||||
|
||||
/**
|
||||
* Maps this linked list to a new one using the given function
|
||||
*/
|
||||
map<R>(fn: (value: T, index: number) => R): LinkedList<R>;
|
||||
|
||||
/**
|
||||
* Invokes the given callback for each value from the beginning to the end (much faster than for-of).
|
||||
* If the given function returns false it stops iterating.
|
||||
*/
|
||||
forEach(callback: (value: T, index: number) => void | boolean): void;
|
||||
|
||||
/**
|
||||
* Default length of a new created linked list
|
||||
*/
|
||||
static DEFAULT_LENGTH: number;
|
||||
}
|
||||
}
|
||||
+213
@@ -0,0 +1,213 @@
|
||||
declare namespace adone.collection {
|
||||
namespace I.LRU {
|
||||
type LengthCalculator<K, V> = (value: V, key: K) => number;
|
||||
interface ConstructorOptions<K, V> {
|
||||
/**
|
||||
* The maximum size of the cache, checked by applying the length function to all values in the cache.
|
||||
* Default is Infinity
|
||||
*/
|
||||
max?: number;
|
||||
|
||||
/**
|
||||
* Maximum age in ms. Items are not pro-actively pruned out as they age,
|
||||
* but if you try to get an item that is too old,
|
||||
* it'll drop it and return undefined instead of giving it to you
|
||||
*/
|
||||
maxAge?: number;
|
||||
|
||||
/**
|
||||
* Function that is used to calculate the length of stored items
|
||||
*/
|
||||
length?: LengthCalculator<K, V>;
|
||||
|
||||
/**
|
||||
* Function that is called on items when they are dropped from the cache
|
||||
*/
|
||||
dispose?(key: K, value: V): void;
|
||||
|
||||
/**
|
||||
* Whether to return the stale value before deleting it
|
||||
*/
|
||||
stale?: boolean;
|
||||
|
||||
/**
|
||||
* Dispose will only be called when a key falls out of the cache, not when it is overwritten
|
||||
*/
|
||||
noDisposeOnSet?: boolean;
|
||||
}
|
||||
|
||||
interface SerializedEntry<K, V> {
|
||||
/**
|
||||
* key
|
||||
*/
|
||||
key: K;
|
||||
|
||||
/**
|
||||
* value
|
||||
*/
|
||||
value: V;
|
||||
|
||||
/**
|
||||
* when it becomes expired
|
||||
*/
|
||||
e: number;
|
||||
}
|
||||
|
||||
interface Entry<K, V> {
|
||||
/**
|
||||
* key
|
||||
*/
|
||||
key: K;
|
||||
|
||||
/**
|
||||
* value
|
||||
*/
|
||||
value: V;
|
||||
|
||||
/**
|
||||
* entry length
|
||||
*/
|
||||
length: number;
|
||||
|
||||
/**
|
||||
* Timestamp when the entry was created
|
||||
*/
|
||||
now: number;
|
||||
|
||||
/**
|
||||
* Maximum live time
|
||||
*/
|
||||
maxAge: number;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Represent an LRU cache
|
||||
*/
|
||||
class LRU<K = any, V = any> {
|
||||
/**
|
||||
* Creates an LRU cache of the given size
|
||||
*/
|
||||
constructor(max: number);
|
||||
|
||||
/**
|
||||
* Creates an LRU cache with the given options
|
||||
*/
|
||||
constructor(options?: I.LRU.ConstructorOptions<K, V>);
|
||||
|
||||
/**
|
||||
* The length of the cache, setter resizes the cache
|
||||
*/
|
||||
max: number;
|
||||
|
||||
/**
|
||||
* stale setting
|
||||
*/
|
||||
allowStale: boolean;
|
||||
|
||||
/**
|
||||
* maxAge setting
|
||||
*/
|
||||
maxAge: number;
|
||||
|
||||
/**
|
||||
* length setting
|
||||
*/
|
||||
lengthCalculator: I.LRU.LengthCalculator<K, V>;
|
||||
|
||||
/**
|
||||
* Total length of objects in cache taking into account length options function
|
||||
*/
|
||||
readonly length: number;
|
||||
|
||||
/**
|
||||
* Total quantity of objects currently in cache.
|
||||
* Note, that stale items are returned as part of this item count.
|
||||
*/
|
||||
readonly itemCount: number;
|
||||
|
||||
/**
|
||||
* Iterates over all the keys in the cache, in reverse recent-ness order. (ie, less recently used items are iterated over first.)
|
||||
*/
|
||||
rforEach<T = any>(fn: (this: T, value: V, key: K, cache: LRU<K, V>) => void, thisp?: T): void;
|
||||
|
||||
/**
|
||||
* Iterates over all the keys in the cache, in order of recent-ness
|
||||
*/
|
||||
forEach<T = any>(fn: (this: T, value: V, key: K, cache: LRU<K, V>) => void, thisp?: T): void;
|
||||
|
||||
/**
|
||||
* Returns an array of the keys in the cache
|
||||
*/
|
||||
keys(): K[];
|
||||
|
||||
/**
|
||||
* Returns an array of the values in the cache
|
||||
*/
|
||||
values(): V[];
|
||||
|
||||
/**
|
||||
* Clears the cache entirely, throwing away all values
|
||||
*/
|
||||
reset(): void;
|
||||
|
||||
/**
|
||||
* Return an array of the cache entries ready for serialization and usage with 'destinationCache.load(arr)`
|
||||
*/
|
||||
dump(): Array<I.LRU.SerializedEntry<K, V>>;
|
||||
|
||||
/**
|
||||
* Returns an internal lru list of entries
|
||||
*/
|
||||
dumpLru(): LinkedList<I.LRU.Entry<K, V>>;
|
||||
|
||||
/**
|
||||
* @param opts std.util.inspect options
|
||||
*/
|
||||
inspect(opts?: object): string;
|
||||
|
||||
/**
|
||||
* Sets a new value for the given key. Updates the "recently used"-ness of the key
|
||||
*
|
||||
* @param maxAge maxAge option specific for this key
|
||||
* @returns Whether the key was set
|
||||
*/
|
||||
set(key: K, value: V, maxAge?: number): boolean;
|
||||
|
||||
/**
|
||||
* Check if a key is in the cache, without updating the recent-ness or deleting it for being stale
|
||||
*/
|
||||
has(key: K): boolean;
|
||||
|
||||
/**
|
||||
* Gets the value of the given key. Updates the "recently used"-ness of the key
|
||||
*/
|
||||
get(key: K): V | undefined;
|
||||
|
||||
/**
|
||||
* Returns the key value without updating the "recently used"-ness of the key
|
||||
*/
|
||||
peek(key: K): V | undefined;
|
||||
|
||||
/**
|
||||
* Deletes the less recently used element
|
||||
*/
|
||||
pop(): I.LRU.Entry<K, V>;
|
||||
|
||||
/**
|
||||
* Deletes a key out of the cache
|
||||
*/
|
||||
del(key: K): void;
|
||||
|
||||
/**
|
||||
* Loads another cache entries array, obtained with sourceCache.dump(), into the cache.
|
||||
* The destination cache is reset before loading new entries
|
||||
*/
|
||||
load(arr: Array<I.LRU.SerializedEntry<K, V>>): void;
|
||||
|
||||
/**
|
||||
* Manually iterates over the entire cache proactively pruning old entries
|
||||
*/
|
||||
prune(): void;
|
||||
}
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
declare namespace adone.collection {
|
||||
class MapCache<T = any> {
|
||||
has(key: string): boolean;
|
||||
|
||||
get(key: string): T;
|
||||
|
||||
set(key: string, value: T): void;
|
||||
|
||||
delete(key: string): void;
|
||||
|
||||
clear(): void;
|
||||
}
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
declare namespace adone.collection {
|
||||
class NSCache<T = any> {
|
||||
constructor(size: number, namespaces: string[]);
|
||||
|
||||
resize(newSize: number): void;
|
||||
|
||||
set(ns: string, key: string, value: T): void;
|
||||
|
||||
get(ns: string, key: string): T;
|
||||
|
||||
has(ns: string, key: string): boolean;
|
||||
|
||||
delete(ns: string, key: string): void;
|
||||
|
||||
clear(): void;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
declare namespace adone.collection {
|
||||
namespace I.PriorityQueue {
|
||||
interface ConstructorOptions<T> {
|
||||
/**
|
||||
* Function that compares objects.
|
||||
*
|
||||
* Must return a positive value if a > b, a negative if a < b, and zero for equal objects
|
||||
*/
|
||||
compare?(a: T, b: T): number;
|
||||
|
||||
/**
|
||||
* Function that evaluates the priority value by the given objects,
|
||||
* if the returned value > 0, then the first argument has higher priority,
|
||||
* = 0 same priority, < 0 lower priority.
|
||||
* By default the top element is an element that has the highest priority,
|
||||
* the default priority function is equal to the compare function
|
||||
*/
|
||||
priority?(a: T, b: T): number;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents a priority queue
|
||||
*/
|
||||
class PriorityQueue<T = any> {
|
||||
/**
|
||||
* Whether the queue is empty
|
||||
*/
|
||||
readonly empty: boolean;
|
||||
|
||||
/**
|
||||
* The length of the queue
|
||||
*/
|
||||
readonly length: number;
|
||||
|
||||
constructor(options?: I.PriorityQueue.ConstructorOptions<T>);
|
||||
|
||||
/**
|
||||
* Clones the queue
|
||||
*/
|
||||
clone(): PriorityQueue<T>;
|
||||
|
||||
/**
|
||||
* Inserts a new element
|
||||
*/
|
||||
push(x: T): this;
|
||||
|
||||
/**
|
||||
* Removes the top element (that has the highest priority)
|
||||
*/
|
||||
pop(): T | undefined;
|
||||
|
||||
/**
|
||||
* Deletes the given element from the queue
|
||||
*/
|
||||
delete(x: T): this;
|
||||
|
||||
/**
|
||||
* Replaces the top element (pop + push)
|
||||
*/
|
||||
replace(x: T): T;
|
||||
|
||||
/**
|
||||
* Faster push + pop
|
||||
*/
|
||||
pushpop(x: T): T;
|
||||
|
||||
/**
|
||||
* Converts the queue to an array, it works with a clone of the queue, so the original queue is untouched
|
||||
*/
|
||||
toArray(): T[];
|
||||
|
||||
/**
|
||||
* Creates a queue object from the given iterable
|
||||
*/
|
||||
static from<T>(iterable: Iterable<T>, options?: I.PriorityQueue.ConstructorOptions<T>): PriorityQueue<T>;
|
||||
}
|
||||
}
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
declare namespace adone.collection {
|
||||
/**
|
||||
* Represents a queue
|
||||
*/
|
||||
class Queue<S = any, T = S> {
|
||||
/**
|
||||
* Whether the queue is full
|
||||
*/
|
||||
readonly full: boolean;
|
||||
|
||||
/**
|
||||
* The length of the queue
|
||||
*/
|
||||
readonly length: number;
|
||||
|
||||
/**
|
||||
* Whether the queue is empty
|
||||
*/
|
||||
readonly empty: boolean;
|
||||
|
||||
/**
|
||||
* Inserts a new element at the end
|
||||
*/
|
||||
push(x: S): this;
|
||||
|
||||
/**
|
||||
* Removes and returns an element from the beginning
|
||||
*/
|
||||
pop(): T | undefined;
|
||||
}
|
||||
}
|
||||
+184
@@ -0,0 +1,184 @@
|
||||
declare namespace adone.collection {
|
||||
namespace I.RedBlackTree {
|
||||
interface Node<K, V> {
|
||||
/**
|
||||
* The key associated to the node
|
||||
*/
|
||||
key: K;
|
||||
|
||||
/**
|
||||
* The value associated to the node
|
||||
*/
|
||||
value: V;
|
||||
|
||||
/**
|
||||
* The left subtree of the node
|
||||
*/
|
||||
left?: Node<K, V>;
|
||||
|
||||
/**
|
||||
* The right subtree of the node
|
||||
*/
|
||||
right?: Node<K, V>;
|
||||
}
|
||||
|
||||
interface Iterator<K, V> {
|
||||
/**
|
||||
* Checks if the iterator is valid
|
||||
*/
|
||||
readonly valid: boolean;
|
||||
|
||||
/**
|
||||
* The value of the node at the iterator's current position, null if invalid
|
||||
*/
|
||||
readonly node: Node<K, V> | null;
|
||||
|
||||
/**
|
||||
* The key of the item referenced by the iterator, undefined if invalid
|
||||
*/
|
||||
readonly key?: K;
|
||||
|
||||
/**
|
||||
* The value of the item referenced by the iterator, undefined if invalid
|
||||
*/
|
||||
readonly value?: V;
|
||||
|
||||
/**
|
||||
* Returns the position of this iterator in the sequence
|
||||
*/
|
||||
readonly index: number;
|
||||
|
||||
/**
|
||||
* If true, then the iterator is not at the end of the sequence
|
||||
*/
|
||||
readonly hasNext: boolean;
|
||||
|
||||
/**
|
||||
* If true, then the iterator is not at the beginning of the sequence
|
||||
*/
|
||||
readonly hasPrev: boolean;
|
||||
|
||||
/**
|
||||
* The tree associated to the iterator
|
||||
*/
|
||||
tree: RedBlackTree<K, V>;
|
||||
|
||||
/**
|
||||
* Makes a copy of the iterator
|
||||
*/
|
||||
clone(): Iterator<K, V>;
|
||||
|
||||
/**
|
||||
* Removes the item at the position of the iterator and returns a new rb-tree
|
||||
*/
|
||||
remove(): RedBlackTree<K, V>;
|
||||
|
||||
/**
|
||||
* Advances the iterator to the next position
|
||||
*/
|
||||
next(): void;
|
||||
|
||||
/**
|
||||
* Updates the value of the node in the tree at this iterator and returns a new rb-tree
|
||||
*/
|
||||
update(value: V): RedBlackTree<K, V>;
|
||||
|
||||
/**
|
||||
* Moves the iterator backward one element
|
||||
*/
|
||||
prev(): void;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents a fully persistent red-black tree
|
||||
*/
|
||||
class RedBlackTree<K = any, V = any> {
|
||||
/**
|
||||
* The root node of the tree
|
||||
*/
|
||||
root: I.RedBlackTree.Node<K, V>;
|
||||
|
||||
constructor(compare?: (a: K, b: K) => number, root?: RedBlackTree<K, V>);
|
||||
|
||||
/**
|
||||
* A sorted array of all the keys in the tree
|
||||
*/
|
||||
readonly keys: K[];
|
||||
|
||||
/**
|
||||
* An array of all the values in the tree
|
||||
*/
|
||||
readonly values: V[];
|
||||
|
||||
/**
|
||||
* The number of items in the tree
|
||||
*/
|
||||
readonly length: number;
|
||||
|
||||
/**
|
||||
* An iterator pointing to the first element in the tree
|
||||
*/
|
||||
readonly begin: I.RedBlackTree.Iterator<K, V>;
|
||||
|
||||
/**
|
||||
* An iterator pointing to the last element in the tree
|
||||
*/
|
||||
readonly end: I.RedBlackTree.Iterator<K, V>;
|
||||
|
||||
/**
|
||||
* Creates a new tree with the new pair inserted
|
||||
*/
|
||||
insert(key: K, value: V): RedBlackTree<K, V>;
|
||||
|
||||
/**
|
||||
* Walks a visitor function over the nodes of the tree in order
|
||||
*
|
||||
* @param visit A callback that gets executed on each node.
|
||||
* If a truthy value is returned from the visitor, then iteration is stopped.
|
||||
* @param lo An optional start of the range to visit (inclusive)
|
||||
* @param hi An optional end of the range to visit (non-inclusive)
|
||||
*/
|
||||
forEach<T>(visit: (key: K, value: V) => T, lo?: K, hi?: K): T;
|
||||
|
||||
/**
|
||||
* Finds an iterator starting at the given element
|
||||
*/
|
||||
at(idx: number): I.RedBlackTree.Iterator<K, V>;
|
||||
|
||||
/**
|
||||
* Finds the first item in the tree whose key is >= key
|
||||
*/
|
||||
ge(key: K): I.RedBlackTree.Iterator<K, V>;
|
||||
|
||||
/**
|
||||
* Finds the first item in the tree whose key is > key
|
||||
*/
|
||||
gt(key: K): I.RedBlackTree.Iterator<K, V>;
|
||||
|
||||
/**
|
||||
* Finds the first item in the tree whose key is < key
|
||||
*/
|
||||
lt(key: K): I.RedBlackTree.Iterator<K, V>;
|
||||
|
||||
/**
|
||||
* Finds the first item in the tree whose key is <= key
|
||||
*/
|
||||
le(key: K): I.RedBlackTree.Iterator<K, V>;
|
||||
|
||||
/**
|
||||
* Returns an iterator pointing to the first item in the tree with key, otherwise null
|
||||
*/
|
||||
find(key: K): I.RedBlackTree.Iterator<K, V> | null;
|
||||
|
||||
/**
|
||||
* Removes the first item with key in the tree
|
||||
*/
|
||||
remove(key: K): RedBlackTree<K, V>;
|
||||
|
||||
/**
|
||||
* Retrieves the value associated to the given key
|
||||
*/
|
||||
get(key: K): V | undefined;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
declare namespace adone.collection {
|
||||
class RefcountedCache<T = any> extends MapCache<T> {
|
||||
ref(key: string): void;
|
||||
|
||||
unref(key: string): void;
|
||||
|
||||
references(key: string): number;
|
||||
}
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
declare namespace adone.collection {
|
||||
class Set<T = any> {
|
||||
constructor(key?: (x: T) => any);
|
||||
|
||||
has(value: T): boolean;
|
||||
|
||||
add(value: T): void;
|
||||
|
||||
delete(value: T): void;
|
||||
|
||||
get(value: T): T; // ???
|
||||
|
||||
readonly size: number;
|
||||
|
||||
only(): T;
|
||||
}
|
||||
}
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
declare namespace adone.collection {
|
||||
/**
|
||||
* Represents a stack
|
||||
*/
|
||||
class Stack<T = any> {
|
||||
/**
|
||||
* Whether the stack is empty
|
||||
*/
|
||||
readonly empty: boolean;
|
||||
|
||||
/**
|
||||
* The top element of the stack
|
||||
*/
|
||||
readonly top: T;
|
||||
|
||||
/**
|
||||
* Inserts a new element
|
||||
*/
|
||||
push(x: T): this;
|
||||
|
||||
/**
|
||||
* Removes the top element
|
||||
*/
|
||||
pop(): T | undefined;
|
||||
|
||||
/**
|
||||
* Returns an iterator over the values
|
||||
*/
|
||||
[Symbol.iterator](): IterableIterator<T>;
|
||||
|
||||
/**
|
||||
* Creates a stack and pushed all the values from the given iterable object
|
||||
*/
|
||||
static from<T>(iterable: Iterable<T>): Stack<T>;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
declare namespace adone.collection {
|
||||
/**
|
||||
* Represents a Map that keeps keys only for a specified interval of time
|
||||
*/
|
||||
class TimedoutMap<K = any, V = any> extends Map<K, V> {
|
||||
/**
|
||||
* @param timeout maximum age of the keys, 1000 by default
|
||||
* @param callback callback that is called with each key when the timeout is passed
|
||||
*/
|
||||
constructor(timeout?: number, callback?: (key: K) => void);
|
||||
|
||||
/**
|
||||
* Gets the timeout
|
||||
*/
|
||||
getTimeout(): number;
|
||||
|
||||
/**
|
||||
* Sets the timeout
|
||||
*/
|
||||
setTimeout(ms: number): void;
|
||||
|
||||
/**
|
||||
* Iterates over the map and calls the callback for each element
|
||||
*/
|
||||
forEach<T = any>(callback: (this: T, value: V, key: K, cache: this) => void, thisArg?: T): this;
|
||||
|
||||
/**
|
||||
* Deletes the given key
|
||||
*/
|
||||
delete(key: K): boolean;
|
||||
}
|
||||
}
|
||||
Vendored
+597
@@ -0,0 +1,597 @@
|
||||
declare namespace adone.crypto {
|
||||
namespace asn1 {
|
||||
namespace I {
|
||||
interface LocalBaseBlockParams {
|
||||
blockLength?: number;
|
||||
error?: string;
|
||||
warnings?: string[];
|
||||
valueBeforeDecode?: ArrayBuffer;
|
||||
}
|
||||
|
||||
interface JsonLocalBaseBlock {
|
||||
blockName: string;
|
||||
blockLength: number;
|
||||
error: string;
|
||||
warnings: string[];
|
||||
valueBeforeDecode: ArrayBuffer;
|
||||
}
|
||||
|
||||
class LocalBaseBlock {
|
||||
blockLength: number;
|
||||
error: string;
|
||||
warnings: string[];
|
||||
valueBeforeDecode: ArrayBuffer;
|
||||
|
||||
constructor(params?: LocalBaseBlockParams);
|
||||
/**
|
||||
* Aux function, need to get a block name. Need to have it here for inhiritence
|
||||
*/
|
||||
static blockName(): string;
|
||||
/**
|
||||
* Convertion for the block to JSON object
|
||||
*/
|
||||
toJSON(): JsonLocalBaseBlock;
|
||||
}
|
||||
|
||||
interface LocalHexBlockParams extends LocalBaseBlockParams {
|
||||
isHexOnly?: boolean;
|
||||
valueHex?: ArrayBuffer;
|
||||
}
|
||||
|
||||
class LocalHexBlock {
|
||||
isHexOnly: boolean;
|
||||
|
||||
valueHex: ArrayBuffer;
|
||||
|
||||
constructor(params: any);
|
||||
|
||||
/**
|
||||
* Aux function, need to get a block name. Need to have it here for inhiritence
|
||||
*/
|
||||
static blockName(): string;
|
||||
|
||||
/**
|
||||
* Base function for converting block from BER encoded array of bytes
|
||||
*
|
||||
* @param inputBuffer ASN.1 BER encoded array
|
||||
* @param inputOffset Offset in ASN.1 BER encoded array where decoding should be started
|
||||
* @param inputLength Maximum length of array of bytes which can be using in this function
|
||||
*/
|
||||
fromBER(inputBuffer: ArrayBuffer, inputOffset: number, inputLength: number): number;
|
||||
|
||||
/**
|
||||
* Encoding of current ASN.1 block into ASN.1 encoded array (BER rules)
|
||||
*
|
||||
* @param sizeOnly Flag that we need only a size of encoding, not a real array of bytes
|
||||
*/
|
||||
toBER(sizeOnly?: boolean): ArrayBuffer;
|
||||
|
||||
/**
|
||||
* Convertion for the block to JSON object
|
||||
*/
|
||||
toJSON(): any;
|
||||
}
|
||||
|
||||
interface LocalIdentificationBlockParams {
|
||||
idBlock?: LocalHexBlockParams & {
|
||||
isConstructed?: boolean;
|
||||
tagClass?: number;
|
||||
tagNumber?: number;
|
||||
};
|
||||
}
|
||||
|
||||
class LocalIdentificationBlock extends LocalBaseBlock {
|
||||
isConstructed: boolean;
|
||||
|
||||
tagClass: number;
|
||||
|
||||
tagNumber: number;
|
||||
|
||||
constructor(params?: LocalIdentificationBlockParams);
|
||||
|
||||
// ILocalHexBlock implementation
|
||||
isHexOnly: boolean;
|
||||
valueHex: ArrayBuffer;
|
||||
fromBER(inputBuffer: ArrayBuffer, inputOffset: number, inputLength: number): number;
|
||||
toBER(sizeOnly?: boolean): ArrayBuffer;
|
||||
}
|
||||
|
||||
interface LocalLengthBlockParams {
|
||||
lenBlock?: {
|
||||
isIndefiniteForm?: boolean;
|
||||
longFormUsed?: boolean;
|
||||
length: number;
|
||||
};
|
||||
}
|
||||
|
||||
class LocalLengthBlock extends LocalBaseBlock {
|
||||
isIndefiniteForm: boolean;
|
||||
longFormUsed: boolean;
|
||||
length: number;
|
||||
constructor(params?: LocalLengthBlockParams);
|
||||
fromBER(inputBuffer: ArrayBuffer, inputOffset: number, inputLength: number): void;
|
||||
toBER(sizeOnly?: boolean): ArrayBuffer;
|
||||
}
|
||||
|
||||
class LocalValueBlock extends LocalBaseBlock {
|
||||
fromBER(inputBuffer: ArrayBuffer, inputOffset: number, inputLength: number): void;
|
||||
toBER(sizeOnly?: boolean): ArrayBuffer;
|
||||
}
|
||||
|
||||
interface BaseBlockParams extends LocalBaseBlockParams {
|
||||
name?: string;
|
||||
optional?: boolean;
|
||||
primitiveSchema?: object;
|
||||
}
|
||||
|
||||
interface LocalPrimitiveValueBlockParams extends LocalBaseBlockParams {
|
||||
valueHex?: ArrayBuffer;
|
||||
isHexOnly?: boolean;
|
||||
}
|
||||
|
||||
class LocalPrimitiveValueBlock extends LocalValueBlock {
|
||||
valueHex: ArrayBuffer;
|
||||
isHexOnly: boolean;
|
||||
fromBER(inputBuffer: ArrayBuffer, inputOffset: number, inputLength: number): number;
|
||||
toBER(sizeOnly?: boolean): ArrayBuffer;
|
||||
}
|
||||
|
||||
interface LocalConstructedValueBlockParams extends LocalBaseBlockParams {
|
||||
value?: LocalValueBlock;
|
||||
isIndefiniteForm?: boolean;
|
||||
}
|
||||
|
||||
class LocalConstructedValueBlock extends LocalValueBlock {
|
||||
value: LocalValueBlock[];
|
||||
isIndefiniteForm: boolean;
|
||||
fromBER(inputBuffer: ArrayBuffer, inputOffset: number, inputLength: number): number;
|
||||
toBER(sizeOnly?: boolean): ArrayBuffer;
|
||||
}
|
||||
|
||||
class LocalEndOfContentValueBlock extends LocalValueBlock {
|
||||
constructor(params?: LocalBaseBlockParams);
|
||||
fromBER(inputBuffer: ArrayBuffer, inputOffset: number, inputLength: number): number;
|
||||
toBER(sizeOnly?: boolean): ArrayBuffer;
|
||||
}
|
||||
|
||||
interface LocalBooleanValueBlockParams extends LocalBaseBlockParams {
|
||||
value?: boolean;
|
||||
isHexOnly?: boolean;
|
||||
valueHex?: ArrayBuffer;
|
||||
}
|
||||
|
||||
class LocalBooleanValueBlock extends LocalValueBlock {
|
||||
value: boolean;
|
||||
isHexOnly: boolean;
|
||||
valueHex: ArrayBuffer;
|
||||
fromBER(inputBuffer: ArrayBuffer, inputOffset: number, inputLength: number): number;
|
||||
toBER(sizeOnly?: boolean): ArrayBuffer;
|
||||
}
|
||||
|
||||
interface LocalOctetStringValueBlockParams extends LocalConstructedValueBlockParams, LocalHexBlockParams {
|
||||
isConstructed?: boolean;
|
||||
}
|
||||
|
||||
class LocalOctetStringValueBlock extends LocalConstructedValueBlock {
|
||||
isConstructed: boolean;
|
||||
isHexOnly: boolean;
|
||||
valueHex: ArrayBuffer;
|
||||
|
||||
constructor(params?: LocalOctetStringValueBlockParams);
|
||||
}
|
||||
|
||||
interface LocalBitStringValueBlockParams extends LocalConstructedValueBlockParams, LocalHexBlockParams {
|
||||
unusedBits?: number;
|
||||
isConstructed?: boolean;
|
||||
blockLength?: number;
|
||||
}
|
||||
|
||||
class LocalBitStringValueBlock extends LocalConstructedValueBlock implements LocalHexBlock {
|
||||
unusedBits: number;
|
||||
isConstructed: boolean;
|
||||
blockLength: number;
|
||||
isHexOnly: boolean;
|
||||
valueHex: ArrayBuffer;
|
||||
constructor(params?: LocalBitStringValueBlockParams);
|
||||
}
|
||||
|
||||
interface LocalIntegerValueBlockParams extends LocalBaseBlockParams, LocalHexBlockParams {
|
||||
}
|
||||
|
||||
class LocalIntegerValueBlock extends LocalValueBlock implements LocalHexBlock {
|
||||
valueDec: number;
|
||||
isHexOnly: boolean;
|
||||
valueHex: ArrayBuffer;
|
||||
constructor(params?: LocalIntegerValueBlockParams);
|
||||
fromBER(inputBuffer: ArrayBuffer, inputOffset: number, inputLength: number): number;
|
||||
toBER(sizeOnly?: boolean): ArrayBuffer;
|
||||
/**
|
||||
* Base function for converting block from DER encoded array of bytes
|
||||
*
|
||||
* @param inputBuffer ASN.1 DER encoded array
|
||||
* @param inputOffset Offset in ASN.1 DER encoded array where decoding should be started
|
||||
* @param inputLength Maximum length of array of bytes which can be using in this function
|
||||
* @param expectedLength Expected length of converted "valueHex" buffer
|
||||
*/
|
||||
fromDER(inputBuffer: ArrayBuffer, inputOffset: number, inputLength: number, expectedLength?: number): number;
|
||||
/**
|
||||
* Encoding of current ASN.1 block into ASN.1 encoded array (DER rules)
|
||||
*
|
||||
* @param sizeOnly Flag that we need only a size of encoding, not a real array of bytes
|
||||
*/
|
||||
toDER(sizeOnly?: boolean): ArrayBuffer;
|
||||
}
|
||||
|
||||
interface IntegerParams {
|
||||
value?: number;
|
||||
}
|
||||
|
||||
interface LocalSidValueBlockParams extends LocalBaseBlockParams, LocalHexBlockParams {
|
||||
valueDec?: number;
|
||||
isFirstSid?: boolean;
|
||||
}
|
||||
|
||||
class LocalSidValueBlock extends LocalBaseBlock implements LocalHexBlock {
|
||||
valueDec: number;
|
||||
isFirstSid: boolean;
|
||||
isHexOnly: boolean;
|
||||
valueHex: ArrayBuffer;
|
||||
constructor(params?: LocalSidValueBlockParams);
|
||||
fromBER(inputBuffer: ArrayBuffer, inputOffset: number, inputLength: number): number;
|
||||
toBER(sizeOnly?: boolean): ArrayBuffer;
|
||||
toString(): string;
|
||||
}
|
||||
|
||||
interface LocalObjectIdentifierValueBlockParams extends LocalBaseBlockParams {
|
||||
value?: string;
|
||||
}
|
||||
|
||||
class LocalObjectIdentifierValueBlock extends LocalValueBlock {
|
||||
constructor(params?: LocalObjectIdentifierValueBlockParams);
|
||||
|
||||
/**
|
||||
* Create "LocalObjectIdentifierValueBlock" class from string
|
||||
*
|
||||
* @param string Input string to convert from
|
||||
*/
|
||||
fromString(data: string): boolean;
|
||||
/**
|
||||
* Converts "LocalObjectIdentifierValueBlock" class to string
|
||||
*/
|
||||
toString(): string;
|
||||
}
|
||||
|
||||
interface LocalUtf8StringValueBlockParams extends LocalBaseBlockParams, LocalHexBlock {
|
||||
}
|
||||
|
||||
class LocalUtf8StringValueBlock extends LocalBaseBlock implements LocalHexBlock {
|
||||
isHexOnly: boolean;
|
||||
valueHex: ArrayBuffer;
|
||||
constructor(params?: LocalSidValueBlockParams);
|
||||
fromBER(inputBuffer: ArrayBuffer, inputOffset: number, inputLength: number): number;
|
||||
toBER(sizeOnly?: boolean): ArrayBuffer;
|
||||
toString(): string;
|
||||
}
|
||||
|
||||
interface Utf8StringParams {
|
||||
value?: string;
|
||||
}
|
||||
|
||||
interface LocalBmpStringValueBlockParams extends LocalHexBlockParams, LocalBaseBlockParams {
|
||||
}
|
||||
|
||||
class LocalBmpStringValueBlock extends LocalBaseBlock implements LocalHexBlock {
|
||||
value: string;
|
||||
isHexOnly: boolean;
|
||||
valueHex: ArrayBuffer;
|
||||
|
||||
constructor(params?: LocalBmpStringValueBlockParams);
|
||||
|
||||
fromBER(inputBuffer: ArrayBuffer, inputOffset: number, inputLength: number): number;
|
||||
toBER(sizeOnly?: boolean): ArrayBuffer;
|
||||
}
|
||||
|
||||
interface LocalUniversalStringValueParams extends LocalHexBlockParams, LocalBaseBlockParams {
|
||||
}
|
||||
|
||||
class LocalUniversalStringValueBlock extends LocalBaseBlock implements LocalHexBlock {
|
||||
value: string;
|
||||
isHexOnly: boolean;
|
||||
valueHex: ArrayBuffer;
|
||||
|
||||
constructor(params?: LocalUniversalStringValueParams);
|
||||
|
||||
fromBER(inputBuffer: ArrayBuffer, inputOffset: number, inputLength: number): number;
|
||||
toBER(sizeOnly?: boolean): ArrayBuffer;
|
||||
}
|
||||
|
||||
interface LocalSimpleLocalSimpleStringValueBlockParams extends LocalHexBlockParams, LocalBaseBlockParams {
|
||||
}
|
||||
|
||||
class LocalSimpleLocalSimpleStringValueBlock extends LocalBaseBlock implements LocalHexBlock {
|
||||
value: string;
|
||||
isHexOnly: boolean;
|
||||
valueHex: ArrayBuffer;
|
||||
|
||||
constructor(params?: LocalSimpleLocalSimpleStringValueBlockParams);
|
||||
|
||||
fromBER(inputBuffer: ArrayBuffer, inputOffset: number, inputLength: number): number;
|
||||
toBER(sizeOnly?: boolean): ArrayBuffer;
|
||||
}
|
||||
|
||||
interface LocalSimpleStringBlockParams {
|
||||
value?: string;
|
||||
}
|
||||
|
||||
class LocalSimpleStringBlock extends BaseBlock<LocalSimpleLocalSimpleStringValueBlock> {
|
||||
constructor(params?: LocalSimpleStringBlockParams);
|
||||
/**
|
||||
* Function converting ArrayBuffer into ASN.1 internal string
|
||||
*
|
||||
* @param inputBuffer ASN.1 BER encoded array
|
||||
*/
|
||||
fromBuffer(inputBuffer: ArrayBuffer): void;
|
||||
/**
|
||||
* Function converting JavaScript string into ASN.1 internal class
|
||||
*
|
||||
* @param inputString ASN.1 BER encoded array
|
||||
*/
|
||||
fromString(inputString: string): void;
|
||||
}
|
||||
|
||||
interface BmpStringParams {
|
||||
value?: string;
|
||||
}
|
||||
|
||||
interface UniversalStringParams {
|
||||
value?: string;
|
||||
}
|
||||
|
||||
interface UTCTimeParams extends LocalSimpleLocalSimpleStringValueBlockParams {
|
||||
value?: string;
|
||||
valueDate?: Date;
|
||||
}
|
||||
|
||||
interface ChoiceParams {
|
||||
value?: LocalValueBlock[];
|
||||
optional?: boolean;
|
||||
}
|
||||
|
||||
interface AnyParams {
|
||||
name?: string;
|
||||
optional?: boolean;
|
||||
}
|
||||
|
||||
interface RepeatedParams {
|
||||
name?: string;
|
||||
optional?: boolean;
|
||||
value?: Any;
|
||||
local?: boolean;
|
||||
}
|
||||
|
||||
interface RawDataParams {
|
||||
data?: ArrayBuffer;
|
||||
}
|
||||
}
|
||||
|
||||
class BaseBlock<T extends I.LocalValueBlock> extends I.LocalBaseBlock {
|
||||
constructor(parameters?: I.BaseBlockParams, valueBlockType?: typeof I.LocalValueBlock);
|
||||
idBlock: I.LocalIdentificationBlock;
|
||||
lenBlock: I.LocalLengthBlock;
|
||||
valueBlock: T;
|
||||
fromBER(inputBuffer: ArrayBuffer, inputOffset: number, inputLength: number): number;
|
||||
toBER(sizeOnly?: boolean): ArrayBuffer;
|
||||
}
|
||||
|
||||
class Primitive extends BaseBlock<I.LocalPrimitiveValueBlock> {
|
||||
}
|
||||
|
||||
class Constructed extends BaseBlock<I.LocalConstructedValueBlock> { }
|
||||
|
||||
class EndOfContent extends BaseBlock<I.LocalEndOfContentValueBlock> { }
|
||||
|
||||
class Boolean extends BaseBlock<I.LocalBooleanValueBlock> { }
|
||||
|
||||
class Sequence extends Constructed { }
|
||||
|
||||
class Set extends Constructed { }
|
||||
|
||||
class Null extends BaseBlock<I.LocalValueBlock> { }
|
||||
|
||||
class OctetString extends BaseBlock<I.LocalOctetStringValueBlock> {
|
||||
constructor(params?: I.LocalOctetStringValueBlockParams);
|
||||
/**
|
||||
* Checking that two OCTETSTRINGs are equal
|
||||
*/
|
||||
isEqual(octetString: OctetString): boolean;
|
||||
}
|
||||
|
||||
class BitString extends BaseBlock<I.LocalBitStringValueBlock> {
|
||||
constructor(params?: I.LocalBitStringValueBlockParams);
|
||||
/**
|
||||
* Checking that two BITSTRINGs are equal
|
||||
* @param bitString
|
||||
*/
|
||||
isEqual(bitString: BitString): boolean;
|
||||
}
|
||||
|
||||
class Integer extends BaseBlock<I.LocalIntegerValueBlock> {
|
||||
constructor(params?: I.IntegerParams)
|
||||
/**
|
||||
* Compare two Integer object, or Integer and ArrayBuffer objects
|
||||
*/
|
||||
isEqual(otherValue: Integer | ArrayBuffer): boolean;
|
||||
/**
|
||||
* Convert current Integer value from BER into DER format
|
||||
*/
|
||||
convertToDER(): Integer;
|
||||
/**
|
||||
* Convert current Integer value from DER to BER format
|
||||
*/
|
||||
convertFromDER(): Integer;
|
||||
}
|
||||
|
||||
class Enumerated extends Integer { }
|
||||
|
||||
class ObjectIdentifier extends BaseBlock<I.LocalObjectIdentifierValueBlock> {
|
||||
constructor(params?: I.LocalObjectIdentifierValueBlockParams);
|
||||
}
|
||||
|
||||
class Utf8String extends BaseBlock<I.LocalUtf8StringValueBlock> {
|
||||
constructor(params?: I.Utf8StringParams);
|
||||
/**
|
||||
* Function converting ArrayBuffer into ASN.1 internal string
|
||||
*
|
||||
* @param inputBuffer ASN.1 BER encoded array
|
||||
*/
|
||||
fromBuffer(inputBuffer: ArrayBuffer): void;
|
||||
/**
|
||||
* Function converting JavaScript string into ASN.1 internal class
|
||||
*
|
||||
* @param inputString ASN.1 BER encoded array
|
||||
*/
|
||||
fromString(inputString: string): void;
|
||||
}
|
||||
|
||||
class BmpString extends BaseBlock<I.LocalBmpStringValueBlock> {
|
||||
constructor(params?: I.BmpStringParams);
|
||||
/**
|
||||
* Function converting ArrayBuffer into ASN.1 internal string
|
||||
*
|
||||
* @param inputBuffer ASN.1 BER encoded array
|
||||
*/
|
||||
fromBuffer(inputBuffer: ArrayBuffer): void;
|
||||
/**
|
||||
* Function converting JavaScript string into ASN.1 internal class
|
||||
*
|
||||
* @param inputString ASN.1 BER encoded array
|
||||
*/
|
||||
fromString(inputString: string): void;
|
||||
}
|
||||
|
||||
class UniversalString extends BaseBlock<I.LocalUniversalStringValueBlock> {
|
||||
constructor(params?: I.UniversalStringParams);
|
||||
/**
|
||||
* Function converting ArrayBuffer into ASN.1 internal string
|
||||
*
|
||||
* @param inputBuffer ASN.1 BER encoded array
|
||||
*/
|
||||
fromBuffer(inputBuffer: ArrayBuffer): void;
|
||||
/**
|
||||
* Function converting JavaScript string into ASN.1 internal class
|
||||
*
|
||||
* @param inputString ASN.1 BER encoded array
|
||||
*/
|
||||
fromString(inputString: string): void;
|
||||
}
|
||||
|
||||
class NumericString extends I.LocalSimpleStringBlock { }
|
||||
|
||||
class PrintableString extends I.LocalSimpleStringBlock { }
|
||||
|
||||
class TeletexString extends I.LocalSimpleStringBlock { }
|
||||
|
||||
class VideotexString extends I.LocalSimpleStringBlock { }
|
||||
|
||||
class IA5String extends I.LocalSimpleStringBlock { }
|
||||
|
||||
class GraphicString extends I.LocalSimpleStringBlock { }
|
||||
|
||||
class VisibleString extends I.LocalSimpleStringBlock { }
|
||||
|
||||
class GeneralString extends I.LocalSimpleStringBlock { }
|
||||
|
||||
class CharacterString extends I.LocalSimpleStringBlock { }
|
||||
|
||||
class UTCTime extends VisibleString {
|
||||
year: number;
|
||||
month: number;
|
||||
day: number;
|
||||
hour: number;
|
||||
minute: number;
|
||||
second: number;
|
||||
constructor(params?: I.UTCTimeParams);
|
||||
/**
|
||||
* Function converting ASN.1 internal string into ArrayBuffer
|
||||
*/
|
||||
toBuffer(): ArrayBuffer;
|
||||
/**
|
||||
* Function converting "Date" object into ASN.1 internal string
|
||||
*
|
||||
* @param inputDate JavaScript "Date" object
|
||||
*/
|
||||
fromDate(inputDate: Date): void;
|
||||
/**
|
||||
* Function converting ASN.1 internal string into "Date" object
|
||||
*/
|
||||
toDate(): Date;
|
||||
}
|
||||
|
||||
class GeneralizedTime extends UTCTime {
|
||||
millisecond: number;
|
||||
}
|
||||
|
||||
class DATE extends Utf8String { }
|
||||
|
||||
class TimeOfDay extends Utf8String { }
|
||||
|
||||
class DateTime extends Utf8String { }
|
||||
|
||||
class Duration extends Utf8String { }
|
||||
|
||||
class TIME extends Utf8String { }
|
||||
|
||||
class Choice {
|
||||
value: I.LocalValueBlock[];
|
||||
optional: boolean;
|
||||
constructor(params?: I.ChoiceParams);
|
||||
}
|
||||
|
||||
class Any {
|
||||
name: string;
|
||||
optional: boolean;
|
||||
constructor(params?: I.AnyParams);
|
||||
}
|
||||
|
||||
class Repeated {
|
||||
name: string;
|
||||
optional: boolean;
|
||||
value: Any;
|
||||
local: boolean;
|
||||
constructor(params?: I.RepeatedParams);
|
||||
}
|
||||
|
||||
class RawData {
|
||||
data: ArrayBuffer;
|
||||
|
||||
constructor(params?: I.RawDataParams);
|
||||
|
||||
fromBER(inputBuffer: ArrayBuffer, inputOffset: number, inputLength: number): number;
|
||||
toBER(sizeOnly?: boolean): ArrayBuffer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Major function for decoding ASN.1 BER array into internal library structuries
|
||||
*
|
||||
* @param inputBuffer ASN.1 BER encoded array of bytes
|
||||
*/
|
||||
function fromBER(inputBuffer: ArrayBuffer): { offset: number; result: I.LocalBaseBlock };
|
||||
|
||||
/**
|
||||
* Compare of two ASN.1 object trees
|
||||
*
|
||||
* @param root Root of input ASN.1 object tree
|
||||
* @param inputData Input ASN.1 object tree
|
||||
* @param inputSchema Input ASN.1 schema to compare with
|
||||
*/
|
||||
function compareSchema(root: any, inputData: any, inputSchema: any): { verified: boolean, result?: any };
|
||||
|
||||
/**
|
||||
* ASN.1 schema verification for ArrayBuffer data
|
||||
*
|
||||
* @param inputBuffer Input BER-encoded ASN.1 data
|
||||
* @param inputSchema Input ASN.1 schema to verify against to
|
||||
*/
|
||||
function verifySchema(inputBuffer: ArrayBuffer, inputSchema: any): { verified: boolean, result?: any };
|
||||
}
|
||||
}
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
declare namespace adone.crypto {
|
||||
namespace ed25519 {
|
||||
const publicKeyLength: number;
|
||||
|
||||
const privateKeyLength: number;
|
||||
|
||||
namespace I {
|
||||
interface KeyPair {
|
||||
publicKey: Buffer;
|
||||
privateKey: Buffer;
|
||||
}
|
||||
}
|
||||
|
||||
function generateKeyPair(seed: Buffer): I.KeyPair;
|
||||
|
||||
function sign(message: Buffer, seed: Buffer | I.KeyPair): Buffer;
|
||||
|
||||
function verify(message: Buffer, signature: Buffer, publicKey: Buffer): boolean;
|
||||
}
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
/// <reference path="./asn1.d.ts" />
|
||||
/// <reference path="./ed25519.d.ts" />
|
||||
/// <reference path="./secp256k1.d.ts" />
|
||||
|
||||
declare namespace adone {
|
||||
namespace crypto {
|
||||
//
|
||||
}
|
||||
}
|
||||
+127
@@ -0,0 +1,127 @@
|
||||
declare namespace adone.crypto {
|
||||
namespace secp256k1 {
|
||||
/**
|
||||
* Verifies an ECDSA privateKey
|
||||
*/
|
||||
function privateKeyVerify(privateKey: Buffer): boolean;
|
||||
|
||||
/**
|
||||
* Exports a privateKey in DER format
|
||||
*/
|
||||
function privateKeyExport(privateKey: Buffer, compressed?: boolean): Buffer;
|
||||
|
||||
/**
|
||||
* Imports a privateKey in DER format
|
||||
*/
|
||||
function privateKeyImport(privateKey: Buffer): Buffer;
|
||||
|
||||
/**
|
||||
* Negates a privateKey by subtracting it from the order of the curve's base point
|
||||
*/
|
||||
function privateKeyNegate(privateKey: Buffer): Buffer;
|
||||
|
||||
/**
|
||||
* Computes the inverse of a privateKey (modulo the order of the curve's base point)
|
||||
*/
|
||||
function privateKeyModInverse(privateKey: Buffer): Buffer;
|
||||
|
||||
/**
|
||||
* Tweaks a privateKey by adding tweak to it
|
||||
*/
|
||||
function privateKeyTweakAdd(privateKey: Buffer, tweak: Buffer): Buffer;
|
||||
|
||||
/**
|
||||
* Tweaks a privateKey by multiplying it by a tweak
|
||||
*/
|
||||
function privateKeyTweakMul(privateKey: Buffer, tweak: Buffer): Buffer;
|
||||
|
||||
/**
|
||||
* Computes the public key for a privateKey
|
||||
*/
|
||||
function publicKeyCreate(privateKey: Buffer, compressed?: boolean): Buffer;
|
||||
|
||||
/**
|
||||
* Converts a publicKey to compressed or uncompressed form
|
||||
*/
|
||||
function publicKeyConvert(publicKey: Buffer, compressed?: boolean): Buffer;
|
||||
|
||||
/**
|
||||
* Verifies an ECDSA publicKey
|
||||
*/
|
||||
function publicKeyVerify(publicKey: Buffer): boolean;
|
||||
|
||||
/**
|
||||
* Tweaks a publicKey by adding tweak times the generator to it
|
||||
*/
|
||||
function publicKeyTweakAdd(publicKey: Buffer, tweak: Buffer, compressed?: boolean): Buffer;
|
||||
|
||||
/**
|
||||
* Tweaks a publicKey by multiplying it by a tweak value
|
||||
*/
|
||||
function publicKeyTweakMul(publicKey: Buffer, tweak: Buffer, compressed?: boolean): Buffer;
|
||||
|
||||
/**
|
||||
* Adds a given publicKeys together
|
||||
*/
|
||||
function publicKeyCombine(publicKeys: Buffer[], compressed?: boolean): Buffer;
|
||||
|
||||
/**
|
||||
* Converts a signature to a normalized lower-S form
|
||||
*/
|
||||
function signatureNormalize(signature: Buffer): Buffer;
|
||||
|
||||
/**
|
||||
* Serializes an ECDSA signature in DER format
|
||||
*/
|
||||
function signatureExport(signature: Buffer): Buffer;
|
||||
|
||||
/**
|
||||
* Parse a DER ECDSA signature (follow by BIP66)
|
||||
*/
|
||||
function signatureImport(signature: Buffer): Buffer;
|
||||
|
||||
/**
|
||||
* Same as signatureImport but not follow by BIP66
|
||||
*/
|
||||
function signatureImportLax(signature: Buffer): Buffer;
|
||||
|
||||
namespace I {
|
||||
interface SignOptions {
|
||||
noncefn?: (message: Buffer, privateKey: Buffer, algo: Buffer, data: Buffer, attempt: number) => Buffer;
|
||||
data?: Buffer | null;
|
||||
}
|
||||
|
||||
interface SignResult {
|
||||
signature: Buffer;
|
||||
recovery: number;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an ECDSA signature. Always return low-S signature.
|
||||
*/
|
||||
function sign(message: Buffer, privateKey: Buffer, options?: I.SignOptions): I.SignResult;
|
||||
|
||||
/**
|
||||
* Verifies an ECDSA signature
|
||||
*
|
||||
* Note: return false for high signatures!
|
||||
*/
|
||||
function verify(message: Buffer, signature: Buffer, publicKey: Buffer): boolean;
|
||||
|
||||
/**
|
||||
* Recovers an ECDSA public key from a signature
|
||||
*/
|
||||
function recover(message: Buffer, signature: Buffer, recovery: number, compressed?: boolean): Buffer;
|
||||
|
||||
/**
|
||||
* Computes an EC Diffie-Hellman secret and applied sha256 to compressed public key
|
||||
*/
|
||||
function ecdh(publicKey: Buffer, privateKey: Buffer): Buffer;
|
||||
|
||||
/**
|
||||
* Computes an EC Diffie-Hellman secret and return public key as result
|
||||
*/
|
||||
function ecdhUnsafe(publicKey: Buffer, privateKey: Buffer, compressed?: boolean): Buffer;
|
||||
}
|
||||
}
|
||||
Vendored
+178
@@ -1050,5 +1050,183 @@ declare namespace adone {
|
||||
*/
|
||||
function decode(buf: Buffer, options?: I.DeserializeOptions): any;
|
||||
}
|
||||
|
||||
namespace protobuf {
|
||||
namespace schema {
|
||||
namespace I {
|
||||
interface Field {
|
||||
name: string | null;
|
||||
type: string | null;
|
||||
tag: number;
|
||||
map: {
|
||||
from: string;
|
||||
to: string;
|
||||
} | null;
|
||||
oneof: string | null;
|
||||
required: boolean;
|
||||
repeated: boolean;
|
||||
options: object;
|
||||
}
|
||||
|
||||
interface Enum {
|
||||
name: string;
|
||||
values: object;
|
||||
options: object;
|
||||
}
|
||||
|
||||
interface Extend {
|
||||
name: string;
|
||||
message: Message;
|
||||
}
|
||||
|
||||
interface Message {
|
||||
name: string;
|
||||
enums: Enum[];
|
||||
extends: Extend[];
|
||||
messages: Message[];
|
||||
fields: Field[];
|
||||
extensions: {
|
||||
from: number,
|
||||
to: number
|
||||
} | null;
|
||||
}
|
||||
|
||||
interface RPCMethod {
|
||||
name: string;
|
||||
input_type: string | null;
|
||||
output_type: string | null;
|
||||
client_streaming: boolean;
|
||||
server_streaming: boolean;
|
||||
options: object;
|
||||
}
|
||||
|
||||
interface Service {
|
||||
name: string;
|
||||
methods: RPCMethod[];
|
||||
options: object;
|
||||
}
|
||||
|
||||
interface Schema {
|
||||
syntax: any; // ??
|
||||
package: string | null;
|
||||
imports: string[];
|
||||
enums: Enum[];
|
||||
messages: Message[];
|
||||
options: object;
|
||||
extends: Extend[];
|
||||
services?: Service[];
|
||||
}
|
||||
}
|
||||
|
||||
function parse(buf: Buffer | string): I.Schema;
|
||||
|
||||
function stringify(schema: object): string;
|
||||
}
|
||||
|
||||
function create(proto: Buffer | string | object, opts?: object): object;
|
||||
}
|
||||
|
||||
namespace base32 {
|
||||
function charmap<T = object>(alphabet: string, mappings?: T): T;
|
||||
|
||||
namespace I {
|
||||
interface Spec {
|
||||
alphabet: string;
|
||||
charmap: {
|
||||
[c: string]: number;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
const rfc4648: I.Spec;
|
||||
|
||||
const crockford: I.Spec;
|
||||
|
||||
const base32hex: I.Spec;
|
||||
|
||||
namespace I {
|
||||
interface DecoderOptions {
|
||||
type: "rfc4648" | "crockford" | "base32hex";
|
||||
charmap?: object;
|
||||
}
|
||||
|
||||
interface EncoderOptions {
|
||||
type: "rfc4648" | "crockford" | "base32hex";
|
||||
alphabet?: string;
|
||||
}
|
||||
}
|
||||
|
||||
class Decoder {
|
||||
constructor(options?: I.DecoderOptions);
|
||||
|
||||
write(str: string): this;
|
||||
|
||||
finalize(str?: string): Buffer;
|
||||
}
|
||||
|
||||
class Encoder {
|
||||
constructor(options?: I.EncoderOptions);
|
||||
|
||||
write(buf: Buffer): this;
|
||||
|
||||
finalize(buf?: Buffer): string;
|
||||
}
|
||||
|
||||
function encode(buf: Buffer, options?: I.EncoderOptions): string;
|
||||
|
||||
function decode(str: string, options?: I.DecoderOptions): Buffer;
|
||||
}
|
||||
|
||||
namespace I {
|
||||
interface BaseX {
|
||||
encode(buf: Buffer): string;
|
||||
|
||||
decode(str: string): Buffer;
|
||||
|
||||
decodeUnsafe(str: string): Buffer;
|
||||
}
|
||||
}
|
||||
|
||||
function basex(alphabet: string): I.BaseX;
|
||||
|
||||
const base58: I.BaseX;
|
||||
|
||||
namespace base64url {
|
||||
function unescape(str: string): string;
|
||||
|
||||
function escape(str: string): string;
|
||||
|
||||
namespace I {
|
||||
interface EncodeOptions {
|
||||
encoding?: string;
|
||||
}
|
||||
|
||||
interface DecodeOptions {
|
||||
encoding?: string;
|
||||
buffer?: boolean;
|
||||
}
|
||||
}
|
||||
|
||||
function encode(str: Buffer | string, options?: I.EncodeOptions): string;
|
||||
|
||||
function decode(str: string, options: I.DecodeOptions & { buffer: true }): Buffer;
|
||||
function decode(str: string, options?: I.DecodeOptions): string;
|
||||
}
|
||||
|
||||
namespace varint {
|
||||
function encode<T = any>(num: number, out?: T[], offset?: number): T[];
|
||||
|
||||
function decode(buf: Buffer, offset?: number): number;
|
||||
|
||||
function encodingLength(value: number): number;
|
||||
}
|
||||
|
||||
namespace varintSigned {
|
||||
function encode<T = any>(num: number, out?: T[], offset?: number): T[];
|
||||
|
||||
function decode(buf: Buffer, offset?: number): number;
|
||||
|
||||
function encodingLength(value: number): number;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Vendored
+337
@@ -0,0 +1,337 @@
|
||||
declare namespace adone {
|
||||
namespace fake {
|
||||
namespace I {
|
||||
interface Card {
|
||||
name: string;
|
||||
username: string;
|
||||
email: string;
|
||||
address: FullAddress;
|
||||
phone: string;
|
||||
website: string;
|
||||
company: Company;
|
||||
posts: Post[];
|
||||
accountHistory: string[];
|
||||
}
|
||||
|
||||
interface FullAddress {
|
||||
streetA: string;
|
||||
streetB: string;
|
||||
streetC: string;
|
||||
streetD: string;
|
||||
city: string;
|
||||
state: string;
|
||||
county: string;
|
||||
zipcode: string;
|
||||
geo: Geo;
|
||||
}
|
||||
|
||||
interface Geo {
|
||||
lat: string;
|
||||
lng: string;
|
||||
}
|
||||
|
||||
interface Company {
|
||||
name: string;
|
||||
catchPhrase: string;
|
||||
bs: string;
|
||||
}
|
||||
|
||||
interface Post {
|
||||
words: string;
|
||||
sentence: string;
|
||||
sentences: string;
|
||||
paragraph: string;
|
||||
}
|
||||
|
||||
interface ContextualCard {
|
||||
name: string;
|
||||
username: string;
|
||||
email: string;
|
||||
dob: Date;
|
||||
phone: string;
|
||||
address: Address;
|
||||
website: string;
|
||||
company: Company;
|
||||
}
|
||||
|
||||
interface Address {
|
||||
street: string;
|
||||
suite: string;
|
||||
city: string;
|
||||
state: string;
|
||||
zipcode: string;
|
||||
geo: Geo;
|
||||
}
|
||||
|
||||
interface UserCard {
|
||||
name: string;
|
||||
username: string;
|
||||
email: string;
|
||||
address: Address;
|
||||
phone: string;
|
||||
website: string;
|
||||
company: Company;
|
||||
}
|
||||
|
||||
interface Transaction {
|
||||
amount: string;
|
||||
date: Date;
|
||||
business: string;
|
||||
name: string;
|
||||
type: string;
|
||||
account: string;
|
||||
}
|
||||
}
|
||||
|
||||
namespace address {
|
||||
function zipCode(format?: string): string;
|
||||
function city(format?: number): string;
|
||||
function cityPrefix(): string;
|
||||
function citySuffix(): string;
|
||||
function streetName(): string;
|
||||
function streetAddress(useFullAddress?: boolean): string;
|
||||
function streetSuffix(): string;
|
||||
function streetPrefix(): string;
|
||||
function secondaryAddress(): string;
|
||||
function county(): string;
|
||||
function country(): string;
|
||||
function countryCode(): string;
|
||||
function state(useAbbr?: boolean): string;
|
||||
function stateAbbr(): string;
|
||||
function latitude(): string;
|
||||
function longitude(): string;
|
||||
}
|
||||
|
||||
namespace commerce {
|
||||
function color(): string;
|
||||
function department(): string;
|
||||
function productName(): string;
|
||||
function price(min?: number, max?: number, dec?: number, symbol?: string): string;
|
||||
function productAdjective(): string;
|
||||
function productMaterial(): string;
|
||||
function product(): string;
|
||||
}
|
||||
|
||||
namespace company {
|
||||
function suffixes(): string[];
|
||||
function companyName(format?: number): string;
|
||||
function companySuffix(): string;
|
||||
function catchPhrase(): string;
|
||||
function bs(): string;
|
||||
function catchPhraseAdjective(): string;
|
||||
function catchPhraseDescriptor(): string;
|
||||
function catchPhraseNoun(): string;
|
||||
function bsAdjective(): string;
|
||||
function bsBuzz(): string;
|
||||
function bsNoun(): string;
|
||||
}
|
||||
|
||||
namespace database {
|
||||
function column(): string;
|
||||
function type(): string;
|
||||
function collation(): string;
|
||||
function engine(): string;
|
||||
}
|
||||
|
||||
namespace date {
|
||||
function past(years?: number, refDate?: string|Date): Date;
|
||||
function future(years?: number, refDate?: string|Date): Date;
|
||||
function between(from: string|number|Date, to: string|Date): Date;
|
||||
function recent(days?: number): Date;
|
||||
function soon(days?: number): Date;
|
||||
function month(options?: { abbr?: boolean, context?: boolean }): string;
|
||||
function weekday(options?: { abbr?: boolean, context?: boolean }): string;
|
||||
}
|
||||
|
||||
function fake(str: string): string;
|
||||
|
||||
namespace finance {
|
||||
function account(length?: number): string;
|
||||
function accountName(): string;
|
||||
function mask(length?: number, parens?: boolean, elipsis?: boolean): string;
|
||||
function amount(min?: number, max?: number, dec?: number, symbol?: string): string;
|
||||
function transactionType(): string;
|
||||
function currencyCode(): string;
|
||||
function currencyName(): string;
|
||||
function currencySymbol(): string;
|
||||
function bitcoinAddress(): string;
|
||||
function ethereumAddress(): string;
|
||||
function iban(formatted?: boolean): string;
|
||||
function bic(): string;
|
||||
}
|
||||
|
||||
namespace hacker {
|
||||
function abbreviation(): string;
|
||||
function adjective(): string;
|
||||
function noun(): string;
|
||||
function verb(): string;
|
||||
function ingverb(): string;
|
||||
function phrase(): string;
|
||||
}
|
||||
|
||||
namespace helpers {
|
||||
function randomize<T>(array: T[]): T;
|
||||
function randomize(): string;
|
||||
function slugify(string?: string): string;
|
||||
function replaceSymbolWithNumber(string?: string, symbol?: string): string;
|
||||
function replaceSymbols(string?: string): string;
|
||||
function shuffle<T>(o: T[]): T[];
|
||||
function shuffle(): string[];
|
||||
function mustache(str: string, data: { [key: string]: string|((substring: string, ...args: any[]) => string) }): string;
|
||||
function createCard(): I.Card;
|
||||
function contextualCard(): I.ContextualCard;
|
||||
function userCard(): I.UserCard;
|
||||
function createTransaction(): I.Transaction;
|
||||
}
|
||||
|
||||
namespace image {
|
||||
function image(): string;
|
||||
function avatar(): string;
|
||||
function imageUrl(width?: number, height?: number, category?: string): string;
|
||||
function abstract(width?: number, height?: number): string;
|
||||
function animals(width?: number, height?: number): string;
|
||||
function business(width?: number, height?: number): string;
|
||||
function cats(width?: number, height?: number): string;
|
||||
function city(width?: number, height?: number): string;
|
||||
function food(width?: number, height?: number): string;
|
||||
function nightlife(width?: number, height?: number): string;
|
||||
function fashion(width?: number, height?: number): string;
|
||||
function people(width?: number, height?: number): string;
|
||||
function nature(width?: number, height?: number): string;
|
||||
function sports(width?: number, height?: number): string;
|
||||
function technics(width?: number, height?: number): string;
|
||||
function transport(width?: number, height?: number): string;
|
||||
function dataUri(width?: number, height?: number): string;
|
||||
}
|
||||
|
||||
namespace internet {
|
||||
function avatar(): string;
|
||||
function email(firstName?: string, lastName?: string, provider?: string): string;
|
||||
function exampleEmail(firstName?: string, lastName?: string): string;
|
||||
function userName(firstName?: string, lastName?: string): string;
|
||||
function protocol(): string;
|
||||
function url(): string;
|
||||
function domainName(): string;
|
||||
function domainSuffix(): string;
|
||||
function domainWord(): string;
|
||||
function ip(): string;
|
||||
function ipv6(): string;
|
||||
function userAgent(): string;
|
||||
function color(baseRed255?: number, baseGreen255?: number, baseBlue255?: number): string;
|
||||
function mac(): string;
|
||||
function password(len?: number, memorable?: boolean, pattern?: string|RegExp, prefix?: string): string;
|
||||
}
|
||||
|
||||
namespace lorem {
|
||||
function word(): string;
|
||||
function words(num?: number): string;
|
||||
function sentence(wordCount?: number, range?: number): string;
|
||||
function slug(wordCount?: number): string;
|
||||
function sentences(sentenceCount?: number): string;
|
||||
function paragraph(sentenceCount?: number): string;
|
||||
function paragraphs(paragraphCount?: number, separator?: string): string;
|
||||
function text(times?: number): string;
|
||||
function lines(lineCount?: number): string;
|
||||
}
|
||||
|
||||
namespace name {
|
||||
function firstName(gender?: number): string;
|
||||
function lastName(gender?: number): string;
|
||||
function findName(firstName?: string, lastName?: string, gender?: number): string;
|
||||
function jobTitle(): string;
|
||||
function prefix(): string;
|
||||
function suffix(): string;
|
||||
function title(): string;
|
||||
function jobDescriptor(): string;
|
||||
function jobArea(): string;
|
||||
function jobType(): string;
|
||||
}
|
||||
|
||||
namespace phone {
|
||||
function phoneNumber(format?: string): string;
|
||||
function phoneNumberFormat(phoneFormatsArrayIndex?: number): string;
|
||||
function phoneFormats(): string;
|
||||
}
|
||||
|
||||
namespace random {
|
||||
function number(max: number): number;
|
||||
function number(options?: { min?: number, max?: number, precision?: number }): number;
|
||||
function arrayElement(): string;
|
||||
function arrayElement<T>(array: T[]): T;
|
||||
function objectElement(object?: { [key: string]: any }, field?: "key"): string;
|
||||
function objectElement<T>(object?: { [key: string]: T }, field?: any): T;
|
||||
function uuid(): string;
|
||||
function boolean(): boolean;
|
||||
function word(type?: string): string;
|
||||
function words(count?: number): string;
|
||||
function image(): string;
|
||||
function locale(): string;
|
||||
function alphaNumeric(count?: number): string;
|
||||
function hexaDecimal(count?: number): string;
|
||||
}
|
||||
|
||||
namespace system {
|
||||
function fileName(ext: string, type: string): string;
|
||||
function commonFileName(ext: string, type: string): string;
|
||||
function mimeType(): string;
|
||||
function commonFileType(): string;
|
||||
function commonFileExt(): string;
|
||||
function fileType(): string;
|
||||
function fileExt(mimeType: string): string;
|
||||
function directoryPath(): string;
|
||||
function filePath(): string;
|
||||
function semver(): string;
|
||||
}
|
||||
|
||||
function seed(value: number): void;
|
||||
|
||||
namespace I {
|
||||
type Locale =
|
||||
| "az"
|
||||
| "cz"
|
||||
| "de"
|
||||
| "de_AT"
|
||||
| "de_CH"
|
||||
| "el"
|
||||
| "en"
|
||||
| "en_AU"
|
||||
| "en_BORK"
|
||||
| "en_CA"
|
||||
| "en_GB"
|
||||
| "en_IE"
|
||||
| "en_IND"
|
||||
| "en_US"
|
||||
| "en_au_ocker"
|
||||
| "es"
|
||||
| "es_MX"
|
||||
| "fa"
|
||||
| "fr"
|
||||
| "fr_CA"
|
||||
| "ge"
|
||||
| "id_ID"
|
||||
| "it"
|
||||
| "ja"
|
||||
| "ko"
|
||||
| "lv"
|
||||
| "nb_NO"
|
||||
| "nep"
|
||||
| "nl"
|
||||
| "nl_BE"
|
||||
| "pl"
|
||||
| "pt_BR"
|
||||
| "ro"
|
||||
| "ru"
|
||||
| "sk"
|
||||
| "sv"
|
||||
| "tr"
|
||||
| "uk"
|
||||
| "vi"
|
||||
| "zh_CN"
|
||||
| "zh_TW";
|
||||
}
|
||||
|
||||
function getLocale(): I.Locale;
|
||||
|
||||
function setLocale(locale: I.Locale): void;
|
||||
}
|
||||
}
|
||||
Vendored
+18
-14
@@ -99,12 +99,12 @@ declare namespace adone {
|
||||
/**
|
||||
* Checks whether the given object is not a primitive, i.e. neither `undefined` nor `null` nor number nor string nor boolean nor symbol)
|
||||
*/
|
||||
export function object(obj: any): boolean;
|
||||
export function object(obj: any): obj is object;
|
||||
|
||||
/**
|
||||
* Checks whether the given object is a plain object, i.e. created by Object
|
||||
*/
|
||||
export function plainObject(obj: any): boolean;
|
||||
export function plainObject(obj: any): obj is object;
|
||||
|
||||
/**
|
||||
* Checks whether the given object is an adone namespace
|
||||
@@ -120,7 +120,7 @@ declare namespace adone {
|
||||
/**
|
||||
* Checks whether the given object is empty, i.e. it is an object(not a primitive), and Object.keys returns an empty array
|
||||
*/
|
||||
export function emptyObject(obj: any): boolean;
|
||||
export function emptyObject(obj: any): obj is object;
|
||||
|
||||
/**
|
||||
* Checks whether the given object has the given owned property
|
||||
@@ -140,7 +140,7 @@ declare namespace adone {
|
||||
/**
|
||||
* Checks whether the given object is like an array, i.e. it is not a primitive, not a function and has length
|
||||
*/
|
||||
export function arrayLikeObject(obj: any): boolean;
|
||||
export function arrayLikeObject(obj: any): obj is ArrayLike<any>;
|
||||
|
||||
/**
|
||||
* Checks whether the given array has the given value
|
||||
@@ -227,13 +227,13 @@ declare namespace adone {
|
||||
/**
|
||||
* Checks whether the given object is a function
|
||||
*/
|
||||
function _function(obj: any): boolean;
|
||||
function _function(obj: any): obj is (...args: any[]) => any;
|
||||
export { _function as function };
|
||||
|
||||
/**
|
||||
* Checks whether the given object is an async function
|
||||
*/
|
||||
export function asyncFunction(obj: any): boolean;
|
||||
export function asyncFunction(obj: any): obj is (...args: any[]) => Promise<any>;
|
||||
|
||||
/**
|
||||
* Checks whether the given object is a promise
|
||||
@@ -258,7 +258,7 @@ declare namespace adone {
|
||||
/**
|
||||
* Checks whether the given object is a generator function
|
||||
*/
|
||||
export function generator(obj: any): boolean;
|
||||
export function generator(obj: any): obj is GeneratorFunction;
|
||||
|
||||
/**
|
||||
* Checks whether the given object is NaN
|
||||
@@ -320,12 +320,12 @@ declare namespace adone {
|
||||
/**
|
||||
* Checks whether the given object is an adone subsystem
|
||||
*/
|
||||
export function subsystem(obj: any): boolean;
|
||||
export function subsystem(obj: any): obj is adone.application.Subsystem;
|
||||
|
||||
/**
|
||||
* Checks whether the given object is an adone application
|
||||
*/
|
||||
export function application(obj: any): boolean;
|
||||
export function application(obj: any): obj is adone.application.Application;
|
||||
|
||||
/**
|
||||
* Checks whether the given object is an adone logger
|
||||
@@ -335,22 +335,22 @@ declare namespace adone {
|
||||
/**
|
||||
* Checks whether the given object is a core stream
|
||||
*/
|
||||
export function coreStream(obj: any): boolean;
|
||||
export function coreStream(obj: any): obj is adone.stream.core.Stream;
|
||||
|
||||
/**
|
||||
* Checks whether the given object is a fast local map stream
|
||||
*/
|
||||
export function fastLocalMapStream(obj: any): boolean;
|
||||
export function fastLocalMapStream(obj: any): obj is adone.fast.I.LocalMapStream<any>;
|
||||
|
||||
/**
|
||||
* Checks whether the given object is a fast local stream
|
||||
*/
|
||||
export function fastLocalStream(obj: any): boolean;
|
||||
export function fastLocalStream(obj: any): obj is adone.fast.I.LocalStream<any>;
|
||||
|
||||
/**
|
||||
* Checks whether the given object is a fast stream
|
||||
*/
|
||||
export function fastStream(obj: any): boolean;
|
||||
export function fastStream(obj: any): obj is adone.fast.I.Stream<any>;
|
||||
|
||||
/**
|
||||
* Checks whether the given object is a genesis netron
|
||||
@@ -430,7 +430,7 @@ declare namespace adone {
|
||||
/**
|
||||
* Checks whether the given object is iterable, has defined Symbol.iterator property
|
||||
*/
|
||||
export function iterable(obj: any): boolean;
|
||||
export function iterable(obj: any): obj is Iterable<any>;
|
||||
|
||||
/**
|
||||
* true if the OS is Windows
|
||||
@@ -672,5 +672,9 @@ declare namespace adone {
|
||||
* Checks whether the given object is a valid UUID identifier (v1, v2, v3, v4 or v5)
|
||||
*/
|
||||
export function uuid(obj: any, version?: "all"): obj is string;
|
||||
|
||||
export function emitter(obj: any): obj is event.Emitter;
|
||||
|
||||
export function asyncEmitter(obj: any): obj is event.AsyncEmitter;
|
||||
}
|
||||
}
|
||||
|
||||
+275
@@ -0,0 +1,275 @@
|
||||
declare namespace adone.net.http {
|
||||
namespace client {
|
||||
namespace I {
|
||||
interface RequestHeaders {
|
||||
"Accept"?: string;
|
||||
"Accept-Charset"?: string;
|
||||
"Accept-Encoding"?: string;
|
||||
"Accept-Language"?: string;
|
||||
"Accept-Datetime"?: string;
|
||||
"Access-Control-Request-Method"?: string;
|
||||
"Access-Control-Request-Headers"?: string;
|
||||
"Authorization"?: string;
|
||||
"Cache-Control"?: string;
|
||||
"Connection"?: string;
|
||||
"Cookie"?: string;
|
||||
"Content-Length"?: string;
|
||||
"Content-MD5"?: string;
|
||||
"Content-Type"?: string;
|
||||
"Date"?: string;
|
||||
"Expect"?: string;
|
||||
"Forwarded"?: string;
|
||||
"From"?: string;
|
||||
"Host"?: string;
|
||||
"If-Match"?: string;
|
||||
"If-Modified-Since"?: string;
|
||||
"If-None-Match"?: string;
|
||||
"If-Range"?: string;
|
||||
"If-Unmodified-Since"?: string;
|
||||
"Max-Forwards"?: string;
|
||||
"Origin"?: string;
|
||||
"Pragma"?: string;
|
||||
"Proxy-Authorization"?: string;
|
||||
"Range"?: string;
|
||||
"Referer"?: string;
|
||||
"TE"?: string;
|
||||
"User-Agent"?: string;
|
||||
"Upgrade"?: string;
|
||||
"Via"?: string;
|
||||
"Warning"?: string;
|
||||
"X-Requested-With"?: string;
|
||||
"DNT"?: string;
|
||||
"X-Forwarded-For"?: string;
|
||||
"X-Forwarded-Host"?: string;
|
||||
"X-Forwarded-Proto"?: string;
|
||||
"Front-End-Https"?: string;
|
||||
"X-Http-Method-Override"?: string;
|
||||
"X-ATT-DeviceId"?: string;
|
||||
"X-Wap-Profile"?: string;
|
||||
"Proxy-Connection"?: string;
|
||||
"X-UIDH"?: string;
|
||||
"X-Csrf-Token"?: string;
|
||||
"X-Request-ID"?: string;
|
||||
"X-Correlation-ID"?: string;
|
||||
|
||||
[name: string]: string | undefined;
|
||||
}
|
||||
|
||||
interface ResponseHeaders {
|
||||
"accept-patch": string | undefined;
|
||||
"accept-ranges": string | undefined;
|
||||
"access-control-allow-credentials": string | undefined;
|
||||
"access-control-allow-headers": string | undefined;
|
||||
"access-control-allow-methods": string | undefined;
|
||||
"access-control-allow-origin": string | undefined;
|
||||
"access-control-expose-headers": string | undefined;
|
||||
"access-control-max-age": string | undefined;
|
||||
"age": string | undefined;
|
||||
"allow": string | undefined;
|
||||
"alt-svc": string | undefined;
|
||||
"cache-control": string | undefined;
|
||||
"connection": string| undefined;
|
||||
"content-disposition": string | undefined;
|
||||
"content-encoding": string| undefined;
|
||||
"content-language": string | undefined;
|
||||
"content-length": string| undefined;
|
||||
"content-location": string| undefined;
|
||||
"content-md5": string| undefined;
|
||||
"content-range": string| undefined;
|
||||
"content-security-policy": string | undefined;
|
||||
"content-type": string| undefined;
|
||||
"date": string| undefined;
|
||||
"etag": string| undefined;
|
||||
"expires": string| undefined;
|
||||
"keep-alive": string | undefined;
|
||||
"last-modified": string | undefined;
|
||||
"link": string| undefined;
|
||||
"location": string| undefined;
|
||||
"p3p": string| undefined;
|
||||
"pragma": string| undefined;
|
||||
"proxy-authenticate": string | undefined;
|
||||
"public-key-pins": string| undefined;
|
||||
"referer-policy": string | undefined;
|
||||
"refresh": string | undefined;
|
||||
"retry-after": string | undefined;
|
||||
"server": string | undefined;
|
||||
"set-cookie": string | undefined;
|
||||
"status": string | undefined;
|
||||
"strict-transport-security": string| undefined;
|
||||
"timing-allow-origin": string | undefined;
|
||||
"tk": string| undefined;
|
||||
"transfer-encoding": string | undefined;
|
||||
"upgrade-insecure-requests": string | undefined;
|
||||
"upgrade": string| undefined;
|
||||
"vary": string | undefined;
|
||||
"via": string| undefined;
|
||||
"warning": string| undefined;
|
||||
"www-authenticate": string | undefined;
|
||||
"x-content-duration": string | undefined;
|
||||
"x-content-security-policy": string | undefined;
|
||||
"x-content-type-options": string | undefined;
|
||||
"x-correlation-id": string | undefined;
|
||||
"x-frame-options": string| undefined;
|
||||
"x-powered-by": string | undefined;
|
||||
"x-request-id": string | undefined;
|
||||
"x-ua-compatible": string | undefined;
|
||||
"x-webkit-csp": string | undefined;
|
||||
"x-xss-protection": string | undefined;
|
||||
|
||||
[header: string]: string | undefined;
|
||||
}
|
||||
|
||||
interface Response<T> {
|
||||
status: number;
|
||||
statusText: string;
|
||||
headers: ResponseHeaders;
|
||||
data: T;
|
||||
}
|
||||
|
||||
type Transformer = (data: Data, headers: object, config: I.Options) => Data;
|
||||
|
||||
interface FormValueOptions {
|
||||
header?: string | { [key: string]: string };
|
||||
knownLength?: number;
|
||||
filename?: string;
|
||||
filepath?: string;
|
||||
contentType?: string;
|
||||
}
|
||||
|
||||
type FormValue = string | Buffer | nodestd.stream.Readable | {
|
||||
value: string | Buffer | nodestd.stream.Readable;
|
||||
options: FormValueOptions
|
||||
};
|
||||
|
||||
interface UploadProgressEvent {
|
||||
lengthComputable: boolean;
|
||||
loaded: number;
|
||||
total: number;
|
||||
}
|
||||
|
||||
interface ProxyObject {
|
||||
protocol?: string;
|
||||
host?: string;
|
||||
port?: number;
|
||||
auth?: {
|
||||
username?: string;
|
||||
password?: string;
|
||||
};
|
||||
}
|
||||
|
||||
interface Config {
|
||||
adapter<T>(config: I.Config): Promise<Response<T>>;
|
||||
transformRequest: Transformer[];
|
||||
transformResponse: Transformer[];
|
||||
timeout: number;
|
||||
xsrfCookieName: string;
|
||||
xsrfHeaderName: string;
|
||||
maxContentLength: number;
|
||||
validateStatus: (status: number) => boolean;
|
||||
responseType: "buffer" | "string" | "stream" | "json";
|
||||
responseEncoding: adone.util.iconv.I.SupportedEncoding;
|
||||
method: "GET" | "POST" | "PUT" | "PATCH" | "DELETE" | "OPTIONS";
|
||||
headers: RequestHeaders;
|
||||
data: Data;
|
||||
formData: {
|
||||
[formKey: string]: FormValue | FormValue[];
|
||||
};
|
||||
auth: {
|
||||
username?: string;
|
||||
password?: string;
|
||||
};
|
||||
httpsAgent: object;
|
||||
httpAgent: object;
|
||||
params: object;
|
||||
rejectUnauthorized: boolean;
|
||||
proxy: string | ProxyObject | false;
|
||||
transport: object;
|
||||
maxRedirects: number;
|
||||
cancelToken: CancelToken;
|
||||
onUploadProgress(event: UploadProgressEvent): void;
|
||||
baseURL: string;
|
||||
paramsSerializer(params: object): string;
|
||||
}
|
||||
|
||||
type Options = Partial<Config>;
|
||||
|
||||
type Data = string | Buffer | ArrayBuffer | nodestd.stream.Readable | ArrayBufferView | object | undefined;
|
||||
|
||||
interface Request extends Client {
|
||||
(config: I.Options, ...args: any[]): Promise<object>;
|
||||
}
|
||||
}
|
||||
|
||||
class Client {
|
||||
constructor(options?: I.Options);
|
||||
|
||||
request(config: I.Options & { responseType: "json" }, ...args: any[]): Promise<I.Response<object | string>>;
|
||||
request(config: I.Options & { responseType: "string" }, ...args: any[]): Promise<I.Response<string>>;
|
||||
request(config: I.Options & { responseType: "buffer" }, ...args: any[]): Promise<I.Response<Buffer>>;
|
||||
request(config: I.Options & { responseType: "stream" }, ...args: any[]): Promise<I.Response<nodestd.stream.Readable>>;
|
||||
request(config: I.Options, ...args: any[]): Promise<I.Response<object | string>>;
|
||||
|
||||
get(url: string, options: I.Options & { responseType: "string" }): Promise<I.Response<string>>;
|
||||
get(url: string, options: I.Options & { responseType: "buffer" }): Promise<I.Response<Buffer>>;
|
||||
get(url: string, options: I.Options & { responseType: "stream" }): Promise<I.Response<nodestd.stream.Readable>>;
|
||||
get(url: string, options?: I.Options): Promise<I.Response<object | string>>;
|
||||
|
||||
post(url: string, data: I.Data, options: I.Options & { responseType: "string" }): Promise<I.Response<string>>;
|
||||
post(url: string, data: I.Data, options: I.Options & { responseType: "buffer" }): Promise<I.Response<Buffer>>;
|
||||
post(url: string, data: I.Data, options: I.Options & { responseType: "stream" }): Promise<I.Response<nodestd.stream.Readable>>;
|
||||
post(url: string, data?: I.Data, options?: I.Options): Promise<I.Response<object | string>>;
|
||||
|
||||
put(url: string, data: I.Data, options: I.Options & { responseType: "string" }): Promise<I.Response<string>>;
|
||||
put(url: string, data: I.Data, options: I.Options & { responseType: "buffer" }): Promise<I.Response<Buffer>>;
|
||||
put(url: string, data: I.Data, options: I.Options & { responseType: "stream" }): Promise<I.Response<nodestd.stream.Readable>>;
|
||||
put(url: string, data?: I.Data, options?: I.Options): Promise<I.Response<object | string>>;
|
||||
|
||||
patch(url: string, data: I.Data, options: I.Options & { responseType: "string" }): Promise<I.Response<string>>;
|
||||
patch(url: string, data: I.Data, options: I.Options & { responseType: "buffer" }): Promise<I.Response<Buffer>>;
|
||||
patch(url: string, data: I.Data, options: I.Options & { responseType: "stream" }): Promise<I.Response<nodestd.stream.Readable>>;
|
||||
patch(url: string, data?: I.Data, options?: I.Options): Promise<I.Response<object | string>>;
|
||||
|
||||
delete(url: string, options: I.Options & { responseType: "string" }): Promise<I.Response<string>>;
|
||||
delete(url: string, options: I.Options & { responseType: "buffer" }): Promise<I.Response<Buffer>>;
|
||||
delete(url: string, options: I.Options & { responseType: "stream" }): Promise<I.Response<nodestd.stream.Readable>>;
|
||||
delete(url: string, options?: I.Options): Promise<I.Response<object | string>>;
|
||||
|
||||
options(url: string, options: I.Options & { responseType: "string" }): Promise<I.Response<string>>;
|
||||
options(url: string, options: I.Options & { responseType: "buffer" }): Promise<I.Response<Buffer>>;
|
||||
options(url: string, options: I.Options & { responseType: "stream" }): Promise<I.Response<nodestd.stream.Readable>>;
|
||||
options(url: string, options?: I.Options): Promise<I.Response<object | string>>;
|
||||
}
|
||||
|
||||
class Cancel {
|
||||
message: string;
|
||||
|
||||
constructor(message: string);
|
||||
}
|
||||
|
||||
namespace I {
|
||||
type Canceller = (message?: string) => void;
|
||||
|
||||
interface CancelTokenSource {
|
||||
token: CancelToken;
|
||||
cancel: Canceller;
|
||||
}
|
||||
}
|
||||
|
||||
class CancelToken {
|
||||
promise: Promise<Cancel>;
|
||||
reason?: Cancel;
|
||||
|
||||
constructor(executor: I.Canceller);
|
||||
|
||||
throwIfRequested(): void;
|
||||
|
||||
static source(): I.CancelTokenSource;
|
||||
}
|
||||
|
||||
const request: I.Request;
|
||||
|
||||
function create(options?: I.Options): I.Request;
|
||||
|
||||
function isCancel(obj: any): obj is Cancel;
|
||||
}
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
/// <reference path="./client.d.ts" />
|
||||
|
||||
declare namespace adone.net {
|
||||
namespace http {
|
||||
//
|
||||
}
|
||||
}
|
||||
Vendored
+7
@@ -0,0 +1,7 @@
|
||||
/// <reference path="./http/index.d.ts" />
|
||||
|
||||
declare namespace adone {
|
||||
namespace net {
|
||||
//
|
||||
}
|
||||
}
|
||||
Vendored
+25
@@ -0,0 +1,25 @@
|
||||
declare namespace adone {
|
||||
namespace regex {
|
||||
function filename(): RegExp;
|
||||
|
||||
function ip4(): RegExp;
|
||||
|
||||
function ip6(): RegExp;
|
||||
|
||||
function protocol(): RegExp;
|
||||
|
||||
function idn(): RegExp;
|
||||
|
||||
function punycode(): RegExp;
|
||||
|
||||
function uri(): RegExp;
|
||||
|
||||
function uuid4(): RegExp;
|
||||
|
||||
function uuid5(): RegExp;
|
||||
|
||||
function ansi(): RegExp;
|
||||
|
||||
function shebang(): RegExp;
|
||||
}
|
||||
}
|
||||
Vendored
+237
@@ -0,0 +1,237 @@
|
||||
declare namespace adone {
|
||||
namespace semver {
|
||||
const SEMVER_SPEC_VERSION: "2.0.0";
|
||||
|
||||
namespace I {
|
||||
type ReleaseType = "major"
|
||||
| "premajor"
|
||||
| "minor"
|
||||
| "preminor"
|
||||
| "patch"
|
||||
| "prepatch"
|
||||
| "prerelease";
|
||||
|
||||
type Operator = '==='
|
||||
| "!=="
|
||||
| ""
|
||||
| "="
|
||||
| "=="
|
||||
| "!="
|
||||
| ">"
|
||||
| ">="
|
||||
| "<"
|
||||
| "<=";
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the parsed version as a SemVer object, or null if it's not valid.
|
||||
*/
|
||||
function parse(v: string | SemVer, loose?: boolean): SemVer | null;
|
||||
|
||||
/**
|
||||
* Returns the parsed version, or null if it's not valid.
|
||||
*/
|
||||
function valid(v: string | SemVer, loose?: boolean): string | null;
|
||||
|
||||
/**
|
||||
* Returns cleaned (removed leading/trailing whitespace, remove '=v' prefix) and parsed version, or null if version is invalid.
|
||||
*/
|
||||
function clean(version: string, loose?: boolean): string | null;
|
||||
|
||||
/**
|
||||
* Returns the version incremented by the release type (major, minor, patch, or prerelease), or null if it's not valid.
|
||||
*/
|
||||
function inc(v: string | SemVer, release: I.ReleaseType, loose?: boolean, identifier?: string): string | null;
|
||||
|
||||
/**
|
||||
* Returns the major version number.
|
||||
*/
|
||||
function major(v: string | SemVer, loose?: boolean): number;
|
||||
|
||||
/**
|
||||
* Returns the minor version number.
|
||||
*/
|
||||
function minor(v: string | SemVer, loose?: boolean): number;
|
||||
|
||||
/**
|
||||
* Returns the patch version number.
|
||||
*/
|
||||
function patch(v: string | SemVer, loose?: boolean): number;
|
||||
|
||||
/**
|
||||
* Returns an array of prerelease components, or null if none exist.
|
||||
*/
|
||||
function prerelease(v: string | SemVer, loose?: boolean): string[] | null;
|
||||
|
||||
// Comparison
|
||||
|
||||
/**
|
||||
* v1 > v2
|
||||
*/
|
||||
function gt(v1: string | SemVer, v2: string | SemVer, loose?: boolean): boolean;
|
||||
|
||||
/**
|
||||
* v1 >= v2
|
||||
*/
|
||||
function gte(v1: string | SemVer, v2: string | SemVer, loose?: boolean): boolean;
|
||||
|
||||
/**
|
||||
* v1 < v2
|
||||
*/
|
||||
function lt(v1: string | SemVer, v2: string | SemVer, loose?: boolean): boolean;
|
||||
|
||||
/**
|
||||
* v1 <= v2
|
||||
*/
|
||||
function lte(v1: string | SemVer, v2: string | SemVer, loose?: boolean): boolean;
|
||||
|
||||
/**
|
||||
* v1 == v2 This is true if they're logically equivalent, even if they're not the exact same string. You already know how to compare strings.
|
||||
*/
|
||||
function eq(v1: string | SemVer, v2: string | SemVer, loose?: boolean): boolean;
|
||||
|
||||
/**
|
||||
* v1 != v2 The opposite of eq.
|
||||
*/
|
||||
function neq(v1: string | SemVer, v2: string | SemVer, loose?: boolean): boolean;
|
||||
|
||||
/**
|
||||
* Pass in a comparison string, and it'll call the corresponding semver comparison function.
|
||||
* "===" and "!==" do simple string comparison, but are included for completeness.
|
||||
* Throws if an invalid comparison string is provided.
|
||||
*/
|
||||
function cmp(v1: string | SemVer, operator: I.Operator, v2: string | SemVer, loose?: boolean): boolean;
|
||||
|
||||
/**
|
||||
* Returns 0 if v1 == v2, or 1 if v1 is greater, or -1 if v2 is greater. Sorts in ascending order if passed to Array.sort().
|
||||
*/
|
||||
function compare(v1: string | SemVer, v2: string | SemVer, loose?: boolean): 1 | 0 | -1;
|
||||
|
||||
/**
|
||||
* The reverse of compare. Sorts an array of versions in descending order when passed to Array.sort().
|
||||
*/
|
||||
function rcompare(v1: string | SemVer, v2: string | SemVer, loose?: boolean): 1 | 0 | -1;
|
||||
|
||||
/**
|
||||
* Compares two identifiers, must be numeric strings or truthy/falsy values. Sorts in ascending order if passed to Array.sort().
|
||||
*/
|
||||
function compareIdentifiers(a: string | null, b: string | null): 1 | 0 | -1;
|
||||
|
||||
/**
|
||||
* The reverse of compareIdentifiers. Sorts in descending order when passed to Array.sort().
|
||||
*/
|
||||
function rcompareIdentifiers(a: string | null, b: string | null): 1 | 0 | -1;
|
||||
|
||||
/**
|
||||
* Sorts an array of semver entries in ascending order.
|
||||
*/
|
||||
function sort(list: Array<string | SemVer>, loose?: boolean): Array<string | SemVer>;
|
||||
|
||||
/**
|
||||
* Sorts an array of semver entries in descending order.
|
||||
*/
|
||||
function rsort(list: Array<string | SemVer>, loose?: boolean): Array<string | SemVer>;
|
||||
|
||||
/**
|
||||
* Returns difference between two versions by the release type (major, premajor, minor, preminor, patch, prepatch, or prerelease), or null if the versions are the same.
|
||||
*/
|
||||
function diff(v1: string, v2: string, loose?: boolean): I.ReleaseType | null;
|
||||
|
||||
// Ranges
|
||||
|
||||
/**
|
||||
* Returns the valid range or null if it's not valid
|
||||
*/
|
||||
function validRange(range: string | Range, loose?: boolean): string;
|
||||
|
||||
/**
|
||||
* Returns true if the version satisfies the range.
|
||||
*/
|
||||
function satisfies(version: string | SemVer, range: string | Range, loose?: boolean): boolean;
|
||||
|
||||
/**
|
||||
* Returns the highest version in the list that satisfies the range, or null if none of them do.
|
||||
*/
|
||||
function maxSatisfying(versions: Array<string | SemVer>, range: string | Range, loose?: boolean): string;
|
||||
|
||||
/**
|
||||
* Returns the lowest version in the list that satisfies the range, or null if none of them do.
|
||||
*/
|
||||
function minSatisfying(versions: Array<string | SemVer>, range: string, loose?: boolean): string;
|
||||
|
||||
/**
|
||||
* Returns true if version is greater than all the versions possible in the range.
|
||||
*/
|
||||
function gtr(version: string | SemVer, range: string | Range, loose?: boolean): boolean;
|
||||
|
||||
/**
|
||||
* Returns true if version is less than all the versions possible in the range.
|
||||
*/
|
||||
function ltr(version: string | SemVer, range: string | Range, loose?: boolean): boolean;
|
||||
|
||||
/**
|
||||
* Returns true if the version is outside the bounds of the range in either the high or low direction.
|
||||
* The hilo argument must be either the string '>' or '<'. (This is the function called by gtr and ltr.)
|
||||
*/
|
||||
function outside(version: string | SemVer, range: string | Range, hilo: '>' | '<', loose?: boolean): boolean;
|
||||
|
||||
/**
|
||||
* Returns true if any of the ranges comparators intersect
|
||||
*/
|
||||
function intersects(range1: string | Range, range2: string | Range, loose?: boolean): boolean;
|
||||
|
||||
// Coercion
|
||||
|
||||
/**
|
||||
* Coerces a string to semver if possible
|
||||
*/
|
||||
function coerce(version: string | SemVer): SemVer | null;
|
||||
|
||||
class SemVer {
|
||||
constructor(version: string | SemVer, loose?: boolean);
|
||||
|
||||
raw: string;
|
||||
loose: boolean;
|
||||
format(): string;
|
||||
inspect(): string;
|
||||
|
||||
major: number;
|
||||
minor: number;
|
||||
patch: number;
|
||||
version: string;
|
||||
build: string[];
|
||||
prerelease: string[];
|
||||
|
||||
compare(other: string | SemVer): 1 | 0 | -1;
|
||||
compareMain(other: string | SemVer): 1 | 0 | -1;
|
||||
comparePre(other: string | SemVer): 1 | 0 | -1;
|
||||
inc(release: I.ReleaseType, identifier?: string): SemVer;
|
||||
}
|
||||
|
||||
class Comparator {
|
||||
constructor(comp: string | Comparator, loose?: boolean);
|
||||
|
||||
semver: SemVer;
|
||||
operator: string;
|
||||
value: boolean;
|
||||
parse(comp: string): void;
|
||||
test(version: string | SemVer): boolean;
|
||||
intersects(comp: Comparator, loose?: boolean): boolean;
|
||||
}
|
||||
|
||||
class Range {
|
||||
constructor(range: string | Range, loose?: boolean);
|
||||
|
||||
range: string;
|
||||
raw: string;
|
||||
loose: boolean;
|
||||
format(): string;
|
||||
inspect(): string;
|
||||
|
||||
set: Comparator[][];
|
||||
parseRange(range: string): Comparator[];
|
||||
test(version: string | SemVer): boolean;
|
||||
intersects(range: Range, loose?: boolean): boolean;
|
||||
}
|
||||
}
|
||||
}
|
||||
Vendored
+37
-31
@@ -1,34 +1,37 @@
|
||||
import * as assert from "assert";
|
||||
import * as fs from "fs";
|
||||
import * as path from "path";
|
||||
import * as util from "util";
|
||||
import * as events from "events";
|
||||
import * as stream from "stream";
|
||||
import * as url from "url";
|
||||
import * as net from "net";
|
||||
import * as http from "http";
|
||||
import * as https from "https";
|
||||
import * as child_process from "child_process";
|
||||
import * as os from "os";
|
||||
import * as cluster from "cluster";
|
||||
import * as repl from "repl";
|
||||
import * as punycode from "punycode";
|
||||
import * as readline from "readline";
|
||||
import * as string_decoder from "string_decoder";
|
||||
import * as querystring from "querystring";
|
||||
import * as crypto from "crypto";
|
||||
import * as vm from "vm";
|
||||
import * as v8 from "v8";
|
||||
import * as domain from "domain";
|
||||
import * as tty from "tty";
|
||||
import * as buffer from "buffer";
|
||||
import * as constants from "constants";
|
||||
import * as zlib from "zlib";
|
||||
import * as tls from "tls";
|
||||
import * as console from "console";
|
||||
import * as dns from "dns";
|
||||
import * as timers from "timers";
|
||||
import * as dgram from "dgram";
|
||||
import assert = require("assert");
|
||||
import fs = require("fs");
|
||||
import path = require("path");
|
||||
import util = require("util");
|
||||
import events = require("events");
|
||||
import stream = require("stream");
|
||||
import url = require("url");
|
||||
import net = require("net");
|
||||
import http = require("http");
|
||||
import http2 = require("http2");
|
||||
import https = require("https");
|
||||
import child_process = require("child_process");
|
||||
import os = require("os");
|
||||
import cluster = require("cluster");
|
||||
import repl = require("repl");
|
||||
import punycode = require("punycode");
|
||||
import readline = require("readline");
|
||||
import string_decoder = require("string_decoder");
|
||||
import querystring = require("querystring");
|
||||
import crypto = require("crypto");
|
||||
import vm = require("vm");
|
||||
import v8 = require("v8");
|
||||
import domain = require("domain");
|
||||
import module = require("module");
|
||||
import tty = require("tty");
|
||||
import buffer = require("buffer");
|
||||
import constants = require("constants");
|
||||
import zlib = require("zlib");
|
||||
import tls = require("tls");
|
||||
import console = require("console");
|
||||
import dns = require("dns");
|
||||
import timers = require("timers");
|
||||
import dgram = require("dgram");
|
||||
import perf_hooks = require("perf_hooks");
|
||||
|
||||
export {
|
||||
assert,
|
||||
@@ -40,6 +43,7 @@ export {
|
||||
url,
|
||||
net,
|
||||
http,
|
||||
http2,
|
||||
https,
|
||||
child_process,
|
||||
os,
|
||||
@@ -53,6 +57,7 @@ export {
|
||||
vm,
|
||||
v8,
|
||||
domain,
|
||||
module,
|
||||
tty,
|
||||
buffer,
|
||||
constants,
|
||||
@@ -62,6 +67,7 @@ export {
|
||||
dns,
|
||||
timers,
|
||||
dgram,
|
||||
perf_hooks
|
||||
};
|
||||
|
||||
export as namespace nodestd;
|
||||
|
||||
Vendored
+19
@@ -0,0 +1,19 @@
|
||||
declare namespace adone.system {
|
||||
namespace env {
|
||||
function user(): string;
|
||||
|
||||
function prompt(): string;
|
||||
|
||||
function hostname(): string;
|
||||
|
||||
function tmpdir(): string;
|
||||
|
||||
function home(): string;
|
||||
|
||||
function path(): string;
|
||||
|
||||
function editor(): string;
|
||||
|
||||
function shell(): string;
|
||||
}
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
/// <reference path="./env.d.ts" />
|
||||
/// <reference path="./process.d.ts" />
|
||||
/// <reference path="./user.d.ts" />
|
||||
|
||||
declare namespace adone {
|
||||
namespace system {
|
||||
//
|
||||
}
|
||||
}
|
||||
+241
@@ -0,0 +1,241 @@
|
||||
declare namespace adone.system.process {
|
||||
function errname(code: number): string;
|
||||
|
||||
function errnameFallback(uv: object, code: number): string;
|
||||
|
||||
function stdio(opts: object): any[];
|
||||
|
||||
namespace I {
|
||||
type StdIOOption = "pipe" | "ipc" | "ignore" | nodestd.stream.Stream | number | null | undefined;
|
||||
|
||||
interface ExecCommonOptions {
|
||||
/**
|
||||
* Current working directory of the child process.
|
||||
* @default `process.cwd()`
|
||||
*/
|
||||
cwd?: string;
|
||||
|
||||
/**
|
||||
* Environment key-value pairs.
|
||||
* Extends automatically from `process.env`.
|
||||
* Set `extendEnv` to `false` if you don"t want this.
|
||||
* @default `process.env`
|
||||
*/
|
||||
env?: NodeJS.ProcessEnv;
|
||||
|
||||
/**
|
||||
* Set to `false` if you don't want to extend the environment variables when providing the `env` property.
|
||||
* @default `true`
|
||||
*/
|
||||
extendEnv?: boolean;
|
||||
|
||||
/**
|
||||
* Explicitly set the value of `argv[0]` sent to the child process.
|
||||
* This will be set to `command` or `file` if not specified.
|
||||
*/
|
||||
argv0?: string;
|
||||
|
||||
/**
|
||||
* The `stdio` option is used to configure the pipes that are established between the parent and child process.
|
||||
* By default, the child's stdin, stdout, and stderr are redirected to corresponding `subprocess.stdin`, `subprocess.stdout`, and `subprocess.stderr` streams on the `ChildProcess` object.
|
||||
* @default `'pipe'`
|
||||
*
|
||||
* @see https://nodejs.org/api/child_process.html#child_process_options_stdio
|
||||
*/
|
||||
stdio?: "pipe" | "ignore" | "inherit" | StdIOOption[];
|
||||
|
||||
/**
|
||||
* Prepare child to run independently of its parent process.
|
||||
* Specific behavior depends on the platform.
|
||||
* @see https://nodejs.org/api/child_process.html#child_process_options_detached
|
||||
*/
|
||||
detached?: boolean;
|
||||
|
||||
/**
|
||||
* Sets the user identity of the process.
|
||||
*/
|
||||
uid?: number;
|
||||
|
||||
/**
|
||||
* Sets the group identity of the process.
|
||||
*/
|
||||
gid?: number;
|
||||
|
||||
/**
|
||||
* If `true`, runs `command` inside of a shell.
|
||||
* Uses `/bin/sh` on UNIX and `cmd.exe` on Windows.
|
||||
* A different shell can be specified as a string.
|
||||
* The shell should understand the `-c` switch on UNIX or `/d /s /c` on Windows.
|
||||
* @default `false`
|
||||
*/
|
||||
shell?: boolean | string;
|
||||
|
||||
/**
|
||||
* If `true`, no quoting or escaping of arguments is done on Windows.
|
||||
* Ignored on other platforms.
|
||||
* This is set to `true` automatically when `shell` is specified.
|
||||
* @default `false`
|
||||
*/
|
||||
windowsVerbatimArguments?: boolean;
|
||||
|
||||
/**
|
||||
* Strip EOF (last newline) from the output.
|
||||
* @default `true`
|
||||
* @see https://github.com/sindresorhus/strip-eof
|
||||
*/
|
||||
stripEof?: boolean;
|
||||
|
||||
/**
|
||||
* Prefer locally installed binaries when looking for a binary to execute.
|
||||
* If you `$ npm install foo`, you can then `execa('foo')`.
|
||||
* @default `true`
|
||||
*/
|
||||
preferLocal?: boolean;
|
||||
|
||||
/**
|
||||
* Preferred path to find locally installed binaries in (use with `preferLocal`).
|
||||
* @default `process.cwd()`
|
||||
*/
|
||||
localDir?: string;
|
||||
|
||||
/**
|
||||
* Setting this to `false` resolves the promise with the error instead of rejecting it.
|
||||
* @default `true`
|
||||
*/
|
||||
reject?: boolean;
|
||||
|
||||
/**
|
||||
* Keep track of the spawned process and `kill` it when the parent process exits.
|
||||
* @default `true`
|
||||
*/
|
||||
cleanup?: boolean;
|
||||
|
||||
/**
|
||||
* Specify the character encoding used to decode the `stdout` and `stderr` output.
|
||||
* @default `utf8`
|
||||
*/
|
||||
encoding?: string;
|
||||
|
||||
/**
|
||||
* If `timeout` is greater than `0`, the parent will send the signal identified by the `killSignal` property
|
||||
* (the default is `SIGTERM`) if the child runs longer than `timeout` milliseconds.
|
||||
*
|
||||
* @default `0`
|
||||
*/
|
||||
timeout?: number;
|
||||
|
||||
/**
|
||||
* Largest amount of data in bytes allowed on `stdout` or `stderr`.
|
||||
* @default `10000000` (10MB)
|
||||
*/
|
||||
maxBuffer?: number;
|
||||
|
||||
/**
|
||||
* Signal value to be used when the spawned process will be killed.
|
||||
* @default `SIGTERM`
|
||||
*/
|
||||
killSignal?: string | number;
|
||||
|
||||
/**
|
||||
* Used to configure the stdin pipe that is established between the parent and child process.
|
||||
* @default `'pipe'`
|
||||
* @see https://nodejs.org/api/child_process.html#child_process_options_stdio
|
||||
*/
|
||||
stdin?: StdIOOption;
|
||||
|
||||
/**
|
||||
* Used to configure the stdout pipe that is established between the parent and child process.
|
||||
* @default `'pipe'`
|
||||
* @see https://nodejs.org/api/child_process.html#child_process_options_stdio
|
||||
*/
|
||||
stdout?: StdIOOption;
|
||||
|
||||
/**
|
||||
* Used to configure the stderr pipe that is established between the parent and child process.
|
||||
* @default `'pipe'`
|
||||
* @see https://nodejs.org/api/child_process.html#child_process_options_stdio
|
||||
*/
|
||||
stderr?: StdIOOption;
|
||||
}
|
||||
|
||||
interface ExecOptions extends ExecCommonOptions {
|
||||
/**
|
||||
* Write some input to the `stdin` of your binary.
|
||||
*/
|
||||
input?: string | Buffer | nodestd.stream.Stream;
|
||||
}
|
||||
|
||||
interface ExecSyncOptions extends ExecCommonOptions {
|
||||
/**
|
||||
* Write some input to the `stdin` of your binary.
|
||||
* Streams are not allowed when using the synchronous methods.
|
||||
*/
|
||||
input?: string | Buffer;
|
||||
}
|
||||
|
||||
interface ExecReturns {
|
||||
/**
|
||||
* The command that was run.
|
||||
*/
|
||||
cmd: string;
|
||||
|
||||
/**
|
||||
* The exit code of the process that was run.
|
||||
*/
|
||||
code: number;
|
||||
|
||||
/**
|
||||
* Whether the process failed to run.
|
||||
*/
|
||||
failed: boolean;
|
||||
|
||||
/**
|
||||
* Whether the process was killed.
|
||||
*/
|
||||
killed: boolean;
|
||||
|
||||
/**
|
||||
* The signal that was used to terminate the process.
|
||||
*/
|
||||
signal: string | null;
|
||||
|
||||
/**
|
||||
* The output of the process on stderr.
|
||||
*/
|
||||
stderr: string;
|
||||
|
||||
/**
|
||||
* The output of the process on stdout.
|
||||
*/
|
||||
stdout: string;
|
||||
|
||||
/**
|
||||
* Whether the process timed out.
|
||||
*/
|
||||
timedOut: boolean;
|
||||
}
|
||||
|
||||
type ExecError = Error & ExecReturns;
|
||||
|
||||
interface ExecChildPromise {
|
||||
catch<TResult = never>(onrejected?: ((reason: ExecError) => TResult | PromiseLike<TResult>) | null): Promise<ExecReturns | TResult>;
|
||||
}
|
||||
|
||||
type ExecChildProcess = nodestd.child_process.ChildProcess & ExecChildPromise & Promise<ExecReturns>;
|
||||
}
|
||||
|
||||
function exec(cmd: string, args?: string[], opts?: I.ExecOptions): I.ExecChildProcess;
|
||||
function exec(cmd: string, opts?: I.ExecOptions): I.ExecChildProcess;
|
||||
|
||||
function execStdout(cmd: string, args?: string[], opts?: I.ExecOptions): Promise<string>;
|
||||
function execStdout(cmd: string, opts?: I.ExecOptions): Promise<string>;
|
||||
|
||||
function execStderr(cmd: string, args?: string[], opts?: I.ExecOptions): Promise<string>;
|
||||
function execStderr(cmd: string, opts?: I.ExecOptions): Promise<string>;
|
||||
|
||||
function shell(cmd: string, opts?: I.ExecOptions): I.ExecChildProcess;
|
||||
|
||||
function execSync(cmd: string, args?: string[], opts?: I.ExecSyncOptions): I.ExecReturns;
|
||||
|
||||
function shellSync(cmd: string, opts?: I.ExecSyncOptions): I.ExecReturns;
|
||||
}
|
||||
Vendored
+31
@@ -0,0 +1,31 @@
|
||||
declare namespace adone.system {
|
||||
/**
|
||||
* Utils for uid/gid
|
||||
*/
|
||||
namespace user {
|
||||
/**
|
||||
* Returns uid by the given username
|
||||
*/
|
||||
function uid(username: string): { uid: number, gid: number };
|
||||
|
||||
/**
|
||||
* Returns gid by the given groupname
|
||||
*/
|
||||
function gid(groupname: string): number;
|
||||
|
||||
/**
|
||||
* Returns gids the given user belongs
|
||||
*/
|
||||
function gids(username: string): number[];
|
||||
|
||||
/**
|
||||
* Returns username by the given uid
|
||||
*/
|
||||
function username(uid: number): string;
|
||||
|
||||
/**
|
||||
* Returns groupname by the given gid
|
||||
*/
|
||||
function groupname(gid: number): string;
|
||||
}
|
||||
}
|
||||
+41
@@ -0,0 +1,41 @@
|
||||
declare namespace adone.templating {
|
||||
namespace dot {
|
||||
namespace I {
|
||||
type RenderFunction = (...args: any[]) => string;
|
||||
|
||||
interface TemplateSettings {
|
||||
evaluate: RegExp;
|
||||
interpolate: RegExp;
|
||||
encode: RegExp;
|
||||
use: RegExp;
|
||||
useParams: RegExp;
|
||||
define: RegExp;
|
||||
defineParams: RegExp;
|
||||
conditional: RegExp;
|
||||
iterate: RegExp;
|
||||
varname: string;
|
||||
strip: boolean;
|
||||
append: boolean;
|
||||
selfcontained: boolean;
|
||||
}
|
||||
}
|
||||
const version: string;
|
||||
|
||||
let templateSettings: I.TemplateSettings;
|
||||
|
||||
function template(tmpl: string, c?: I.TemplateSettings, def?: {}): I.RenderFunction;
|
||||
|
||||
function compile(tmpl: string, def?: object): I.RenderFunction;
|
||||
|
||||
namespace I {
|
||||
interface ProcessOptions {
|
||||
path?: string;
|
||||
destination?: string;
|
||||
global?: string;
|
||||
templateSettings?: Partial<I.TemplateSettings>;
|
||||
}
|
||||
}
|
||||
|
||||
function process(options?: I.ProcessOptions): { [path: string]: I.RenderFunction };
|
||||
}
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
/// <reference path="./dot.d.ts" />
|
||||
/// <reference path="./nunjucks.d.ts" />
|
||||
|
||||
declare namespace adone {
|
||||
namespace templating {
|
||||
//
|
||||
}
|
||||
}
|
||||
+121
@@ -0,0 +1,121 @@
|
||||
declare namespace adone.templating {
|
||||
namespace nunjucks {
|
||||
namespace I {
|
||||
interface EnvironmentOptions {
|
||||
dev?: boolean;
|
||||
autoescape?: boolean;
|
||||
throOnUndefined?: boolean;
|
||||
trimBlocks?: boolean;
|
||||
lstripBlocks?: boolean;
|
||||
}
|
||||
|
||||
interface FileSystemLoaderOptions {
|
||||
watch?: boolean;
|
||||
noCache?: boolean;
|
||||
}
|
||||
|
||||
type ConfigureOptions = EnvironmentOptions & FileSystemLoaderOptions & {
|
||||
tags?: {
|
||||
blockStart?: string,
|
||||
blockEnd?: string,
|
||||
variableStart?: string,
|
||||
variableEnd?: string,
|
||||
commentStart?: string,
|
||||
commentEnd?: string
|
||||
};
|
||||
};
|
||||
|
||||
interface PrecompileOptions {
|
||||
name?: string;
|
||||
asFunction?: boolean;
|
||||
force?: boolean;
|
||||
env?: Environment;
|
||||
include?: string[];
|
||||
exclude?: string[];
|
||||
wrapper?(templates: { name: string, template: string }, opts: PrecompileOptions): string;
|
||||
}
|
||||
|
||||
interface Extension {
|
||||
tags: string[];
|
||||
parse(parser: any, nodes: any, lexer: any): any;
|
||||
}
|
||||
|
||||
interface LoaderSource {
|
||||
src: string;
|
||||
path: string;
|
||||
noCache: boolean;
|
||||
}
|
||||
|
||||
interface Loader {
|
||||
async?: boolean;
|
||||
getSource(name: string): LoaderSource;
|
||||
extend?(extender: Loader): Loader;
|
||||
}
|
||||
}
|
||||
|
||||
class Environment {
|
||||
options: {
|
||||
autoescape: boolean;
|
||||
};
|
||||
|
||||
constructor(loader?: I.Loader | I.Loader[] | null, opts?: I.EnvironmentOptions);
|
||||
render(name: string, context?: object): string;
|
||||
render(name: string, context?: object, callback?: (err: any, res: string) => any): void;
|
||||
|
||||
renderString(name: string, context?: object): string;
|
||||
renderString(name: string, context?: object, callback?: (err: any, res: string) => any): void;
|
||||
|
||||
addFilter(name: string, func: (...args: any[]) => any, async?: boolean): void;
|
||||
getFilter(name: string): (...args: any[]) => any;
|
||||
|
||||
addExtension(name: string, ext: I.Extension): void;
|
||||
removeExtension(name: string): void;
|
||||
getExtension(name: string): I.Extension;
|
||||
hasExtension(name: string): boolean;
|
||||
|
||||
addGlobal(name: string, value: any): this;
|
||||
|
||||
getTemplate(name: string, eagerCompile?: boolean): Template;
|
||||
getTemplate(name: string, eagerCompile?: boolean, callback?: (err: any, templ: Template) => Template): void;
|
||||
|
||||
express(app: object): void;
|
||||
}
|
||||
|
||||
class Template {
|
||||
constructor(src: string, env?: Environment, eagerCompile?: boolean);
|
||||
render(context?: object): string;
|
||||
render(context?: object, callback?: (err: any, res: string) => any): void;
|
||||
}
|
||||
|
||||
class Loader {
|
||||
on(name: string, func: (...args: any[]) => any): void;
|
||||
emit(name: string, ...args: any[]): void;
|
||||
resolve(from: string, to: string): string;
|
||||
isRelative(filename: string): boolean;
|
||||
extend(toExtend: I.Loader): I.Loader;
|
||||
}
|
||||
|
||||
class FileSystemLoader extends Loader implements I.Loader {
|
||||
constructor(searchPaths?: string | string[], opts?: I.FileSystemLoaderOptions);
|
||||
|
||||
getSource(name: string): I.LoaderSource;
|
||||
}
|
||||
|
||||
class PrecompiledLoader extends Loader implements I.Loader {
|
||||
getSource(name: string): I.LoaderSource;
|
||||
}
|
||||
|
||||
function renderSync(name: string, context?: object): string;
|
||||
function render(name: string, context?: object): Promise<string>;
|
||||
|
||||
function renderString(src: string, context?: object): Promise<string>;
|
||||
function renderStringSync(src: string, context?: object): string;
|
||||
|
||||
function compile(src: string, env?: Environment, path?: string, eagerCompile?: boolean): Template;
|
||||
|
||||
function configure(options?: I.ConfigureOptions): Environment;
|
||||
function configure(path: string | string[], options?: I.ConfigureOptions): Environment;
|
||||
|
||||
function installJinjaCompat(): void;
|
||||
}
|
||||
}
|
||||
Vendored
+77
@@ -0,0 +1,77 @@
|
||||
/// <reference path="./pretties.d.ts" />
|
||||
/// <reference path="./spinners.d.ts" />
|
||||
/// <reference path="./table.d.ts" />
|
||||
/// <reference path="./unicode.d.ts" />
|
||||
|
||||
declare namespace adone {
|
||||
namespace text {
|
||||
namespace escape {
|
||||
function regExpPattern(str: string): string;
|
||||
|
||||
function regExpReplacement(str: string): string;
|
||||
|
||||
function format(str: string): string;
|
||||
|
||||
function shellArg(str: string): string;
|
||||
|
||||
function control(str: string): string;
|
||||
|
||||
function htmlSpecialChars(str: string): string;
|
||||
}
|
||||
|
||||
namespace regexp {
|
||||
function array2alternatives(array: string[]): string;
|
||||
}
|
||||
|
||||
function escapeStringRegexp(str: string): string;
|
||||
|
||||
function toCamelCase(str: string): string;
|
||||
|
||||
function camelCaseToDashed(str: string): string;
|
||||
|
||||
const endLineRegExp: RegExp;
|
||||
|
||||
function splitLines(str: string): string[];
|
||||
|
||||
function regExpIndexOf(str: string, regex: RegExp, index?: number): string;
|
||||
|
||||
function stripAnsi(str: string): string;
|
||||
|
||||
function hasAnsi(str: string): boolean;
|
||||
|
||||
function random(len: number): string;
|
||||
|
||||
function detectNewLine(str: string): "\r\n" | "\n";
|
||||
|
||||
namespace I {
|
||||
interface WordWrapOptions {
|
||||
join?: boolean;
|
||||
mode?: "soft" | "hard";
|
||||
countAnsiEscapeCodes?: boolean;
|
||||
}
|
||||
}
|
||||
|
||||
function wordwrap(str: string, stop: number, options: I.WordWrapOptions & { join: false}): string[];
|
||||
function wordwrap(str: string, stop: number, options?: I.WordWrapOptions): string;
|
||||
|
||||
function stringDistance(strA: string, strB: string, memo?: number[][]): number;
|
||||
|
||||
function stringDistanceCapped(strA: string, strB: string, cap: number): number;
|
||||
|
||||
function capitalize(str: string): string;
|
||||
|
||||
function capitalizeWords(str: string): string;
|
||||
|
||||
function width(str: string): number;
|
||||
|
||||
function indent(string: string, spaces: number): string;
|
||||
|
||||
function stripEof(str: string): string;
|
||||
|
||||
function stripLastCRLF(str: string): string;
|
||||
|
||||
function stripBOM(str: string): string;
|
||||
|
||||
function toUTF8Array(str: string): number[];
|
||||
}
|
||||
}
|
||||
+55
@@ -0,0 +1,55 @@
|
||||
declare namespace adone.text {
|
||||
namespace pretty {
|
||||
namespace I {
|
||||
interface JSONOptions {
|
||||
emptyArrayMsg?: string;
|
||||
keysColor?: string;
|
||||
dashColor?: string;
|
||||
numberColor?: string;
|
||||
stringColor?: string;
|
||||
defaultIndentation?: number;
|
||||
noColor?: boolean;
|
||||
noAlign?: boolean;
|
||||
}
|
||||
}
|
||||
|
||||
function json(data: any, options?: I.JSONOptions, indentation?: number): string;
|
||||
|
||||
namespace I {
|
||||
interface TableColumn {
|
||||
id: string;
|
||||
header?: string;
|
||||
align?: "right" | "center" | "left";
|
||||
width?: string | number;
|
||||
maxWidth?: number | string;
|
||||
wordwrap?: "soft" | "hard" | adone.text.I.WordWrapOptions;
|
||||
handle?: (item: object) => string;
|
||||
format?: string | ((val: any, item: object) => string);
|
||||
style?: string | ((val: any, str: string) => string);
|
||||
}
|
||||
|
||||
type TableModel = TableColumn[];
|
||||
|
||||
interface TableStyle {
|
||||
"padding-left"?: number;
|
||||
"padding-right"?: number;
|
||||
head?: string[];
|
||||
broder?: string[];
|
||||
compact?: boolean;
|
||||
}
|
||||
|
||||
interface TableOptions {
|
||||
model: TableModel;
|
||||
noHeader?: boolean;
|
||||
borderless?: boolean;
|
||||
style?: TableStyle;
|
||||
width?: number | string;
|
||||
countAnsiEscapeCodes?: boolean;
|
||||
}
|
||||
|
||||
type TableData = Array<{ [id: string]: any }>;
|
||||
}
|
||||
|
||||
function table(data: I.TableData, options: I.TableOptions): string;
|
||||
}
|
||||
}
|
||||
+468
@@ -0,0 +1,468 @@
|
||||
declare namespace adone.text {
|
||||
namespace spinner {
|
||||
const dots: {
|
||||
interval: 80,
|
||||
frames: [
|
||||
"⠋",
|
||||
"⠙",
|
||||
"⠹",
|
||||
"⠸",
|
||||
"⠼",
|
||||
"⠴",
|
||||
"⠦",
|
||||
"⠧",
|
||||
"⠇",
|
||||
"⠏"
|
||||
]
|
||||
};
|
||||
const dots2: {
|
||||
interval: 80,
|
||||
frames: [
|
||||
"⣾",
|
||||
"⣽",
|
||||
"⣻",
|
||||
"⢿",
|
||||
"⡿",
|
||||
"⣟",
|
||||
"⣯",
|
||||
"⣷"
|
||||
]
|
||||
};
|
||||
const dots3: {
|
||||
interval: 80,
|
||||
frames: [
|
||||
"⠋",
|
||||
"⠙",
|
||||
"⠚",
|
||||
"⠞",
|
||||
"⠖",
|
||||
"⠦",
|
||||
"⠴",
|
||||
"⠲",
|
||||
"⠳",
|
||||
"⠓"
|
||||
]
|
||||
};
|
||||
const dots4: {
|
||||
interval: 80,
|
||||
frames: [
|
||||
"⠄",
|
||||
"⠆",
|
||||
"⠇",
|
||||
"⠋",
|
||||
"⠙",
|
||||
"⠸",
|
||||
"⠰",
|
||||
"⠠",
|
||||
"⠰",
|
||||
"⠸",
|
||||
"⠙",
|
||||
"⠋",
|
||||
"⠇",
|
||||
"⠆"
|
||||
]
|
||||
};
|
||||
const dots5: {
|
||||
interval: 80,
|
||||
frames: [
|
||||
"⠋",
|
||||
"⠙",
|
||||
"⠚",
|
||||
"⠒",
|
||||
"⠂",
|
||||
"⠂",
|
||||
"⠒",
|
||||
"⠲",
|
||||
"⠴",
|
||||
"⠦",
|
||||
"⠖",
|
||||
"⠒",
|
||||
"⠐",
|
||||
"⠐",
|
||||
"⠒",
|
||||
"⠓",
|
||||
"⠋"
|
||||
]
|
||||
};
|
||||
const dots6: {
|
||||
interval: 80,
|
||||
frames: [
|
||||
"⠁",
|
||||
"⠉",
|
||||
"⠙",
|
||||
"⠚",
|
||||
"⠒",
|
||||
"⠂",
|
||||
"⠂",
|
||||
"⠒",
|
||||
"⠲",
|
||||
"⠴",
|
||||
"⠤",
|
||||
"⠄",
|
||||
"⠄",
|
||||
"⠤",
|
||||
"⠴",
|
||||
"⠲",
|
||||
"⠒",
|
||||
"⠂",
|
||||
"⠂",
|
||||
"⠒",
|
||||
"⠚",
|
||||
"⠙",
|
||||
"⠉",
|
||||
"⠁"
|
||||
]
|
||||
};
|
||||
const dots7: {
|
||||
interval: 80,
|
||||
frames: [
|
||||
"⠈",
|
||||
"⠉",
|
||||
"⠋",
|
||||
"⠓",
|
||||
"⠒",
|
||||
"⠐",
|
||||
"⠐",
|
||||
"⠒",
|
||||
"⠖",
|
||||
"⠦",
|
||||
"⠤",
|
||||
"⠠",
|
||||
"⠠",
|
||||
"⠤",
|
||||
"⠦",
|
||||
"⠖",
|
||||
"⠒",
|
||||
"⠐",
|
||||
"⠐",
|
||||
"⠒",
|
||||
"⠓",
|
||||
"⠋",
|
||||
"⠉",
|
||||
"⠈"
|
||||
]
|
||||
};
|
||||
const dots8: {
|
||||
interval: 80,
|
||||
frames: [
|
||||
"⠁",
|
||||
"⠁",
|
||||
"⠉",
|
||||
"⠙",
|
||||
"⠚",
|
||||
"⠒",
|
||||
"⠂",
|
||||
"⠂",
|
||||
"⠒",
|
||||
"⠲",
|
||||
"⠴",
|
||||
"⠤",
|
||||
"⠄",
|
||||
"⠄",
|
||||
"⠤",
|
||||
"⠠",
|
||||
"⠠",
|
||||
"⠤",
|
||||
"⠦",
|
||||
"⠖",
|
||||
"⠒",
|
||||
"⠐",
|
||||
"⠐",
|
||||
"⠒",
|
||||
"⠓",
|
||||
"⠋",
|
||||
"⠉",
|
||||
"⠈",
|
||||
"⠈"
|
||||
]
|
||||
};
|
||||
const dots9: {
|
||||
interval: 80,
|
||||
frames: [
|
||||
"⢹",
|
||||
"⢺",
|
||||
"⢼",
|
||||
"⣸",
|
||||
"⣇",
|
||||
"⡧",
|
||||
"⡗",
|
||||
"⡏"
|
||||
]
|
||||
};
|
||||
const dots10: {
|
||||
interval: 80,
|
||||
frames: [
|
||||
"⢄",
|
||||
"⢂",
|
||||
"⢁",
|
||||
"⡁",
|
||||
"⡈",
|
||||
"⡐",
|
||||
"⡠"
|
||||
]
|
||||
};
|
||||
const dots11: {
|
||||
interval: 100,
|
||||
frames: [
|
||||
"⠁",
|
||||
"⠂",
|
||||
"⠄",
|
||||
"⡀",
|
||||
"⢀",
|
||||
"⠠",
|
||||
"⠐",
|
||||
"⠈"
|
||||
]
|
||||
};
|
||||
const dots12: {
|
||||
interval: 80,
|
||||
frames: [
|
||||
"⢀⠀",
|
||||
"⡀⠀",
|
||||
"⠄⠀",
|
||||
"⢂⠀",
|
||||
"⡂⠀",
|
||||
"⠅⠀",
|
||||
"⢃⠀",
|
||||
"⡃⠀",
|
||||
"⠍⠀",
|
||||
"⢋⠀",
|
||||
"⡋⠀",
|
||||
"⠍⠁",
|
||||
"⢋⠁",
|
||||
"⡋⠁",
|
||||
"⠍⠉",
|
||||
"⠋⠉",
|
||||
"⠋⠉",
|
||||
"⠉⠙",
|
||||
"⠉⠙",
|
||||
"⠉⠩",
|
||||
"⠈⢙",
|
||||
"⠈⡙",
|
||||
"⢈⠩",
|
||||
"⡀⢙",
|
||||
"⠄⡙",
|
||||
"⢂⠩",
|
||||
"⡂⢘",
|
||||
"⠅⡘",
|
||||
"⢃⠨",
|
||||
"⡃⢐",
|
||||
"⠍⡐",
|
||||
"⢋⠠",
|
||||
"⡋⢀",
|
||||
"⠍⡁",
|
||||
"⢋⠁",
|
||||
"⡋⠁",
|
||||
"⠍⠉",
|
||||
"⠋⠉",
|
||||
"⠋⠉",
|
||||
"⠉⠙",
|
||||
"⠉⠙",
|
||||
"⠉⠩",
|
||||
"⠈⢙",
|
||||
"⠈⡙",
|
||||
"⠈⠩",
|
||||
"⠀⢙",
|
||||
"⠀⡙",
|
||||
"⠀⠩",
|
||||
"⠀⢘",
|
||||
"⠀⡘",
|
||||
"⠀⠨",
|
||||
"⠀⢐",
|
||||
"⠀⡐",
|
||||
"⠀⠠",
|
||||
"⠀⢀",
|
||||
"⠀⡀"
|
||||
]
|
||||
};
|
||||
const line: {
|
||||
interval: 130,
|
||||
frames: [
|
||||
"-",
|
||||
"\\",
|
||||
"|",
|
||||
"/"
|
||||
]
|
||||
};
|
||||
const pipe: {
|
||||
interval: 100,
|
||||
frames: [
|
||||
"┤",
|
||||
"┘",
|
||||
"┴",
|
||||
"└",
|
||||
"├",
|
||||
"┌",
|
||||
"┬",
|
||||
"┐"
|
||||
]
|
||||
};
|
||||
const simpleDots: {
|
||||
interval: 200,
|
||||
frames: [
|
||||
". ",
|
||||
".. ",
|
||||
"...",
|
||||
" ..",
|
||||
" .",
|
||||
" "
|
||||
]
|
||||
};
|
||||
const flip: {
|
||||
interval: 70,
|
||||
frames: [
|
||||
"_",
|
||||
"_",
|
||||
"_",
|
||||
"-",
|
||||
"`",
|
||||
"`",
|
||||
"'",
|
||||
"´",
|
||||
"-",
|
||||
"_",
|
||||
"_",
|
||||
"_"
|
||||
]
|
||||
};
|
||||
const growVertical: {
|
||||
interval: 120,
|
||||
frames: [
|
||||
"▁",
|
||||
"▃",
|
||||
"▄",
|
||||
"▅",
|
||||
"▆",
|
||||
"▇",
|
||||
"▆",
|
||||
"▅",
|
||||
"▄",
|
||||
"▃"
|
||||
]
|
||||
};
|
||||
const growHorizontal: {
|
||||
interval: 120,
|
||||
frames: [
|
||||
"▏",
|
||||
"▎",
|
||||
"▍",
|
||||
"▌",
|
||||
"▋",
|
||||
"▊",
|
||||
"▉",
|
||||
"▊",
|
||||
"▋",
|
||||
"▌",
|
||||
"▍",
|
||||
"▎"
|
||||
]
|
||||
};
|
||||
const boxBounce: {
|
||||
interval: 120,
|
||||
frames: [
|
||||
"▖",
|
||||
"▘",
|
||||
"▝",
|
||||
"▗"
|
||||
]
|
||||
};
|
||||
const boxBounce2: {
|
||||
interval: 100,
|
||||
frames: [
|
||||
"▌",
|
||||
"▀",
|
||||
"▐",
|
||||
"▄"
|
||||
]
|
||||
};
|
||||
const triangle: {
|
||||
interval: 50,
|
||||
frames: [
|
||||
"◢",
|
||||
"◣",
|
||||
"◤",
|
||||
"◥"
|
||||
]
|
||||
};
|
||||
const squareCorners: {
|
||||
interval: 180,
|
||||
frames: [
|
||||
"◰",
|
||||
"◳",
|
||||
"◲",
|
||||
"◱"
|
||||
]
|
||||
};
|
||||
const circleQuarters: {
|
||||
interval: 120,
|
||||
frames: [
|
||||
"◴",
|
||||
"◷",
|
||||
"◶",
|
||||
"◵"
|
||||
]
|
||||
};
|
||||
const circleHalves: {
|
||||
interval: 80,
|
||||
frames: [
|
||||
"◐",
|
||||
"◓",
|
||||
"◑",
|
||||
"◒"
|
||||
]
|
||||
};
|
||||
const arrow: {
|
||||
interval: 80,
|
||||
frames: [
|
||||
"⬆️ ",
|
||||
"↗️ ",
|
||||
"➡️ ",
|
||||
"↘️ ",
|
||||
"⬇️ ",
|
||||
"↙️ ",
|
||||
"⬅️ ",
|
||||
"↖️ "
|
||||
]
|
||||
};
|
||||
const arrow3: {
|
||||
interval: 120,
|
||||
frames: [
|
||||
"▹▹▹▹▹",
|
||||
"▸▹▹▹▹",
|
||||
"▹▸▹▹▹",
|
||||
"▹▹▸▹▹",
|
||||
"▹▹▹▸▹",
|
||||
"▹▹▹▹▸"
|
||||
]
|
||||
};
|
||||
const bouncingBar: {
|
||||
interval: 80,
|
||||
frames: [
|
||||
"[ ]",
|
||||
"[ =]",
|
||||
"[ ==]",
|
||||
"[ ===]",
|
||||
"[====]",
|
||||
"[=== ]",
|
||||
"[== ]",
|
||||
"[= ]"
|
||||
]
|
||||
};
|
||||
const clock: {
|
||||
interval: 100,
|
||||
frames: [
|
||||
"🕐 ",
|
||||
"🕑 ",
|
||||
"🕒 ",
|
||||
"🕓 ",
|
||||
"🕔 ",
|
||||
"🕕 ",
|
||||
"🕖 ",
|
||||
"🕗 ",
|
||||
"🕘 ",
|
||||
"🕙 ",
|
||||
"🕚 "
|
||||
]
|
||||
};
|
||||
}
|
||||
}
|
||||
Vendored
+73
@@ -0,0 +1,73 @@
|
||||
declare namespace adone.text {
|
||||
namespace table {
|
||||
namespace I {
|
||||
interface CharsOptions {
|
||||
top: string;
|
||||
"top-mid": string;
|
||||
"top-left": string;
|
||||
"top-right": string;
|
||||
bottom: string;
|
||||
"bottom-mid": string;
|
||||
"bottom-left": string;
|
||||
"bottom-right": string;
|
||||
left: string;
|
||||
"left-mid": string;
|
||||
mid: string;
|
||||
"mid-mid": string;
|
||||
right: string;
|
||||
"right-mid": string;
|
||||
middle: string;
|
||||
}
|
||||
|
||||
interface StyleOptions {
|
||||
"padding-left": number;
|
||||
"padding-right": number;
|
||||
head: string[];
|
||||
border: string[];
|
||||
compact: boolean;
|
||||
}
|
||||
|
||||
interface CommonOptions {
|
||||
truncate: string;
|
||||
colWidths: number[];
|
||||
rowHeights: number[];
|
||||
colAligns: Array<"left" | "center" | "right">;
|
||||
rowAligns: Array<"top" | "center" | "bottom">;
|
||||
head: string[];
|
||||
}
|
||||
|
||||
interface Options extends CommonOptions {
|
||||
style: StyleOptions;
|
||||
chars: CharsOptions;
|
||||
}
|
||||
|
||||
interface ConstructorOptions extends Partial<CommonOptions> {
|
||||
style?: Partial<StyleOptions>;
|
||||
chars?: Partial<CharsOptions>;
|
||||
}
|
||||
}
|
||||
|
||||
class Table extends Array {
|
||||
constructor(options?: I.ConstructorOptions);
|
||||
|
||||
toString(): string;
|
||||
|
||||
readonly width: number;
|
||||
|
||||
static readonly defaultOptions: I.Options;
|
||||
}
|
||||
|
||||
namespace I {
|
||||
interface BorderlessConstructorOptions {
|
||||
colWidths?: number[];
|
||||
head?: string[];
|
||||
colAligns?: Array<"left" | "center" | "right">;
|
||||
style?: Partial<StyleOptions>;
|
||||
}
|
||||
}
|
||||
|
||||
class BorderlessTable extends Table {
|
||||
constructor(options?: I.BorderlessConstructorOptions);
|
||||
}
|
||||
}
|
||||
}
|
||||
+137
@@ -0,0 +1,137 @@
|
||||
declare namespace adone.text {
|
||||
namespace unicode {
|
||||
const symbol: {
|
||||
tick: "✔",
|
||||
cross: "✖",
|
||||
star: "★",
|
||||
square: "▇",
|
||||
squareSmall: "◻",
|
||||
squareSmallFilled: "◼",
|
||||
play: "▶",
|
||||
circle: "◯",
|
||||
circleFilled: "◉",
|
||||
circleDotted: "◌",
|
||||
circleDouble: "◎",
|
||||
circleCircle: "ⓞ",
|
||||
circleCross: "ⓧ",
|
||||
circlePipe: "Ⓘ",
|
||||
circleQuestionMark: "?⃝",
|
||||
bullet: "●",
|
||||
dot: "․",
|
||||
line: "─",
|
||||
ellipsis: "…",
|
||||
pointer: "❯",
|
||||
pointerSmall: "›",
|
||||
info: "ℹ",
|
||||
warning: "⚠",
|
||||
hamburger: "☰",
|
||||
smiley: "㋡",
|
||||
mustache: "෴",
|
||||
heart: "♥",
|
||||
arrowUp: "↑",
|
||||
arrowDown: "↓",
|
||||
arrowLeft: "←",
|
||||
arrowRight: "→",
|
||||
radioOn: "◉",
|
||||
radioOff: "◯",
|
||||
checkboxOn: "☒",
|
||||
checkboxOff: "☐",
|
||||
checkboxCircleOn: "ⓧ",
|
||||
checkboxCircleOff: "Ⓘ",
|
||||
questionMarkPrefix: "?" | "?⃝",
|
||||
oneHalf: "½",
|
||||
oneThird: "⅓",
|
||||
oneQuarter: "¼",
|
||||
oneFifth: "⅕",
|
||||
oneSixth: "⅙",
|
||||
oneSeventh: "⅐",
|
||||
oneEighth: "⅛",
|
||||
oneNinth: "⅑",
|
||||
oneTenth: "⅒",
|
||||
twoThirds: "⅔",
|
||||
twoFifths: "⅖",
|
||||
threeQuarters: "¾",
|
||||
threeFifths: "⅗",
|
||||
threeEighths: "⅜",
|
||||
fourFifths: "⅘",
|
||||
fiveSixths: "⅚",
|
||||
fiveEighths: "⅝",
|
||||
sevenEighths: "⅞",
|
||||
minus: "−"
|
||||
};
|
||||
|
||||
const symbolFallback: {
|
||||
tick: "√",
|
||||
cross: "×",
|
||||
star: "*",
|
||||
square: "█",
|
||||
squareSmall: "[ ]",
|
||||
squareSmallFilled: "[█]",
|
||||
play: "►",
|
||||
circle: "( )",
|
||||
circleFilled: "(*)",
|
||||
circleDotted: "( )",
|
||||
circleDouble: "( )",
|
||||
circleCircle: "(○)",
|
||||
circleCross: "(×)",
|
||||
circlePipe: "(│)",
|
||||
circleQuestionMark: "(?)",
|
||||
bullet: "*",
|
||||
dot: ".",
|
||||
line: "─",
|
||||
ellipsis: "...",
|
||||
pointer: ">",
|
||||
pointerSmall: "»",
|
||||
info: "i",
|
||||
warning: "‼",
|
||||
hamburger: "≡",
|
||||
smiley: "☺",
|
||||
mustache: "┌─┐",
|
||||
heart: "♥",
|
||||
arrowUp: "↑",
|
||||
arrowDown: "↓",
|
||||
arrowLeft: "←",
|
||||
arrowRight: "→",
|
||||
radioOn: "(*)",
|
||||
radioOff: "( )",
|
||||
checkboxOn: "[×]",
|
||||
checkboxOff: "[ ]",
|
||||
checkboxCircleOn: "(×)",
|
||||
checkboxCircleOff: "( )",
|
||||
questionMarkPrefix: "?",
|
||||
oneHalf: "1/2",
|
||||
oneThird: "1/3",
|
||||
oneQuarter: "1/4",
|
||||
oneFifth: "1/5",
|
||||
oneSixth: "1/6",
|
||||
oneSeventh: "1/7",
|
||||
oneEighth: "1/8",
|
||||
oneNinth: "1/9",
|
||||
oneTenth: "1/10",
|
||||
twoThirds: "2/3",
|
||||
twoFifths: "2/5",
|
||||
threeQuarters: "3/4",
|
||||
threeFifths: "3/5",
|
||||
threeEighths: "3/8",
|
||||
fourFifths: "4/5",
|
||||
fiveSixths: "5/6",
|
||||
fiveEighths: "5/8",
|
||||
sevenEighths: "7/8",
|
||||
minus: "-"
|
||||
};
|
||||
|
||||
function approx(str: string): string;
|
||||
|
||||
function length(str: string): number;
|
||||
|
||||
function toArray(str: string): string[];
|
||||
|
||||
function surrogatePair(char: string): number;
|
||||
|
||||
function isFullWidthCodePoint(code: number): boolean;
|
||||
|
||||
function isFullWidth(char: string): boolean;
|
||||
|
||||
function toFullWidth(str: string): string;
|
||||
}
|
||||
}
|
||||
Vendored
+243
-1
@@ -252,7 +252,225 @@ declare namespace adone {
|
||||
function delegate(object: object, property: string): I.Delegator;
|
||||
|
||||
namespace iconv {
|
||||
// TODO: need to normalize source code
|
||||
namespace I {
|
||||
namespace encoding {
|
||||
type Native = "UTF-8"
|
||||
| "UCS-2"
|
||||
| "UTF-16LE"
|
||||
| "ASCII"
|
||||
| "Binary"
|
||||
| "Base64"
|
||||
| "Hex";
|
||||
|
||||
type Unicode = "UTF-16BE" | "UTF-16";
|
||||
|
||||
type Windows = "874"
|
||||
| "1250"
|
||||
| "1251"
|
||||
| "1252"
|
||||
| "1253"
|
||||
| "1254"
|
||||
| "1255"
|
||||
| "1256"
|
||||
| "1257"
|
||||
| "1258"
|
||||
| "CP874"
|
||||
| "CP1251"
|
||||
| "CP1252"
|
||||
| "CP1253"
|
||||
| "CP1254"
|
||||
| "CP1255"
|
||||
| "CP1256"
|
||||
| "CP1257"
|
||||
| "CP1258"
|
||||
| "Win-1251"
|
||||
| "Win-1252"
|
||||
| "Win-1253"
|
||||
| "Win-1254"
|
||||
| "Win-1255"
|
||||
| "Win-1256"
|
||||
| "Win-1257"
|
||||
| "Win-1258"
|
||||
| "Windows-1251"
|
||||
| "Windows-1252"
|
||||
| "Windows-1253"
|
||||
| "Windows-1254"
|
||||
| "Windows-1255"
|
||||
| "Windows-1256"
|
||||
| "Windows-1257"
|
||||
| "Windows-1258";
|
||||
|
||||
type ISO = "ISO-8829-1"
|
||||
| "ISO-8859-2"
|
||||
| "ISO-8859-3"
|
||||
| "ISO-8859-4"
|
||||
| "ISO-8859-5"
|
||||
| "ISO-8859-6"
|
||||
| "ISO-8859-7"
|
||||
| "ISO-8859-8"
|
||||
| "ISO-8859-9"
|
||||
| "ISO-8859-10"
|
||||
| "ISO-8859-11"
|
||||
| "ISO-8859-12"
|
||||
| "ISO-8859-13"
|
||||
| "ISO-8859-14"
|
||||
| "ISO-8859-15"
|
||||
| "ISO-8859-16";
|
||||
|
||||
type IBM = "437"
|
||||
| "737"
|
||||
| "775"
|
||||
| "808"
|
||||
| "850"
|
||||
| "852"
|
||||
| "855"
|
||||
| "856"
|
||||
| "857"
|
||||
| "858"
|
||||
| "860"
|
||||
| "861"
|
||||
| "862"
|
||||
| "863"
|
||||
| "864"
|
||||
| "865"
|
||||
| "866"
|
||||
| "869"
|
||||
| "922"
|
||||
| "1046"
|
||||
| "1124"
|
||||
| "1125"
|
||||
| "1129"
|
||||
| "1133"
|
||||
| "1161"
|
||||
| "1163"
|
||||
| "CP437"
|
||||
| "CP737"
|
||||
| "CP775"
|
||||
| "CP808"
|
||||
| "CP850"
|
||||
| "CP852"
|
||||
| "CP855"
|
||||
| "CP856"
|
||||
| "CP857"
|
||||
| "CP858"
|
||||
| "CP860"
|
||||
| "CP861"
|
||||
| "CP862"
|
||||
| "CP863"
|
||||
| "CP864"
|
||||
| "CP865"
|
||||
| "CP866"
|
||||
| "CP869"
|
||||
| "CP922"
|
||||
| "CP1046"
|
||||
| "CP1124"
|
||||
| "CP1125"
|
||||
| "CP1129"
|
||||
| "CP1133"
|
||||
| "CP1161"
|
||||
| "CP1163"
|
||||
| "IBM437"
|
||||
| "IBM737"
|
||||
| "IBM775"
|
||||
| "IBM808"
|
||||
| "IBM850"
|
||||
| "IBM852"
|
||||
| "IBM855"
|
||||
| "IBM856"
|
||||
| "IBM857"
|
||||
| "IBM858"
|
||||
| "IBM860"
|
||||
| "IBM861"
|
||||
| "IBM862"
|
||||
| "IBM863"
|
||||
| "IBM864"
|
||||
| "IBM865"
|
||||
| "IBM866"
|
||||
| "IBM869"
|
||||
| "IBM922"
|
||||
| "IBM1046"
|
||||
| "IBM1124"
|
||||
| "IBM1125"
|
||||
| "IBM1129"
|
||||
| "IBM1133"
|
||||
| "IBM1161"
|
||||
| "IBM1163";
|
||||
|
||||
type Mac = "MacCroatian"
|
||||
| "MacCyrillic"
|
||||
| "MacGreek"
|
||||
| "MacIceland"
|
||||
| "MacRoman"
|
||||
| "MacThai"
|
||||
| "MacTurkish"
|
||||
| "MacUkraine"
|
||||
| "MacCentEuro"
|
||||
| "Macintosh";
|
||||
|
||||
type KOI8 = "KOI8-R"
|
||||
| "KOI8-U"
|
||||
| "KOI8-RU"
|
||||
| "KOI8-T";
|
||||
|
||||
type Misc = "ArmSCII8"
|
||||
| "RK1048"
|
||||
| "TCVN"
|
||||
| "GEORGIAN-ACADEMY"
|
||||
| "GEORGIAN-PS"
|
||||
| "PT154"
|
||||
| "VISCII"
|
||||
| "ISO-646-CN"
|
||||
| "ISO-646-JP"
|
||||
| "HP Roman-8"
|
||||
| "TIS-620";
|
||||
|
||||
type Singlebyte = Windows
|
||||
| ISO
|
||||
| IBM
|
||||
| Mac
|
||||
| KOI8
|
||||
| Misc;
|
||||
|
||||
type Japanese = "Shift_JIS"
|
||||
| "Windows-31J"
|
||||
| "windows-932"
|
||||
| "EUC-JP";
|
||||
|
||||
type Chinese = "GB2312"
|
||||
| "GBK"
|
||||
| "GB18030"
|
||||
| "Windows-936"
|
||||
| "EUC-CN";
|
||||
|
||||
type Korean = "KS_C_5601"
|
||||
| "Windows-949"
|
||||
| "EUC-KR";
|
||||
|
||||
type TaiwanHongKong = "Big5"
|
||||
| "Big5-HKSCS"
|
||||
| "Windows-950";
|
||||
|
||||
type Multibyte = Japanese
|
||||
| Chinese
|
||||
| Korean
|
||||
| TaiwanHongKong;
|
||||
}
|
||||
|
||||
type SupportedEncoding = encoding.Native
|
||||
| encoding.Unicode
|
||||
| encoding.Singlebyte
|
||||
| encoding.Multibyte;
|
||||
}
|
||||
|
||||
const defaultCharUnicode: "�";
|
||||
|
||||
const defaultCharSingleByte: "?";
|
||||
|
||||
function encodingExists(encoding: string): boolean;
|
||||
|
||||
function encode(buffer: string, encoding: I.SupportedEncoding, options?: object): Buffer;
|
||||
|
||||
function decode(buffer: Buffer, encoding: I.SupportedEncoding, options?: object): string;
|
||||
}
|
||||
|
||||
namespace sqlstring {
|
||||
@@ -337,7 +555,31 @@ declare namespace adone {
|
||||
drop?: boolean;
|
||||
dropLast?: boolean;
|
||||
}
|
||||
|
||||
interface CreateFunction {
|
||||
<R>(fn: () => Promise<R>): Promise<R>;
|
||||
<R>(fn: () => R): Promise<R>;
|
||||
|
||||
<T1, R>(fn: (a: T1) => Promise<R>, a: T1): Promise<R>;
|
||||
<T1, R>(fn: (a: T1) => R, a: T1): Promise<R>;
|
||||
|
||||
<T1, T2, R>(fn: (a: T1, b: T2) => Promise<R>, a: T1, b: T2): Promise<R>;
|
||||
<T1, T2, R>(fn: (a: T1, b: T2) => R, a: T1, b: T2): Promise<R>;
|
||||
|
||||
<T1, T2, T3, R>(fn: (a: T1, b: T2, c: T3) => Promise<R>, a: T1, b: T2, c: T3): Promise<R>;
|
||||
<T1, T2, T3, R>(fn: (a: T1, b: T2, c: T3) => R, a: T1, b: T2, c: T3): Promise<R>;
|
||||
|
||||
<T1, T2, T3, T4, R>(fn: (a: T1, b: T2, c: T3, d: T4) => Promise<R>, a: T1, b: T2, c: T3, d: T4): Promise<R>;
|
||||
<T1, T2, T3, T4, R>(fn: (a: T1, b: T2, c: T3, d: T4) => R, a: T1, b: T2, c: T3, d: T4): Promise<R>;
|
||||
|
||||
<T1, T2, T3, T4, T5, R>(fn: (a: T1, b: T2, c: T3, d: T4, e: T5) => Promise<R>, a: T1, b: T2, c: T3, d: T4, e: T5): Promise<R>;
|
||||
<T1, T2, T3, T4, T5, R>(fn: (a: T1, b: T2, c: T3, d: T4, e: T5) => R, a: T1, b: T2, c: T3, d: T4, e: T5): Promise<R>;
|
||||
|
||||
<R>(fn: (...args: any[]) => Promise<R>, ...args: any[]): Promise<R>;
|
||||
<R>(fn: (...args: any[]) => R, ...args: any[]): Promise<R>;
|
||||
}
|
||||
}
|
||||
function create(options?: I.Options): I.CreateFunction;
|
||||
function create<R>(fn: () => R, options?: I.Options): () => Promise<R>;
|
||||
function create<T1, R>(fn: (a: T1) => R, options?: I.Options): (a: T1) => Promise<R>;
|
||||
function create<T1, T2, R>(fn: (a: T1, b: T2) => R, options?: I.Options): (a: T1, b: T2) => Promise<R>;
|
||||
|
||||
Vendored
+10
-2
@@ -8,22 +8,30 @@
|
||||
/// <reference path="./glosses/application.d.ts" />
|
||||
/// <reference path="./glosses/archives.d.ts" />
|
||||
/// <reference path="./glosses/assertion.d.ts" />
|
||||
/// <reference path="./glosses/collections.d.ts" />
|
||||
/// <reference path="./glosses/collections/index.d.ts" />
|
||||
/// <reference path="./glosses/compressors.d.ts" />
|
||||
/// <reference path="./glosses/crypto/index.d.ts" />
|
||||
/// <reference path="./glosses/data.d.ts" />
|
||||
/// <reference path="./glosses/datetime.d.ts" />
|
||||
/// <reference path="./glosses/events.d.ts" />
|
||||
/// <reference path="./glosses/exceptions.d.ts" />
|
||||
/// <reference path="./glosses/fake.d.ts" />
|
||||
/// <reference path="./glosses/fast.d.ts" />
|
||||
/// <reference path="./glosses/fs.d.ts" />
|
||||
/// <reference path="./glosses/is.d.ts" />
|
||||
/// <reference path="./glosses/math/index.d.ts" />
|
||||
/// <reference path="./glosses/meta.d.ts" />
|
||||
/// <reference path="./glosses/net/index.d.ts" />
|
||||
/// <reference path="./glosses/promise.d.ts" />
|
||||
/// <reference path="./glosses/shani.d.ts" />
|
||||
/// <reference path="./glosses/regex.d.ts" />
|
||||
/// <reference path="./glosses/semver.d.ts" />
|
||||
/// <reference path="./glosses/shani-global.d.ts" />
|
||||
/// <reference path="./glosses/shani.d.ts" />
|
||||
/// <reference path="./glosses/std.d.ts" />
|
||||
/// <reference path="./glosses/streams.d.ts" />
|
||||
/// <reference path="./glosses/system/index.d.ts" />
|
||||
/// <reference path="./glosses/templating/index.d.ts" />
|
||||
/// <reference path="./glosses/text/index.d.ts" />
|
||||
/// <reference path="./glosses/utils.d.ts" />
|
||||
|
||||
declare const _adone: typeof adone;
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,19 @@
|
||||
namespace adoneTests.collection.ArraySet {
|
||||
const {
|
||||
collection: {
|
||||
ArraySet
|
||||
}
|
||||
} = adone;
|
||||
|
||||
type ArraySet<T = any> = adone.collection.ArraySet<T>;
|
||||
|
||||
new ArraySet();
|
||||
{ const a: number = new ArraySet().length; }
|
||||
{ const a: ArraySet = new ArraySet<string>().add("hello"); }
|
||||
{ const a: ArraySet = new ArraySet<string>().add("hello", true); }
|
||||
{ const a: boolean = new ArraySet<string>().has("string"); }
|
||||
{ const a: number = new ArraySet<string>().indexOf("hello"); }
|
||||
{ const a: string[] = new ArraySet<string>().toArray(); }
|
||||
{ const a: ArraySet<number> = ArraySet.from([1]); }
|
||||
{ const a: ArraySet<number> = ArraySet.from([1], true); }
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
namespace adoneTests.collection.AsyncQueue {
|
||||
const {
|
||||
collection: {
|
||||
AsyncQueue
|
||||
}
|
||||
} = adone;
|
||||
|
||||
type AsyncQueue = adone.collection.AsyncQueue;
|
||||
|
||||
{ const a: AsyncQueue = new AsyncQueue().push(123); }
|
||||
{ const a: Promise<number> = new AsyncQueue<number>().push(123).pop(); }
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
namespace adoneTests.collection.AVLTree {
|
||||
const {
|
||||
collection: {
|
||||
AVLTree
|
||||
}
|
||||
} = adone;
|
||||
|
||||
type AVLTree<K = any, V = any> = adone.collection.AVLTree<K, V>;
|
||||
|
||||
new AVLTree();
|
||||
new AVLTree<string, number>({ checkValueEquality: (a: number, b: number) => a === b });
|
||||
new AVLTree<string, number>({ compareKeys: (a: string, b: string) => a.length - b.length });
|
||||
new AVLTree<string, number>({ parent: new AVLTree() });
|
||||
new AVLTree<string, number>({ unique: false });
|
||||
new AVLTree<string, number>({ value: 123 });
|
||||
new AVLTree<string, number>().checkIsAVLT();
|
||||
new AVLTree<string, number>().insert("123", 123);
|
||||
new AVLTree<string, number>().delete("123");
|
||||
new AVLTree<string, number>().delete("123", 123);
|
||||
{ const a: number = new AVLTree<string, number>().getNumberOFKeys(); }
|
||||
{ const a: number[] = new AVLTree<string, number>().search("key"); }
|
||||
{ const a: number[] = new AVLTree<string, number>().betweenBounds({}); }
|
||||
{ const a: number[] = new AVLTree<string, number>().betweenBounds({ $gt: "ads" }); }
|
||||
{ const a: number[] = new AVLTree<string, number>().betweenBounds({ $lt: "ads" }); }
|
||||
{ const a: number[] = new AVLTree<string, number>().betweenBounds({ $gte: "ads" }); }
|
||||
{ const a: number[] = new AVLTree<string, number>().betweenBounds({ $lte: "ads" }); }
|
||||
new AVLTree<string, number>().executeOnEveryNode((tree: AVLTree<string, number>) => null);
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
namespace adoneTests.collection.BinarySearchTree {
|
||||
const {
|
||||
collection: {
|
||||
BinarySearchTree
|
||||
}
|
||||
} = adone;
|
||||
|
||||
type BinarySearchTree<K = any, V = any> = adone.collection.BinarySearchTree<K, V>;
|
||||
|
||||
new BinarySearchTree();
|
||||
new BinarySearchTree({});
|
||||
new BinarySearchTree<string, number>({ checkValueEquality: (a: number, b: number) => a === b });
|
||||
new BinarySearchTree<string, number>({ compareKeys: (a: string, b: string) => a.length - b.length });
|
||||
new BinarySearchTree<string, number>({ parent: new BinarySearchTree<string, number>() });
|
||||
new BinarySearchTree<string, number>({ unique: true });
|
||||
new BinarySearchTree<string, number>({ value: 123 });
|
||||
{ const a: BinarySearchTree<string, number> = new BinarySearchTree<string, number>().getMaxKeyDescendant(); }
|
||||
{ const a: string = new BinarySearchTree<string, number>().getMaxKey(); }
|
||||
{ const a: BinarySearchTree<string, number> = new BinarySearchTree<string, number>().getMinKeyDescendant(); }
|
||||
{ const a: string = new BinarySearchTree<string, number>().getMinKey(); }
|
||||
new BinarySearchTree<string, number>().checkAllNodesFullfillCondition((key: string, value: number) => null);
|
||||
new BinarySearchTree<string, number>().checkIsBST();
|
||||
{ const a: number = new BinarySearchTree<string, number>().getNumberOfKeys(); }
|
||||
new BinarySearchTree<string, number>().insert("asd", 123);
|
||||
{ const a: number[] = new BinarySearchTree<string, number>().search("asd"); }
|
||||
{ const a: number[] = new BinarySearchTree<string, number>().betweenBounds({ $gt: "" }); }
|
||||
{ const a: number[] = new BinarySearchTree<string, number>().betweenBounds({ $lt: "" }); }
|
||||
{ const a: number[] = new BinarySearchTree<string, number>().betweenBounds({ $lte: "" }); }
|
||||
{ const a: number[] = new BinarySearchTree<string, number>().betweenBounds({ $gte: "" }); }
|
||||
new BinarySearchTree<string, number>().delete("key");
|
||||
new BinarySearchTree<string, number>().delete("key", 123);
|
||||
new BinarySearchTree<string, number>().executeOnEveryNode((tree: BinarySearchTree<string, number>) => null);
|
||||
new BinarySearchTree<string, number>().prettyPrint();
|
||||
new BinarySearchTree<string, number>().prettyPrint(true);
|
||||
new BinarySearchTree<string, number>().prettyPrint(true, " ");
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
namespace adoneTests.collection.BufferList {
|
||||
const {
|
||||
collection: {
|
||||
BufferList
|
||||
}
|
||||
} = adone;
|
||||
|
||||
type BufferList = adone.collection.BufferList;
|
||||
|
||||
new BufferList();
|
||||
new BufferList(Buffer.from("123"));
|
||||
new BufferList("123");
|
||||
new BufferList(123);
|
||||
new BufferList([Buffer.from("123"), "123", 123]);
|
||||
new BufferList((err: any, data: Buffer) => null);
|
||||
new BufferList().append(Buffer.from("123"));
|
||||
new BufferList().append("123");
|
||||
new BufferList().append(123);
|
||||
new BufferList().append([Buffer.from("123"), "123", 123]);
|
||||
new BufferList().end(Buffer.from("123"));
|
||||
new BufferList().end();
|
||||
{ const a: number = new BufferList().get(123); }
|
||||
{ const a: Buffer = new BufferList().slice(); }
|
||||
{ const a: Buffer = new BufferList().slice(1); }
|
||||
{ const a: Buffer = new BufferList().slice(1, 2); }
|
||||
{ const a: Buffer = new BufferList().copy(Buffer.alloc(100)); }
|
||||
{ const a: Buffer = new BufferList().copy(Buffer.alloc(100), 0); }
|
||||
{ const a: Buffer = new BufferList().copy(Buffer.alloc(100), 0, 1); }
|
||||
{ const a: Buffer = new BufferList().copy(Buffer.alloc(100), 0, 1, 2); }
|
||||
{ const a: BufferList = new BufferList().shallowSlice(); }
|
||||
{ const a: BufferList = new BufferList().shallowSlice(1); }
|
||||
{ const a: BufferList = new BufferList().shallowSlice(1, 2); }
|
||||
{ const a: string = new BufferList().toString(); }
|
||||
{ const a: string = new BufferList().toString("utf8"); }
|
||||
{ const a: string = new BufferList().toString("utf8", 1); }
|
||||
{ const a: string = new BufferList().toString("utf8", 1, 2); }
|
||||
{ const a: BufferList = new BufferList().consume(10); }
|
||||
{ const a: BufferList = new BufferList().duplicate(); }
|
||||
new BufferList().destroy();
|
||||
new BufferList().then((x: Buffer) => null);
|
||||
new BufferList().catch((err: any) => null);
|
||||
}
|
||||
@@ -0,0 +1,561 @@
|
||||
namespace adoneTests.collection.ByteArray {
|
||||
const {
|
||||
collection: {
|
||||
ByteArray
|
||||
}
|
||||
} = adone;
|
||||
|
||||
new ByteArray();
|
||||
new ByteArray(10);
|
||||
new ByteArray(10, true);
|
||||
|
||||
const buffer = new ByteArray();
|
||||
|
||||
buffer.woffset === 2;
|
||||
buffer.roffset === 3;
|
||||
buffer.noAssert === true;
|
||||
buffer.buffer.writeUInt8(0, 0);
|
||||
|
||||
namespace readBitSet {
|
||||
const a: boolean[] = buffer.readBitSet();
|
||||
const b: boolean[] = buffer.readBitSet(10);
|
||||
}
|
||||
|
||||
namespace read {
|
||||
const a: adone.collection.ByteArray = buffer.read(1);
|
||||
const b: adone.collection.ByteArray = buffer.read(1, 10);
|
||||
}
|
||||
|
||||
namespace readInt8 {
|
||||
const a: number = buffer.readInt8();
|
||||
const b: number = buffer.readInt8(10);
|
||||
}
|
||||
|
||||
namespace readUInt8 {
|
||||
const a: number = buffer.readUInt8();
|
||||
const b: number = buffer.readUInt8(10);
|
||||
}
|
||||
|
||||
namespace readInt16LE {
|
||||
const a: number = buffer.readInt16LE();
|
||||
const b: number = buffer.readInt16LE(10);
|
||||
}
|
||||
|
||||
namespace readUInt16LE {
|
||||
const a: number = buffer.readUInt16LE();
|
||||
const b: number = buffer.readUInt16LE(10);
|
||||
}
|
||||
|
||||
namespace readInt16BE {
|
||||
const a: number = buffer.readInt16BE();
|
||||
const b: number = buffer.readInt16BE(10);
|
||||
}
|
||||
|
||||
namespace readUInt16BE {
|
||||
const a: number = buffer.readUInt16BE();
|
||||
const b: number = buffer.readUInt16BE(10);
|
||||
}
|
||||
|
||||
namespace readInt32LE {
|
||||
const a: number = buffer.readInt32LE();
|
||||
const b: number = buffer.readInt32LE(10);
|
||||
}
|
||||
|
||||
namespace readUInt32LE {
|
||||
const a: number = buffer.readUInt32LE();
|
||||
const b: number = buffer.readUInt32LE(10);
|
||||
}
|
||||
|
||||
namespace readInt32BE {
|
||||
const a: number = buffer.readInt32BE();
|
||||
const b: number = buffer.readInt32BE(10);
|
||||
}
|
||||
|
||||
namespace readUInt32BE {
|
||||
const a: number = buffer.readUInt32BE();
|
||||
const b: number = buffer.readUInt32BE(10);
|
||||
}
|
||||
|
||||
namespace readInt64LE {
|
||||
const a: adone.math.Long = buffer.readInt64LE();
|
||||
const b: adone.math.Long = buffer.readInt64LE(10);
|
||||
}
|
||||
|
||||
namespace readUInt64LE {
|
||||
const a: adone.math.Long = buffer.readUInt64LE();
|
||||
const b: adone.math.Long = buffer.readUInt64LE(10);
|
||||
}
|
||||
|
||||
namespace readInt64BE {
|
||||
const a: adone.math.Long = buffer.readInt64BE();
|
||||
const b: adone.math.Long = buffer.readInt64BE(10);
|
||||
}
|
||||
|
||||
namespace readUInt64BE {
|
||||
const a: adone.math.Long = buffer.readUInt64BE();
|
||||
const b: adone.math.Long = buffer.readUInt64BE(10);
|
||||
}
|
||||
|
||||
namespace readFloatLE {
|
||||
const a: number = buffer.readFloatLE();
|
||||
const b: number = buffer.readFloatLE(10);
|
||||
}
|
||||
|
||||
namespace readFloatBE {
|
||||
const a: number = buffer.readFloatBE();
|
||||
const b: number = buffer.readFloatBE(10);
|
||||
}
|
||||
|
||||
namespace readDoubleLE {
|
||||
const a: number = buffer.readDoubleLE();
|
||||
const b: number = buffer.readDoubleLE(10);
|
||||
}
|
||||
|
||||
namespace readDoubleBE {
|
||||
const a: number = buffer.readDoubleBE();
|
||||
const b: number = buffer.readDoubleBE(10);
|
||||
}
|
||||
|
||||
namespace write {
|
||||
const a: adone.collection.ByteArray = buffer.write("1");
|
||||
const b: adone.collection.ByteArray = buffer.write(new ByteArray());
|
||||
const c: adone.collection.ByteArray = buffer.write(Buffer.alloc(10));
|
||||
const d: adone.collection.ByteArray = buffer.write(new Uint8Array([1, 2, 3]));
|
||||
const e: adone.collection.ByteArray = buffer.write(new ArrayBuffer(10));
|
||||
const f: adone.collection.ByteArray = buffer.write("1", 10);
|
||||
const g: adone.collection.ByteArray = buffer.write("1", 10, 10);
|
||||
const h: adone.collection.ByteArray = buffer.write("1", 10, 10, "utf8");
|
||||
}
|
||||
|
||||
namespace writeBitSet {
|
||||
const a: adone.collection.ByteArray = buffer.writeBitSet([1, 2, 3]);
|
||||
const b: number = buffer.writeBitSet([1, 2, 3], 10);
|
||||
}
|
||||
|
||||
namespace writeInt8 {
|
||||
const a: adone.collection.ByteArray = buffer.writeInt8(10);
|
||||
const b: adone.collection.ByteArray = buffer.writeInt8(10, 10);
|
||||
}
|
||||
|
||||
namespace writeUInt8 {
|
||||
const a: adone.collection.ByteArray = buffer.writeUInt8(10);
|
||||
const b: adone.collection.ByteArray = buffer.writeUInt8(10, 10);
|
||||
}
|
||||
|
||||
namespace writeInt16LE {
|
||||
const a: adone.collection.ByteArray = buffer.writeInt16LE(10);
|
||||
const b: adone.collection.ByteArray = buffer.writeInt16LE(10, 10);
|
||||
}
|
||||
|
||||
namespace writeInt16BE {
|
||||
const a: adone.collection.ByteArray = buffer.writeInt16BE(10);
|
||||
const b: adone.collection.ByteArray = buffer.writeInt16BE(10, 10);
|
||||
}
|
||||
|
||||
namespace writeUInt16LE {
|
||||
const a: adone.collection.ByteArray = buffer.writeUInt16LE(10);
|
||||
const b: adone.collection.ByteArray = buffer.writeUInt16LE(10, 10);
|
||||
}
|
||||
|
||||
namespace writeUInt16BE {
|
||||
const a: adone.collection.ByteArray = buffer.writeUInt16BE(10);
|
||||
const b: adone.collection.ByteArray = buffer.writeUInt16BE(10, 10);
|
||||
}
|
||||
|
||||
namespace writeInt32LE {
|
||||
const a: adone.collection.ByteArray = buffer.writeInt32LE(10);
|
||||
const b: adone.collection.ByteArray = buffer.writeInt32LE(10, 10);
|
||||
}
|
||||
|
||||
namespace writeInt32BE {
|
||||
const a: adone.collection.ByteArray = buffer.writeInt32BE(10);
|
||||
const b: adone.collection.ByteArray = buffer.writeInt32BE(10, 10);
|
||||
}
|
||||
|
||||
namespace writeUInt32LE {
|
||||
const a: adone.collection.ByteArray = buffer.writeUInt32LE(10);
|
||||
const b: adone.collection.ByteArray = buffer.writeUInt32LE(10, 10);
|
||||
}
|
||||
|
||||
namespace writeUInt32BE {
|
||||
const a: adone.collection.ByteArray = buffer.writeUInt32BE(10);
|
||||
const b: adone.collection.ByteArray = buffer.writeUInt32BE(10, 10);
|
||||
}
|
||||
|
||||
namespace writeInt64LE {
|
||||
const a: adone.collection.ByteArray = buffer.writeInt64LE(10);
|
||||
const b: adone.collection.ByteArray = buffer.writeInt64LE(10, 10);
|
||||
}
|
||||
|
||||
namespace writeInt64BE {
|
||||
const a: adone.collection.ByteArray = buffer.writeInt64BE(10);
|
||||
const b: adone.collection.ByteArray = buffer.writeInt64BE(10, 10);
|
||||
}
|
||||
|
||||
namespace writeUInt64LE {
|
||||
const a: adone.collection.ByteArray = buffer.writeUInt64LE(10);
|
||||
const b: adone.collection.ByteArray = buffer.writeUInt64LE(10, 10);
|
||||
}
|
||||
|
||||
namespace writeUInt64BE {
|
||||
const a: adone.collection.ByteArray = buffer.writeUInt64BE(10);
|
||||
const b: adone.collection.ByteArray = buffer.writeUInt64BE(10, 10);
|
||||
}
|
||||
|
||||
namespace writeFloatLE {
|
||||
const a: adone.collection.ByteArray = buffer.writeFloatLE(10);
|
||||
const b: adone.collection.ByteArray = buffer.writeFloatLE(10, 10);
|
||||
}
|
||||
|
||||
namespace writeFloatBE {
|
||||
const a: adone.collection.ByteArray = buffer.writeFloatBE(10);
|
||||
const b: adone.collection.ByteArray = buffer.writeFloatBE(10, 10);
|
||||
}
|
||||
|
||||
namespace writeDoubleLE {
|
||||
const a: adone.collection.ByteArray = buffer.writeDoubleLE(10);
|
||||
const b: adone.collection.ByteArray = buffer.writeDoubleLE(10, 10);
|
||||
}
|
||||
|
||||
namespace writeDoubleBE {
|
||||
const a: adone.collection.ByteArray = buffer.writeDoubleBE(10);
|
||||
const b: adone.collection.ByteArray = buffer.writeDoubleBE(10, 10);
|
||||
}
|
||||
|
||||
namespace writeVarInt32 {
|
||||
const a: adone.collection.ByteArray = buffer.writeVarint32(10);
|
||||
const b: number = buffer.writeVarint32(10, 10);
|
||||
}
|
||||
|
||||
namespace writeVarInt32ZigZag {
|
||||
const a: adone.collection.ByteArray = buffer.writeVarint32ZigZag(10);
|
||||
const b: number = buffer.writeVarint32ZigZag(10, 10);
|
||||
}
|
||||
|
||||
namespace readVarint32 {
|
||||
const a: number = buffer.readVarint32();
|
||||
const b: { value: number, length: number } = buffer.readVarint32(10);
|
||||
}
|
||||
|
||||
namespace readVarint32ZigZag {
|
||||
const a: number = buffer.readVarint32ZigZag();
|
||||
const b: { value: number, length: number } = buffer.readVarint32ZigZag(10);
|
||||
}
|
||||
|
||||
namespace writeVarint64 {
|
||||
const a: adone.collection.ByteArray = buffer.writeVarint64(10);
|
||||
const b: number = buffer.writeVarint64(10, 10);
|
||||
}
|
||||
|
||||
namespace writeVarint64ZigZag {
|
||||
const a: adone.collection.ByteArray = buffer.writeVarint64ZigZag(10);
|
||||
const b: number = buffer.writeVarint64ZigZag(10, 10);
|
||||
}
|
||||
|
||||
namespace readVarint64 {
|
||||
const a: adone.math.Long = buffer.readVarint64();
|
||||
const b: { value: adone.math.Long, length: number } = buffer.readVarint64(10);
|
||||
}
|
||||
|
||||
namespace readVarint64ZigZag {
|
||||
const a: adone.math.Long = buffer.readVarint64ZigZag();
|
||||
const b: { value: adone.math.Long, length: number } = buffer.readVarint64ZigZag(10);
|
||||
}
|
||||
|
||||
namespace writeCString {
|
||||
const a: adone.collection.ByteArray = buffer.writeCString("asd");
|
||||
const b: number = buffer.writeCString("123", 10);
|
||||
}
|
||||
|
||||
namespace readCString {
|
||||
const a: string = buffer.readCString();
|
||||
const b: { string: string, length: number } = buffer.readCString(10);
|
||||
}
|
||||
|
||||
namespace writeString {
|
||||
const a: adone.collection.ByteArray = buffer.writeString("abc");
|
||||
const b: number = buffer.writeString("abc", 10);
|
||||
}
|
||||
|
||||
namespace readString {
|
||||
const a: string = buffer.readString(10);
|
||||
const b: string = buffer.readString(10, "b");
|
||||
const c: string = buffer.readString(10, "c");
|
||||
const d: { string: string, length: number } = buffer.readString(10, "c", 10);
|
||||
}
|
||||
|
||||
namespace writeVString {
|
||||
const a: adone.collection.ByteArray = buffer.writeVString("abc");
|
||||
const b: number = buffer.writeVString("abc", 10);
|
||||
}
|
||||
|
||||
namespace readVString {
|
||||
const a: string = buffer.readVString();
|
||||
const b: { string: string, length: number } = buffer.readVString(10);
|
||||
}
|
||||
|
||||
namespace appendTo {
|
||||
const a: adone.collection.ByteArray = buffer.appendTo(new ByteArray());
|
||||
const b: adone.collection.ByteArray = buffer.appendTo(new ByteArray(), 10);
|
||||
}
|
||||
|
||||
namespace assert {
|
||||
const a: adone.collection.ByteArray = buffer.assert();
|
||||
const b: adone.collection.ByteArray = buffer.assert(true);
|
||||
}
|
||||
|
||||
namespace capacity {
|
||||
const a: number = buffer.capacity();
|
||||
}
|
||||
|
||||
namespace clear {
|
||||
const a: adone.collection.ByteArray = buffer.clear();
|
||||
}
|
||||
|
||||
namespace copy {
|
||||
const a: adone.collection.ByteArray = buffer.clone();
|
||||
const c: adone.collection.ByteArray = buffer.clone(true);
|
||||
}
|
||||
|
||||
namespace compact {
|
||||
const a: adone.collection.ByteArray = buffer.compact();
|
||||
const b: adone.collection.ByteArray = buffer.compact(1);
|
||||
const c: adone.collection.ByteArray = buffer.compact(1, 10);
|
||||
}
|
||||
|
||||
namespace copyTo {
|
||||
const a: adone.collection.ByteArray = buffer.copyTo(new ByteArray());
|
||||
const b: adone.collection.ByteArray = buffer.copyTo(new ByteArray(), 0);
|
||||
const c: adone.collection.ByteArray = buffer.copyTo(new ByteArray(), 0, 0);
|
||||
const d: adone.collection.ByteArray = buffer.copyTo(new ByteArray(), 0, 0, 10);
|
||||
}
|
||||
|
||||
namespace ensureCapacity {
|
||||
const a: adone.collection.ByteArray = buffer.ensureCapacity(10);
|
||||
}
|
||||
|
||||
namespace fill {
|
||||
const a: adone.collection.ByteArray = buffer.fill("0");
|
||||
const b: adone.collection.ByteArray = buffer.fill(0);
|
||||
const c: adone.collection.ByteArray = buffer.fill(0, 0);
|
||||
const d: adone.collection.ByteArray = buffer.fill(0, 0, 10);
|
||||
}
|
||||
|
||||
namespace flip {
|
||||
const a: adone.collection.ByteArray = buffer.flip();
|
||||
}
|
||||
|
||||
namespace mark {
|
||||
const a: adone.collection.ByteArray = buffer.mark();
|
||||
const b: adone.collection.ByteArray = buffer.mark(10);
|
||||
}
|
||||
|
||||
namespace prepend {
|
||||
const a: adone.collection.ByteArray = buffer.prepend("");
|
||||
const b: adone.collection.ByteArray = buffer.prepend(new ByteArray());
|
||||
const c: adone.collection.ByteArray = buffer.prepend(Buffer.alloc(10));
|
||||
const d: adone.collection.ByteArray = buffer.prepend(new Uint8Array([1, 2, 3]));
|
||||
const e: adone.collection.ByteArray = buffer.prepend(new ArrayBuffer(10));
|
||||
const f: adone.collection.ByteArray = buffer.prepend("", "utf8");
|
||||
const g: adone.collection.ByteArray = buffer.prepend("", "utf8", 10);
|
||||
const h: adone.collection.ByteArray = buffer.prepend("", 10);
|
||||
}
|
||||
|
||||
namespace prependTo {
|
||||
const a: adone.collection.ByteArray = buffer.prependTo(new ByteArray());
|
||||
const b: adone.collection.ByteArray = buffer.prependTo(new ByteArray(), 10);
|
||||
}
|
||||
|
||||
namespace remaining {
|
||||
const a: number = buffer.remaining();
|
||||
}
|
||||
|
||||
namespace reset {
|
||||
const a: adone.collection.ByteArray = buffer.reset();
|
||||
}
|
||||
|
||||
namespace resize {
|
||||
const a: adone.collection.ByteArray = buffer.resize(10);
|
||||
}
|
||||
|
||||
namespace reverse {
|
||||
const a: adone.collection.ByteArray = buffer.reverse();
|
||||
const b: adone.collection.ByteArray = buffer.reverse(1);
|
||||
const c: adone.collection.ByteArray = buffer.reverse(1, 10);
|
||||
}
|
||||
|
||||
namespace skip {
|
||||
const a: adone.collection.ByteArray = buffer.skip(10);
|
||||
}
|
||||
|
||||
namespace slice {
|
||||
const a: adone.collection.ByteArray = buffer.slice();
|
||||
const b: adone.collection.ByteArray = buffer.slice(1);
|
||||
const c: adone.collection.ByteArray = buffer.slice(1, 10);
|
||||
}
|
||||
|
||||
namespace toBuffer {
|
||||
const a: Buffer = buffer.toBuffer();
|
||||
const b: Buffer = buffer.toBuffer(true);
|
||||
const c: Buffer = buffer.toBuffer(true, 0);
|
||||
const d: Buffer = buffer.toBuffer(true, 0, 10);
|
||||
}
|
||||
|
||||
namespace toArrayBuffer {
|
||||
const a: ArrayBuffer = buffer.toArrayBuffer();
|
||||
}
|
||||
|
||||
namespace toString {
|
||||
const a: string = buffer.toString();
|
||||
const b: string = buffer.toString("utf8");
|
||||
const c: string = buffer.toString("utf8", 0);
|
||||
const d: string = buffer.toString("utf8", 0, 10);
|
||||
}
|
||||
|
||||
namespace toBase64 {
|
||||
const a: string = buffer.toBase64();
|
||||
const b: string = buffer.toBase64(0);
|
||||
const c: string = buffer.toBase64(0, 10);
|
||||
}
|
||||
|
||||
namespace toBinary {
|
||||
const a: string = buffer.toBinary();
|
||||
const b: string = buffer.toBinary(0);
|
||||
const c: string = buffer.toBinary(0, 10);
|
||||
}
|
||||
|
||||
namespace toDebug {
|
||||
const a: string = buffer.toDebug();
|
||||
const b: string = buffer.toDebug(true);
|
||||
}
|
||||
|
||||
namespace toUTF8 {
|
||||
const a: string = buffer.toUTF8();
|
||||
const b: string = buffer.toUTF8(0);
|
||||
const c: string = buffer.toUTF8(0, 10);
|
||||
}
|
||||
|
||||
namespace static {
|
||||
namespace accessor {
|
||||
const a: typeof Buffer = ByteArray.accessor();
|
||||
}
|
||||
|
||||
namespace allocate {
|
||||
const a: adone.collection.ByteArray = ByteArray.allocate();
|
||||
const b: adone.collection.ByteArray = ByteArray.allocate(10);
|
||||
const c: adone.collection.ByteArray = ByteArray.allocate(10, true);
|
||||
}
|
||||
|
||||
namespace concat {
|
||||
const a: adone.collection.ByteArray = ByteArray.concat([
|
||||
new ByteArray(),
|
||||
Buffer.alloc(10),
|
||||
new Uint8Array([1, 2, 3]),
|
||||
new ArrayBuffer(10)
|
||||
]);
|
||||
const b: adone.collection.ByteArray = ByteArray.concat([
|
||||
new ByteArray(),
|
||||
Buffer.alloc(10),
|
||||
new Uint8Array([1, 2, 3]),
|
||||
new ArrayBuffer(10)
|
||||
], "utf8");
|
||||
const c: adone.collection.ByteArray = ByteArray.concat([
|
||||
new ByteArray(),
|
||||
Buffer.alloc(10),
|
||||
new Uint8Array([1, 2, 3]),
|
||||
new ArrayBuffer(10)
|
||||
], "utf8", true);
|
||||
}
|
||||
|
||||
namespace type {
|
||||
const a: typeof Buffer = ByteArray.type();
|
||||
}
|
||||
|
||||
namespace wrap {
|
||||
const a: adone.collection.ByteArray = ByteArray.wrap("");
|
||||
const b: adone.collection.ByteArray = ByteArray.wrap(new ByteArray());
|
||||
const c: adone.collection.ByteArray = ByteArray.wrap(Buffer.alloc(10));
|
||||
const d: adone.collection.ByteArray = ByteArray.wrap(new Uint8Array([1, 2, 3]));
|
||||
const e: adone.collection.ByteArray = ByteArray.wrap(new ArrayBuffer(10));
|
||||
const f: adone.collection.ByteArray = ByteArray.wrap("", "utf8");
|
||||
const g: adone.collection.ByteArray = ByteArray.wrap("", "utf8", true);
|
||||
}
|
||||
|
||||
namespace calculateVarint32 {
|
||||
const a: number = ByteArray.calculateVarint32(10);
|
||||
}
|
||||
|
||||
namespace zigZagEncode32 {
|
||||
const a: number = ByteArray.zigZagEncode32(10);
|
||||
}
|
||||
|
||||
namespace zigZagDecode32 {
|
||||
const a: number = ByteArray.zigZagDecode32(10);
|
||||
}
|
||||
|
||||
namespace calculateVarint64 {
|
||||
const a: number = ByteArray.calculateVarint64(10);
|
||||
const b: number = ByteArray.calculateVarint64("10");
|
||||
}
|
||||
|
||||
namespace zigZagEncode64 {
|
||||
const a: adone.math.Long = ByteArray.zigZagEncode64(10);
|
||||
const b: adone.math.Long = ByteArray.zigZagEncode64("10");
|
||||
const c: adone.math.Long = ByteArray.zigZagEncode64(adone.math.Long.fromValue(10));
|
||||
}
|
||||
|
||||
namespace zigZagDecode64 {
|
||||
const a: adone.math.Long = ByteArray.zigZagDecode64(10);
|
||||
const b: adone.math.Long = ByteArray.zigZagDecode64("10");
|
||||
const c: adone.math.Long = ByteArray.zigZagDecode64(adone.math.Long.fromValue(10));
|
||||
}
|
||||
|
||||
namespace calculateUTF8Chars {
|
||||
const a: number = ByteArray.calculateUTF8Chars("123");
|
||||
}
|
||||
|
||||
namespace calculateString {
|
||||
const a: number = ByteArray.calculateString("123");
|
||||
}
|
||||
|
||||
namespace fromBase64 {
|
||||
const a: adone.collection.ByteArray = ByteArray.fromBase64("123");
|
||||
}
|
||||
|
||||
namespace btoa {
|
||||
const a: string = ByteArray.btoa("123");
|
||||
}
|
||||
|
||||
namespace atob {
|
||||
const a: string = ByteArray.atob("123");
|
||||
}
|
||||
|
||||
namespace fromBinary {
|
||||
const a: adone.collection.ByteArray = ByteArray.fromBinary("123");
|
||||
}
|
||||
|
||||
namespace fromDebug {
|
||||
const a: adone.collection.ByteArray = ByteArray.fromDebug("12");
|
||||
const b: adone.collection.ByteArray = ByteArray.fromDebug("12", true);
|
||||
}
|
||||
|
||||
namespace fromHex {
|
||||
const a: adone.collection.ByteArray = ByteArray.fromHex("192");
|
||||
const b: adone.collection.ByteArray = ByteArray.fromHex("192", true);
|
||||
}
|
||||
|
||||
namespace fromUTF8 {
|
||||
const a: adone.collection.ByteArray = ByteArray.fromUTF8("123");
|
||||
const b: adone.collection.ByteArray = ByteArray.fromUTF8("123", true);
|
||||
}
|
||||
|
||||
namespace constants {
|
||||
const a: number = ByteArray.DEFAULT_CAPACITY;
|
||||
const b: boolean = ByteArray.DEFAULT_NOASSERT;
|
||||
const c: number = ByteArray.MAX_VARINT32_BYTES;
|
||||
const d: number = ByteArray.MAX_VARINT64_BYTES;
|
||||
const e: string = ByteArray.METRICS_CHARS;
|
||||
const f: string = ByteArray.METRICS_BYTES;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
namespace adoneTests.collection.DefaultMap {
|
||||
const {
|
||||
collection: {
|
||||
DefaultMap
|
||||
}
|
||||
} = adone;
|
||||
|
||||
type DefaultMap<K = any, V = any> = adone.collection.DefaultMap<K, V>;
|
||||
|
||||
new DefaultMap();
|
||||
{ const a: DefaultMap<string, number> = new DefaultMap(undefined, [["1", 2]]); }
|
||||
{ const a: DefaultMap<string, number> = new DefaultMap((key: string) => 123); }
|
||||
{ const a: DefaultMap<string, number> = new DefaultMap({ a: 123 }); }
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
namespace adoneTests.collection.FastLRU {
|
||||
const {
|
||||
collection: {
|
||||
FastLRU
|
||||
}
|
||||
} = adone;
|
||||
|
||||
new FastLRU();
|
||||
new FastLRU(100);
|
||||
new FastLRU<string, number>(100, { dispose: (key: string, value: number) => null });
|
||||
{ const a: number = new FastLRU().size; }
|
||||
{ const a: number | undefined = new FastLRU<string, number>().get("key"); }
|
||||
new FastLRU<string, number>().set("key", 123);
|
||||
{ const a: boolean = new FastLRU<string, number>().delete("key"); }
|
||||
{ const a: boolean = new FastLRU<string, number>().has("key"); }
|
||||
{ const a: string[] = [...new FastLRU<string, number>().keys()]; }
|
||||
{ const a: number[] = [...new FastLRU<string, number>().values()]; }
|
||||
{ const a: number[] = [...new FastLRU<string, number>().values()]; }
|
||||
{ const a: Array<[string, number]> = [...new FastLRU<string, number>().entries()]; }
|
||||
new FastLRU<string, number>().clear();
|
||||
}
|
||||
@@ -0,0 +1,123 @@
|
||||
namespace adoneTests.collection.LinkedList {
|
||||
const {
|
||||
collection: {
|
||||
LinkedList
|
||||
}
|
||||
} = adone;
|
||||
|
||||
namespace creation {
|
||||
new LinkedList();
|
||||
new LinkedList(10);
|
||||
}
|
||||
|
||||
namespace properties {
|
||||
{ const a: boolean = new LinkedList().full; }
|
||||
{ const a: boolean = new LinkedList().empty; }
|
||||
{ const a: number = new LinkedList().maxLength; }
|
||||
{ const a: number = new LinkedList().length; }
|
||||
{ const a: boolean = new LinkedList().autoresize; }
|
||||
}
|
||||
|
||||
namespace resize {
|
||||
{ const a: boolean = new LinkedList().resize(100).full; }
|
||||
}
|
||||
|
||||
namespace push {
|
||||
const a = new LinkedList<number>().push(10);
|
||||
a.next;
|
||||
a.prev;
|
||||
const b: number = a.value;
|
||||
}
|
||||
|
||||
namespace pop {
|
||||
const a: number | undefined = new LinkedList<number>().pop();
|
||||
}
|
||||
|
||||
namespace shift {
|
||||
const a: number | undefined = new LinkedList<number>().shift();
|
||||
}
|
||||
|
||||
namespace unshift {
|
||||
const a = new LinkedList<string>().unshift("hello");
|
||||
a.next;
|
||||
a.prev;
|
||||
const b: string = a.value;
|
||||
}
|
||||
|
||||
namespace pushNode {
|
||||
const a = new LinkedList<string>();
|
||||
const node = a.push("1230");
|
||||
a.pushNode(node);
|
||||
}
|
||||
|
||||
namespace unshiftNode {
|
||||
const a = new LinkedList();
|
||||
const node = a.push(10);
|
||||
a.unshiftNode(node);
|
||||
}
|
||||
|
||||
namespace removeNode {
|
||||
const a = new LinkedList<string>();
|
||||
const node = a.unshift("10");
|
||||
a.removeNode(node);
|
||||
}
|
||||
|
||||
namespace clear {
|
||||
new LinkedList().clear();
|
||||
new LinkedList().clear(true);
|
||||
}
|
||||
|
||||
namespace toArray {
|
||||
const a = new LinkedList<number>();
|
||||
const b: number[] = a.toArray();
|
||||
}
|
||||
|
||||
namespace front {
|
||||
const a = new LinkedList<number>();
|
||||
const b: number = a.front;
|
||||
}
|
||||
|
||||
namespace back {
|
||||
const a = new LinkedList<number>();
|
||||
const b: number = a.back;
|
||||
}
|
||||
|
||||
namespace iterating {
|
||||
const a = new LinkedList<string>();
|
||||
for (const b of a) {
|
||||
const i: string = b;
|
||||
}
|
||||
const c = new LinkedList<number>();
|
||||
for (const b of c) {
|
||||
const i: number = b;
|
||||
}
|
||||
}
|
||||
|
||||
namespace nextNode {
|
||||
const a = new LinkedList<string>();
|
||||
const n1 = a.push("h");
|
||||
const n2 = a.nextNode(n1);
|
||||
n1.next;
|
||||
n1.prev;
|
||||
const t: string = n1.value;
|
||||
}
|
||||
|
||||
namespace map {
|
||||
const a = new LinkedList<number>();
|
||||
const f = (a: number, idx: number) => `${a}${idx}`;
|
||||
const b = a.map(f);
|
||||
const c: string = b.front;
|
||||
}
|
||||
|
||||
namespace forEach {
|
||||
const a = new LinkedList<number>();
|
||||
|
||||
a.forEach((a: number, b: number) => {
|
||||
const c = a + b;
|
||||
});
|
||||
}
|
||||
|
||||
namespace static {
|
||||
const a: number = LinkedList.DEFAULT_LENGTH;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
namespace adoneTests.collection.LRU {
|
||||
const {
|
||||
collection: {
|
||||
LRU
|
||||
}
|
||||
} = adone;
|
||||
|
||||
type LRU = adone.collection.LRU;
|
||||
|
||||
new LRU();
|
||||
new LRU(100);
|
||||
new LRU({});
|
||||
new LRU({ max: 100 });
|
||||
new LRU<string, number>({ dispose: (key: string, value: number) => null });
|
||||
new LRU<string, number>({ maxAge: 100 });
|
||||
new LRU<string, number>({ noDisposeOnSet: false });
|
||||
new LRU<string, number>({ stale: true });
|
||||
{ const a: number = new LRU<string, number>().max; }
|
||||
{ new LRU<string, number>().max = 100; }
|
||||
{ const a: boolean = new LRU<string, number>().allowStale; }
|
||||
{ new LRU<string, number>().allowStale = false; }
|
||||
{ const a: number = new LRU<string, number>().maxAge; }
|
||||
{ new LRU<string, number>().maxAge = 100; }
|
||||
{ const a: (v: number, k: string) => number = new LRU<string, number>().lengthCalculator; }
|
||||
{ new LRU<string, number>().lengthCalculator = () => 123; }
|
||||
{ const a: number = new LRU<string, number>().length; }
|
||||
{ const a: number = new LRU<string, number>().itemCount; }
|
||||
new LRU<string, number>().rforEach((value: number, key: string) => null);
|
||||
new LRU<string, number>().rforEach(function (value: number, key: string) {
|
||||
const b: number = this.a;
|
||||
}, { a: 1 });
|
||||
new LRU<string, number>().forEach((value: number, key: string) => null);
|
||||
new LRU<string, number>().forEach(function (value: number, key: string) {
|
||||
const b: number = this.a;
|
||||
}, { a: 1 });
|
||||
{ const a: string[] = new LRU<string, number>().keys(); }
|
||||
{ const a: number[] = new LRU<string, number>().values(); }
|
||||
new LRU<string, number>().reset();
|
||||
{
|
||||
const a: Array<adone.collection.I.LRU.SerializedEntry<string, number>> = new LRU<string, number>().dump();
|
||||
const [b] = a;
|
||||
{ const c: number = b.e; }
|
||||
{ const c: string = b.key; }
|
||||
{ const c: number = b.value; }
|
||||
}
|
||||
{
|
||||
const a: adone.collection.LinkedList<adone.collection.I.LRU.Entry<string, number>> = new LRU<string, number>().dumpLru();
|
||||
const b = a.shift();
|
||||
if (b !== undefined) {
|
||||
{ const a: string = b.key; }
|
||||
{ const a: number = b.value; }
|
||||
{ const a: number = b.now; }
|
||||
{ const a: number = b.maxAge; }
|
||||
}
|
||||
}
|
||||
{ const a: string = new LRU<string, number>().inspect(); }
|
||||
{ const a: string = new LRU<string, number>().inspect({}); }
|
||||
{ const a: boolean = new LRU<string, number>().set("asd", 13); }
|
||||
{ const a: boolean = new LRU<string, number>().set("asd", 13, 100500); }
|
||||
{ const a: boolean = new LRU<string, number>().has("asd"); }
|
||||
{ const a: number | undefined = new LRU<string, number>().get("asd"); }
|
||||
{ const a: number | undefined = new LRU<string, number>().peek("asd"); }
|
||||
{ const a: adone.collection.I.LRU.Entry<string, number> = new LRU<string, number>().pop(); }
|
||||
new LRU<string, number>().del("asd");
|
||||
new LRU<string, number>().load(new LRU<string, number>().dump());
|
||||
new LRU<string, number>().prune();
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
namespace adoneTests.collection.MapCache {
|
||||
const {
|
||||
collection: {
|
||||
MapCache
|
||||
}
|
||||
} = adone;
|
||||
|
||||
new MapCache();
|
||||
|
||||
new MapCache().has("hello");
|
||||
new MapCache().get("hello");
|
||||
new MapCache().set("hello", "world");
|
||||
new MapCache().delete("hello");
|
||||
new MapCache().clear();
|
||||
|
||||
{
|
||||
const a = new MapCache<string>();
|
||||
a.set("a", "b");
|
||||
a.get("a").charCodeAt(20);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
namespace adoneTests.collection.NSCache {
|
||||
const {
|
||||
collection: {
|
||||
NSCache
|
||||
}
|
||||
} = adone;
|
||||
|
||||
new NSCache(10, ["a", "b", "c"]);
|
||||
new NSCache(10, ["a", "b", "c"]).resize(100);
|
||||
new NSCache(10, ["a", "b", "c"]).set("a", "b", "c");
|
||||
new NSCache(10, ["a", "b", "c"]).get("a", "b");
|
||||
new NSCache(10, ["a", "b", "c"]).has("a", "b");
|
||||
new NSCache(10, ["a", "b", "c"]).delete("a", "b");
|
||||
new NSCache(10, ["a", "b", "c"]).clear();
|
||||
|
||||
{
|
||||
const a = new NSCache<string>(10, ["a", "b", "c"]);
|
||||
a.set("a", "b", "c");
|
||||
a.get("a", "b").charCodeAt(100);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
namespace adoneTests.collection.PriorityQueue {
|
||||
const {
|
||||
collection: {
|
||||
PriorityQueue
|
||||
}
|
||||
} = adone;
|
||||
|
||||
type PriorityQueue<T = any> = adone.collection.PriorityQueue<T>;
|
||||
|
||||
{ const a: boolean = new PriorityQueue().empty; }
|
||||
{ const a: number = new PriorityQueue().length; }
|
||||
new PriorityQueue();
|
||||
new PriorityQueue({});
|
||||
new PriorityQueue<number>({
|
||||
compare(a: number, b: number) {
|
||||
return a - b;
|
||||
}
|
||||
});
|
||||
new PriorityQueue<string>({
|
||||
priority(a: string, b: string) {
|
||||
return a.length - b.length;
|
||||
}
|
||||
});
|
||||
{ const a: PriorityQueue<string> = new PriorityQueue<string>().clone(); }
|
||||
{ const a: PriorityQueue<string> = new PriorityQueue<string>().push("123"); }
|
||||
{ const a: string | undefined = new PriorityQueue<string>().pop(); }
|
||||
{ const a: PriorityQueue<string> = new PriorityQueue<string>().delete("123"); }
|
||||
{ const a: PriorityQueue<string> = new PriorityQueue<string>().delete("123"); }
|
||||
{ const a: string = new PriorityQueue<string>().replace("123"); }
|
||||
{ const a: string = new PriorityQueue<string>().pushpop("123"); }
|
||||
{ const a: string[] = new PriorityQueue<string>().toArray(); }
|
||||
{ const a: PriorityQueue<string> = PriorityQueue.from(["1"]); }
|
||||
{ const a: PriorityQueue<string> = PriorityQueue.from(["1"], {}); }
|
||||
{ const a: PriorityQueue<string> = PriorityQueue.from(["1"], { compare: (a: string, b: string) => a.length - b.length }); }
|
||||
{ const a: PriorityQueue<string> = PriorityQueue.from(["1"], { priority: (a: string, b: string) => a.length - b.length }); }
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
namespace adoneTests.collection.Queue {
|
||||
const {
|
||||
collection: {
|
||||
Queue
|
||||
}
|
||||
} = adone;
|
||||
|
||||
type Queue = adone.collection.Queue;
|
||||
|
||||
new Queue();
|
||||
{ const a: Queue = new Queue().push(123).push(123); }
|
||||
{ const a: number | undefined = new Queue<number>().push(123).pop(); }
|
||||
{ const a: string | undefined = new Queue<number, string>().push(123).pop(); }
|
||||
{ const a: boolean = new Queue().full; }
|
||||
{ const a: number = new Queue().length; }
|
||||
{ const a: boolean = new Queue().empty; }
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
namespace adoneTests.collection.RedBlackTree {
|
||||
const {
|
||||
collection: {
|
||||
RedBlackTree
|
||||
}
|
||||
} = adone;
|
||||
|
||||
type RedBlackTree<K = any, V = any> = adone.collection.RedBlackTree<K, V>;
|
||||
type RedBlackTreeIterator<K = any, V = any> = adone.collection.I.RedBlackTree.Iterator<K, V>;
|
||||
type RedBlackTreeNode<K = any, V = any> = adone.collection.I.RedBlackTree.Node<K, V>;
|
||||
|
||||
new RedBlackTree();
|
||||
new RedBlackTree<string, number>((a: string, b: string) => a.length - b.length);
|
||||
new RedBlackTree<string, number>(undefined, new RedBlackTree());
|
||||
{ const a: string[] = new RedBlackTree<string, number>().keys; }
|
||||
{ const a: number[] = new RedBlackTree<string, number>().values; }
|
||||
{ const a: number = new RedBlackTree<string, number>().length; }
|
||||
{
|
||||
const a: RedBlackTreeIterator<string, number> = new RedBlackTree<string, number>().begin;
|
||||
{ const b: boolean = a.valid; }
|
||||
{ const b: RedBlackTreeNode<string, number> | null = a.node; }
|
||||
{ const b: string | undefined = a.key; }
|
||||
{ const b: number | undefined = a.value; }
|
||||
{ const b: number = a.index; }
|
||||
{ const b: boolean = a.hasNext; }
|
||||
{ const b: boolean = a.hasPrev; }
|
||||
{ const b: RedBlackTree<string, number> = a.tree; }
|
||||
{ const b: RedBlackTreeIterator<string, number> = a.clone(); }
|
||||
{ const b: RedBlackTree<string, number> = a.remove(); }
|
||||
a.next();
|
||||
{ const b: RedBlackTree<string, number> = a.update(333); }
|
||||
a.prev();
|
||||
}
|
||||
{ const a: RedBlackTreeIterator<string, number> = new RedBlackTree<string, number>().end; }
|
||||
{ const a: RedBlackTree<string, number> = new RedBlackTree<string, number>().insert("123", 456); }
|
||||
{ const a: number = new RedBlackTree<string, number>().forEach((key: string, value: number) => value); }
|
||||
{ const a: number = new RedBlackTree<string, number>().forEach((key: string, value: number) => value, "1"); }
|
||||
{ const a: number = new RedBlackTree<string, number>().forEach((key: string, value: number) => value, "1", "2"); }
|
||||
{ const a: RedBlackTreeIterator<string, number> = new RedBlackTree<string, number>().at(1); }
|
||||
{ const a: RedBlackTreeIterator<string, number> = new RedBlackTree<string, number>().ge("1"); }
|
||||
{ const a: RedBlackTreeIterator<string, number> = new RedBlackTree<string, number>().gt("1"); }
|
||||
{ const a: RedBlackTreeIterator<string, number> = new RedBlackTree<string, number>().lt("1"); }
|
||||
{ const a: RedBlackTreeIterator<string, number> = new RedBlackTree<string, number>().le("1"); }
|
||||
{ const a: RedBlackTreeIterator<string, number> | null = new RedBlackTree<string, number>().find("1"); }
|
||||
{ const a: RedBlackTree<string, number> = new RedBlackTree<string, number>().remove("1"); }
|
||||
{ const a: RedBlackTree<string, number> = new RedBlackTree<string, number>().remove("1"); }
|
||||
{ const a: number | undefined = new RedBlackTree<string, number>().get("1"); }
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
namespace adoneTests.collection.RefcountedCache {
|
||||
const {
|
||||
collection: {
|
||||
RefcountedCache
|
||||
}
|
||||
} = adone;
|
||||
|
||||
new RefcountedCache();
|
||||
new RefcountedCache().ref("a");
|
||||
new RefcountedCache().unref("a");
|
||||
new RefcountedCache().references("a") === 5;
|
||||
|
||||
{
|
||||
const a = new RefcountedCache<string>();
|
||||
a.get("b").charCodeAt(100);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
namespace adoneTests.collection.Set {
|
||||
const {
|
||||
collection: {
|
||||
Set
|
||||
}
|
||||
} = adone;
|
||||
|
||||
new Set().add("a");
|
||||
new Set().has("a");
|
||||
new Set().delete("a");
|
||||
new Set().get("a");
|
||||
new Set().has("a") === true;
|
||||
new Set().only();
|
||||
new Set().size === 5;
|
||||
|
||||
{
|
||||
const a = new Set<number>();
|
||||
|
||||
a.add(1);
|
||||
a.has(2);
|
||||
a.delete(2);
|
||||
a.get(2); // ???
|
||||
a.only() === 5;
|
||||
a.size === 5;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
namespace adoneTests.collection.Stack {
|
||||
const {
|
||||
collection: {
|
||||
Stack
|
||||
}
|
||||
} = adone;
|
||||
|
||||
type Stack<T = any> = adone.collection.Stack<T>;
|
||||
|
||||
{ const a: boolean = new Stack().empty; }
|
||||
{ const a: number = new Stack<number>().top; }
|
||||
{ const a: Stack<number> = new Stack<number>().push(123); }
|
||||
{ const a: number | undefined = new Stack<number>().pop(); }
|
||||
{ const a: number[] = [...new Stack<number>()]; }
|
||||
{ const a: Stack<number> = Stack.from([1, 2, 3]); }
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
namespace adoneTests.collection.TimedoutMap {
|
||||
const {
|
||||
collection: {
|
||||
TimedoutMap
|
||||
}
|
||||
} = adone;
|
||||
|
||||
type TimedoutMap<K = any, V = any> = adone.collection.TimedoutMap<K, V>;
|
||||
|
||||
new TimedoutMap();
|
||||
new TimedoutMap(1000);
|
||||
new TimedoutMap<string, number>(1000, (key: string) => null);
|
||||
{
|
||||
const a: TimedoutMap<string, number> = new TimedoutMap<string, number>().forEach((value: number, key: string) => null);
|
||||
}
|
||||
{
|
||||
const a: TimedoutMap<string, number> = new TimedoutMap<string, number>().forEach(function (value: number, key: string) {
|
||||
const a: number = this.a;
|
||||
}, { a: 1 });
|
||||
}
|
||||
{ const a: boolean = new TimedoutMap<string, number>().delete("123"); }
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,28 @@
|
||||
namespace adoneTests.crypto.ed25519 {
|
||||
const {
|
||||
crypto: {
|
||||
ed25519
|
||||
}
|
||||
} = adone;
|
||||
|
||||
let buf: Buffer;
|
||||
let num: number;
|
||||
let bool: boolean;
|
||||
|
||||
num = ed25519.privateKeyLength;
|
||||
num = ed25519.publicKeyLength;
|
||||
|
||||
const pair = ed25519.generateKeyPair(Buffer.from("123"));
|
||||
buf = pair.publicKey;
|
||||
buf = pair.privateKey;
|
||||
|
||||
buf = ed25519.sign(Buffer.from("hello"), Buffer.from("seed"));
|
||||
buf = ed25519.sign(Buffer.from("hello"), {
|
||||
publicKey: Buffer.from("hello"),
|
||||
privateKey: Buffer.from("hello")
|
||||
});
|
||||
|
||||
buf = ed25519.sign(Buffer.from("hello"), ed25519.generateKeyPair(Buffer.from("hello")));
|
||||
|
||||
bool = ed25519.verify(Buffer.from("hello"), Buffer.from("world"), Buffer.from("key"));
|
||||
}
|
||||
@@ -0,0 +1,97 @@
|
||||
namespace adoneTests.crypto.secp256k1 {
|
||||
const {
|
||||
crypto: {
|
||||
secp256k1
|
||||
}
|
||||
} = adone;
|
||||
|
||||
let bool: boolean;
|
||||
let buf: Buffer;
|
||||
let num: number;
|
||||
|
||||
const privateKey = Buffer.from("hello");
|
||||
const tweak = Buffer.from("world");
|
||||
const publicKey = Buffer.from("olleh");
|
||||
const signature = Buffer.from("dlrow");
|
||||
|
||||
bool = secp256k1.privateKeyVerify(privateKey);
|
||||
|
||||
buf = secp256k1.privateKeyExport(privateKey);
|
||||
buf = secp256k1.privateKeyExport(privateKey, true);
|
||||
|
||||
buf = secp256k1.privateKeyImport(privateKey);
|
||||
|
||||
buf = secp256k1.privateKeyNegate(privateKey);
|
||||
|
||||
buf = secp256k1.privateKeyTweakAdd(privateKey, tweak);
|
||||
|
||||
buf = secp256k1.privateKeyTweakMul(privateKey, tweak);
|
||||
|
||||
buf = secp256k1.publicKeyConvert(publicKey);
|
||||
buf = secp256k1.publicKeyConvert(publicKey, true);
|
||||
|
||||
bool = secp256k1.publicKeyVerify(publicKey);
|
||||
|
||||
buf = secp256k1.publicKeyTweakAdd(publicKey, tweak);
|
||||
buf = secp256k1.publicKeyTweakAdd(publicKey, tweak, true);
|
||||
|
||||
buf = secp256k1.publicKeyTweakMul(publicKey, tweak);
|
||||
buf = secp256k1.publicKeyTweakMul(publicKey, tweak, true);
|
||||
|
||||
buf = secp256k1.publicKeyCombine([publicKey, publicKey]);
|
||||
buf = secp256k1.publicKeyCombine([publicKey, publicKey], true);
|
||||
|
||||
buf = secp256k1.signatureNormalize(signature);
|
||||
|
||||
buf = secp256k1.signatureExport(signature);
|
||||
|
||||
buf = secp256k1.signatureImport(signature);
|
||||
|
||||
buf = secp256k1.signatureImportLax(signature);
|
||||
|
||||
const message = Buffer.from("msg");
|
||||
|
||||
{
|
||||
const res = secp256k1.sign(message, privateKey);
|
||||
buf = res.signature;
|
||||
num = res.recovery;
|
||||
}
|
||||
{
|
||||
const res = secp256k1.sign(message, privateKey, {});
|
||||
buf = res.signature;
|
||||
num = res.recovery;
|
||||
}
|
||||
{
|
||||
const res = secp256k1.sign(message, privateKey, {
|
||||
data: null
|
||||
});
|
||||
buf = res.signature;
|
||||
num = res.recovery;
|
||||
}
|
||||
{
|
||||
const res = secp256k1.sign(message, privateKey, {
|
||||
data: Buffer.from("123")
|
||||
});
|
||||
buf = res.signature;
|
||||
num = res.recovery;
|
||||
}
|
||||
{
|
||||
const res = secp256k1.sign(message, privateKey, {
|
||||
noncefn(msg: Buffer, privateKey: Buffer, algo: Buffer, data: Buffer, attempt: number) {
|
||||
return Buffer.from("hehe");
|
||||
}
|
||||
});
|
||||
buf = res.signature;
|
||||
num = res.recovery;
|
||||
}
|
||||
|
||||
bool = secp256k1.verify(message, signature, publicKey);
|
||||
|
||||
buf = secp256k1.recover(message, signature, 1);
|
||||
buf = secp256k1.recover(message, signature, 1, true);
|
||||
|
||||
buf = secp256k1.ecdh(publicKey, privateKey);
|
||||
|
||||
buf = secp256k1.ecdhUnsafe(publicKey, privateKey);
|
||||
buf = secp256k1.ecdhUnsafe(publicKey, privateKey, true);
|
||||
}
|
||||
@@ -570,4 +570,277 @@ namespace dataTests {
|
||||
bson.decode(bson.encode({ a: 1 }), { promoteLongs: false }).a;
|
||||
bson.decode(bson.encode({ a: 1 }), { promoteValues: true }).a;
|
||||
}
|
||||
|
||||
namespace protobuf {
|
||||
const {
|
||||
protobuf
|
||||
} = data;
|
||||
|
||||
protobuf.create("hello");
|
||||
protobuf.create(Buffer.from("hello"));
|
||||
protobuf.create({});
|
||||
protobuf.create({}, {});
|
||||
|
||||
namespace schema {
|
||||
const {
|
||||
schema
|
||||
} = protobuf;
|
||||
|
||||
const s = schema.parse("hello");
|
||||
s.syntax;
|
||||
s.package;
|
||||
if (!adone.is.null(s.package)) {
|
||||
const c: string = s.package;
|
||||
}
|
||||
s.imports[0].charCodeAt(100);
|
||||
|
||||
namespace enums {
|
||||
const [a] = s.enums;
|
||||
a.name.charCodeAt(100);
|
||||
a.values;
|
||||
a.options;
|
||||
}
|
||||
|
||||
namespace message {
|
||||
const [msg] = s.messages;
|
||||
msg.name;
|
||||
{
|
||||
const [a] = msg.enums;
|
||||
a.name;
|
||||
a.options;
|
||||
a.values;
|
||||
}
|
||||
{
|
||||
const [a] = msg.extends;
|
||||
a.name;
|
||||
a.message;
|
||||
}
|
||||
{
|
||||
const [a] = msg.messages;
|
||||
a.name;
|
||||
a.enums;
|
||||
a.extends;
|
||||
a.messages;
|
||||
a.fields;
|
||||
a.extensions;
|
||||
}
|
||||
{
|
||||
const [a] = msg.fields;
|
||||
if (!adone.is.null(a.name)) {
|
||||
a.name.charCodeAt(100);
|
||||
}
|
||||
if (!adone.is.null(a.type)) {
|
||||
a.type.charCodeAt(100);
|
||||
}
|
||||
a.tag === 3;
|
||||
if (!adone.is.null(a.map)) {
|
||||
a.map.from.charCodeAt(100);
|
||||
a.map.to.charCodeAt(100);
|
||||
}
|
||||
if (!adone.is.null(a.oneof)) {
|
||||
a.oneof.charCodeAt(100);
|
||||
}
|
||||
a.required === false;
|
||||
a.repeated === true;
|
||||
a.options;
|
||||
}
|
||||
if (!adone.is.null(msg.extensions)) {
|
||||
msg.extensions.from === 2;
|
||||
msg.extensions.to === 3;
|
||||
}
|
||||
}
|
||||
|
||||
s.options;
|
||||
|
||||
s.extends[0].message;
|
||||
s.extends[0].name;
|
||||
|
||||
if (!adone.is.nil(s.services)) {
|
||||
const [svc] = s.services;
|
||||
|
||||
svc.name.charCodeAt(100);
|
||||
svc.options;
|
||||
|
||||
const [m] = svc.methods;
|
||||
|
||||
m.name.charCodeAt(100);
|
||||
if (!adone.is.null(m.input_type)) {
|
||||
m.input_type.charCodeAt(100);
|
||||
}
|
||||
if (!adone.is.null(m.output_type)) {
|
||||
m.output_type.charCodeAt(100);
|
||||
}
|
||||
m.client_streaming === true;
|
||||
m.server_streaming === true;
|
||||
m.options;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
namespace base32 {
|
||||
const {
|
||||
base32
|
||||
} = data;
|
||||
|
||||
base32.charmap("asd");
|
||||
base32.charmap("asd", {});
|
||||
|
||||
base32.rfc4648.alphabet.charCodeAt(0);
|
||||
base32.rfc4648.charmap["X"] === 2;
|
||||
|
||||
base32.crockford.alphabet.charCodeAt(0);
|
||||
base32.crockford.charmap["X"] === 2;
|
||||
|
||||
base32.base32hex.alphabet.charCodeAt(0);
|
||||
base32.base32hex.charmap["X"] === 2;
|
||||
|
||||
namespace decoder {
|
||||
const {
|
||||
Decoder
|
||||
} = base32;
|
||||
new Decoder();
|
||||
new Decoder({
|
||||
type: "base32hex"
|
||||
});
|
||||
new Decoder({
|
||||
type: "crockford"
|
||||
});
|
||||
new Decoder({
|
||||
type: "rfc4648"
|
||||
});
|
||||
new Decoder({
|
||||
type: "rfc4648",
|
||||
charmap: {}
|
||||
});
|
||||
const d = new Decoder();
|
||||
d.write("asd").write("aa");
|
||||
{ const a: Buffer = d.finalize(); }
|
||||
{ const a: Buffer = d.finalize("c"); }
|
||||
}
|
||||
|
||||
namespace encoder {
|
||||
const {
|
||||
Encoder
|
||||
} = base32;
|
||||
|
||||
new Encoder();
|
||||
new Encoder({
|
||||
type: "base32hex"
|
||||
});
|
||||
new Encoder({
|
||||
type: "crockford"
|
||||
});
|
||||
new Encoder({
|
||||
type: "rfc4648"
|
||||
});
|
||||
new Encoder({
|
||||
type: "rfc4648",
|
||||
alphabet: "a"
|
||||
});
|
||||
|
||||
const e = new Encoder();
|
||||
e.write(Buffer.from("b")).write(Buffer.from("a"));
|
||||
{ const a: string = e.finalize(); }
|
||||
{ const a: string = e.finalize(Buffer.from("c")); }
|
||||
}
|
||||
|
||||
base32.encode(Buffer.from("hello")).charCodeAt(100);
|
||||
base32.encode(Buffer.from("hello"), {
|
||||
type: "rfc4648"
|
||||
}).charCodeAt(100);
|
||||
base32.encode(Buffer.from("hello"), {
|
||||
type: "crockford"
|
||||
}).charCodeAt(100);
|
||||
base32.encode(Buffer.from("hello"), {
|
||||
type: "base32hex"
|
||||
}).charCodeAt(100);
|
||||
base32.encode(Buffer.from("hello"), {
|
||||
type: "base32hex",
|
||||
alphabet: "asd"
|
||||
}).charCodeAt(100);
|
||||
|
||||
base32.decode("asd").writeUInt8(100, 0);
|
||||
base32.decode("asd", {
|
||||
type: "base32hex"
|
||||
}).writeUInt8(100, 0);
|
||||
base32.decode("asd", {
|
||||
type: "crockford"
|
||||
}).writeUInt8(100, 0);
|
||||
base32.decode("asd", {
|
||||
type: "rfc4648"
|
||||
}).writeUInt8(100, 0);
|
||||
base32.decode("asd", {
|
||||
type: "rfc4648",
|
||||
charmap: {}
|
||||
}).writeUInt8(100, 0);
|
||||
}
|
||||
|
||||
namespace basex {
|
||||
const {
|
||||
basex
|
||||
} = data;
|
||||
|
||||
const d = basex("abc");
|
||||
const a: Buffer = d.decode("str");
|
||||
const b: string = d.encode(Buffer.from("hello"));
|
||||
const c: Buffer = d.decodeUnsafe("hello");
|
||||
}
|
||||
|
||||
namespace base58 {
|
||||
const {
|
||||
base58
|
||||
} = data;
|
||||
|
||||
const a: Buffer = base58.decode("str");
|
||||
const b: string = base58.encode(Buffer.from("hello"));
|
||||
const c: Buffer = base58.decodeUnsafe("hello");
|
||||
}
|
||||
|
||||
namespace base64url {
|
||||
const {
|
||||
base64url
|
||||
} = data;
|
||||
|
||||
base64url.unescape("a").charCodeAt(100);
|
||||
base64url.escape("a").charCodeAt(100);
|
||||
|
||||
base64url.encode("a").charCodeAt(100);
|
||||
base64url.encode(Buffer.from("a")).charCodeAt(100);
|
||||
base64url.encode(Buffer.from("a"), {}).charCodeAt(100);
|
||||
base64url.encode(Buffer.from("a"), {
|
||||
encoding: "utf8"
|
||||
}).charCodeAt(100);
|
||||
|
||||
base64url.decode("a").charCodeAt(100);
|
||||
base64url.decode("a", { buffer: true }).writeUInt8(0, 0);
|
||||
base64url.decode("a", { encoding: "utf8" }).charCodeAt(100);
|
||||
}
|
||||
|
||||
namespace varint {
|
||||
const {
|
||||
varint
|
||||
} = data;
|
||||
|
||||
varint.encode(12)[0];
|
||||
varint.encode(12, [])[0];
|
||||
varint.encode(12, [], 1)[0];
|
||||
|
||||
varint.decode(Buffer.from("hello")) === 5;
|
||||
varint.decode(Buffer.from("hello"), 2) === 5;
|
||||
varint.encodingLength(100500) === 5;
|
||||
}
|
||||
|
||||
namespace varintSigned {
|
||||
const {
|
||||
varintSigned
|
||||
} = data;
|
||||
|
||||
varintSigned.encode(12)[0];
|
||||
varintSigned.encode(12, [])[0];
|
||||
varintSigned.encode(12, [], 1)[0];
|
||||
|
||||
varintSigned.decode(Buffer.from("hello")) === 5;
|
||||
varintSigned.decode(Buffer.from("hello"), 2) === 5;
|
||||
varintSigned.encodingLength(100500) === 5;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,206 @@
|
||||
namespace adoneTests.fake {
|
||||
const {
|
||||
fake
|
||||
} = adone;
|
||||
|
||||
{ const a: string = fake.address.zipCode(); }
|
||||
{ const a: string = fake.address.zipCode('###'); }
|
||||
{ const a: string = fake.address.city(); }
|
||||
{ const a: string = fake.address.city(0); }
|
||||
{ const a: string = fake.address.cityPrefix(); }
|
||||
{ const a: string = fake.address.citySuffix(); }
|
||||
{ const a: string = fake.address.streetName(); }
|
||||
{ const a: string = fake.address.streetAddress(); }
|
||||
{ const a: string = fake.address.streetAddress(false); }
|
||||
{ const a: string = fake.address.streetSuffix(); }
|
||||
{ const a: string = fake.address.streetPrefix(); }
|
||||
{ const a: string = fake.address.secondaryAddress(); }
|
||||
{ const a: string = fake.address.county(); }
|
||||
{ const a: string = fake.address.country(); }
|
||||
{ const a: string = fake.address.countryCode(); }
|
||||
{ const a: string = fake.address.state(); }
|
||||
{ const a: string = fake.address.state(false); }
|
||||
{ const a: string = fake.address.stateAbbr(); }
|
||||
{ const a: string = fake.address.latitude(); }
|
||||
{ const a: string = fake.address.longitude(); }
|
||||
|
||||
{ const a: string = fake.commerce.color(); }
|
||||
{ const a: string = fake.commerce.department(); }
|
||||
{ const a: string = fake.commerce.productName(); }
|
||||
{ const a: string = fake.commerce.price(); }
|
||||
{ const a: string = fake.commerce.price(0, 0, 0, '#'); }
|
||||
{ const a: string = fake.commerce.productAdjective(); }
|
||||
{ const a: string = fake.commerce.productMaterial(); }
|
||||
{ const a: string = fake.commerce.product(); }
|
||||
|
||||
{ const a: string[] = fake.company.suffixes(); }
|
||||
{ const a: string = fake.company.companyName(); }
|
||||
{ const a: string = fake.company.companyName(0); }
|
||||
{ const a: string = fake.company.companySuffix(); }
|
||||
{ const a: string = fake.company.catchPhrase(); }
|
||||
{ const a: string = fake.company.bs(); }
|
||||
{ const a: string = fake.company.catchPhraseAdjective(); }
|
||||
{ const a: string = fake.company.catchPhraseDescriptor(); }
|
||||
{ const a: string = fake.company.catchPhraseNoun(); }
|
||||
{ const a: string = fake.company.bsAdjective(); }
|
||||
{ const a: string = fake.company.bsBuzz(); }
|
||||
{ const a: string = fake.company.bsNoun(); }
|
||||
|
||||
{ const a: string = fake.database.column(); }
|
||||
{ const a: string = fake.database.type(); }
|
||||
{ const a: string = fake.database.collation(); }
|
||||
{ const a: string = fake.database.engine(); }
|
||||
|
||||
{ const a: Date = fake.date.past(); }
|
||||
{ const a: Date = fake.date.future(); }
|
||||
{ const a: Date = fake.date.between('foo', 'bar'); }
|
||||
{ const a: Date = fake.date.between(new Date(), new Date()); }
|
||||
{ const a: Date = fake.date.recent(); }
|
||||
{ const a: Date = fake.date.recent(100); }
|
||||
{ const a: Date = fake.date.soon(); }
|
||||
{ const a: Date = fake.date.soon(30); }
|
||||
{ const a: string = fake.date.month(); }
|
||||
{ const a: string = fake.date.month({
|
||||
abbr: true,
|
||||
context: true
|
||||
}); }
|
||||
{ const a: string = fake.date.weekday(); }
|
||||
{ const a: string = fake.date.weekday({
|
||||
abbr: true,
|
||||
context: true
|
||||
}); }
|
||||
|
||||
{ const a: string = fake.finance.account(); }
|
||||
{ const a: string = fake.finance.account(0); }
|
||||
{ const a: string = fake.finance.accountName(); }
|
||||
{ const a: string = fake.finance.mask(); }
|
||||
{ const a: string = fake.finance.mask(0, false, false); }
|
||||
{ const a: string = fake.finance.amount(); }
|
||||
{ const a: string = fake.finance.amount(0, 0, 0, '#'); }
|
||||
{ const a: string = fake.finance.transactionType(); }
|
||||
{ const a: string = fake.finance.currencyCode(); }
|
||||
{ const a: string = fake.finance.currencyName(); }
|
||||
{ const a: string = fake.finance.currencySymbol(); }
|
||||
{ const a: string = fake.finance.bitcoinAddress(); }
|
||||
{ const a: string = fake.finance.ethereumAddress(); }
|
||||
{ const a: string = fake.finance.iban(); }
|
||||
{ const a: string = fake.finance.iban(true); }
|
||||
{ const a: string = fake.finance.bic(); }
|
||||
|
||||
{ const a: string = fake.hacker.abbreviation(); }
|
||||
{ const a: string = fake.hacker.adjective(); }
|
||||
{ const a: string = fake.hacker.noun(); }
|
||||
{ const a: string = fake.hacker.verb(); }
|
||||
{ const a: string = fake.hacker.ingverb(); }
|
||||
{ const a: string = fake.hacker.phrase(); }
|
||||
|
||||
{ const a: string = fake.helpers.randomize(); }
|
||||
{ const a: number = fake.helpers.randomize([1, 2, 3, 4]); }
|
||||
{ const a: string = fake.helpers.randomize(['foo', 'bar', 'quux']); }
|
||||
{ const a: string = fake.helpers.slugify('foo bar quux'); }
|
||||
{ const a: string = fake.helpers.replaceSymbolWithNumber('foo# bar#'); }
|
||||
{ const a: string = fake.helpers.replaceSymbols('foo# bar? quux#'); }
|
||||
{ const a: string[] = fake.helpers.shuffle(['foo', 'bar', 'quux']); }
|
||||
{ const a: string = fake.helpers.mustache('{{foo}}{{bar}}', {foo: 'x', bar: 'y'}); }
|
||||
|
||||
const card = fake.helpers.createCard();
|
||||
{ const a: string = card.name; }
|
||||
{ const a: string = card.address.streetA; }
|
||||
const contextualCard = fake.helpers.contextualCard();
|
||||
{ const a: string = contextualCard.name; }
|
||||
{ const a: string = contextualCard.address.suite; }
|
||||
const userCard = fake.helpers.userCard();
|
||||
{ const a: string = userCard.name; }
|
||||
{ const a: string = userCard.address.suite; }
|
||||
|
||||
{ const a: string = fake.internet.avatar(); }
|
||||
{ const a: string = fake.internet.email(); }
|
||||
{ const a: string = fake.internet.email('foo', 'bar', 'quux'); }
|
||||
{ const a: string = fake.internet.exampleEmail(); }
|
||||
{ const a: string = fake.internet.exampleEmail('foo', 'bar'); }
|
||||
{ const a: string = fake.internet.protocol(); }
|
||||
{ const a: string = fake.internet.url(); }
|
||||
{ const a: string = fake.internet.domainName(); }
|
||||
{ const a: string = fake.internet.domainSuffix(); }
|
||||
{ const a: string = fake.internet.domainWord(); }
|
||||
{ const a: string = fake.internet.ip(); }
|
||||
{ const a: string = fake.internet.userAgent(); }
|
||||
{ const a: string = fake.internet.color(); }
|
||||
{ const a: string = fake.internet.color(0, 0, 0); }
|
||||
{ const a: string = fake.internet.mac(); }
|
||||
{ const a: string = fake.internet.password(); }
|
||||
{ const a: string = fake.internet.password(0, false, '#', 'foo'); }
|
||||
|
||||
{ const a: string = fake.lorem.word(); }
|
||||
{ const a: string = fake.lorem.words(); }
|
||||
{ const a: string = fake.lorem.words(0); }
|
||||
{ const a: string = fake.lorem.sentence(); }
|
||||
{ const a: string = fake.lorem.sentence(0, 0); }
|
||||
{ const a: string = fake.lorem.slug(); }
|
||||
{ const a: string = fake.lorem.slug(0); }
|
||||
{ const a: string = fake.lorem.sentences(); }
|
||||
{ const a: string = fake.lorem.sentences(0); }
|
||||
{ const a: string = fake.lorem.paragraph(); }
|
||||
{ const a: string = fake.lorem.paragraph(0); }
|
||||
{ const a: string = fake.lorem.paragraphs(); }
|
||||
{ const a: string = fake.lorem.paragraphs(0, ''); }
|
||||
{ const a: string = fake.lorem.text(); }
|
||||
{ const a: string = fake.lorem.text(0); }
|
||||
{ const a: string = fake.lorem.lines(); }
|
||||
{ const a: string = fake.lorem.lines(0); }
|
||||
|
||||
{ const a: string = fake.name.firstName(); }
|
||||
{ const a: string = fake.name.firstName(0); }
|
||||
{ const a: string = fake.name.lastName(); }
|
||||
{ const a: string = fake.name.lastName(0); }
|
||||
{ const a: string = fake.name.findName(); }
|
||||
{ const a: string = fake.name.findName('', '', 0); }
|
||||
{ const a: string = fake.name.jobTitle(); }
|
||||
{ const a: string = fake.name.prefix(); }
|
||||
{ const a: string = fake.name.suffix(); }
|
||||
{ const a: string = fake.name.title(); }
|
||||
{ const a: string = fake.name.jobDescriptor(); }
|
||||
{ const a: string = fake.name.jobArea(); }
|
||||
{ const a: string = fake.name.jobType(); }
|
||||
|
||||
{ const a: string = fake.phone.phoneNumber(); }
|
||||
{ const a: string = fake.phone.phoneNumber('#'); }
|
||||
{ const a: string = fake.phone.phoneNumberFormat(); }
|
||||
{ const a: string = fake.phone.phoneNumberFormat(0); }
|
||||
{ const a: string = fake.phone.phoneFormats(); }
|
||||
|
||||
{ const a: number = fake.random.number(); }
|
||||
{ const a: number = fake.random.number(0); }
|
||||
{ const a: number = fake.random.number({
|
||||
min: 0,
|
||||
max: 0,
|
||||
precision: 0
|
||||
}); }
|
||||
{ const a: string = fake.random.arrayElement(); }
|
||||
{ const a: string = fake.random.arrayElement(['foo', 'bar', 'quux']); }
|
||||
{ const a: string = fake.random.objectElement(); }
|
||||
{ const a: string = fake.random.objectElement({foo: 'bar', field: 'foo'}); }
|
||||
{ const a: string = fake.random.uuid(); }
|
||||
{ const a: boolean = fake.random.boolean(); }
|
||||
{ const a: string = fake.random.word(); }
|
||||
{ const a: string = fake.random.word("noun"); }
|
||||
{ const a: string = fake.random.words(); }
|
||||
{ const a: string = fake.random.words(0); }
|
||||
{ const a: string = fake.random.image(); }
|
||||
{ const a: string = fake.random.locale(); }
|
||||
{ const a: string = fake.random.alphaNumeric(); }
|
||||
{ const a: string = fake.random.alphaNumeric(0); }
|
||||
{ const a: string = fake.random.hexaDecimal(); }
|
||||
{ const a: string = fake.random.hexaDecimal(3); }
|
||||
|
||||
{ const a: string = fake.system.fileName("foo", "bar"); }
|
||||
{ const a: string = fake.system.commonFileName("foo", "bar"); }
|
||||
{ const a: string = fake.system.mimeType(); }
|
||||
{ const a: string = fake.system.commonFileType(); }
|
||||
{ const a: string = fake.system.commonFileExt(); }
|
||||
{ const a: string = fake.system.fileType(); }
|
||||
{ const a: string = fake.system.fileExt("foo"); }
|
||||
{ const a: string = fake.system.directoryPath(); }
|
||||
{ const a: string = fake.system.filePath(); }
|
||||
{ const a: string = fake.system.semver(); }
|
||||
}
|
||||
@@ -99,15 +99,34 @@ namespace isTests {
|
||||
}
|
||||
}
|
||||
{ const a: boolean = is.json({}); }
|
||||
{ const a: boolean = is.object({}); }
|
||||
{ const a: boolean = is.plainObject({}); }
|
||||
{
|
||||
const a: boolean = is.object({});
|
||||
const b: any = 2;
|
||||
if (is.object(b)) {
|
||||
const c: object = b;
|
||||
}
|
||||
}
|
||||
{
|
||||
const a: boolean = is.plainObject({});
|
||||
const b: any = 2;
|
||||
if (is.plainObject(b)) {
|
||||
const c: object = b;
|
||||
}
|
||||
}
|
||||
{ const a: boolean = is.class({}); }
|
||||
{ const a: boolean = is.emptyObject({}); }
|
||||
{ const a: boolean = is.propertyOwned({}, "a"); }
|
||||
{ const a: boolean = is.propertyDefined({}, "a"); }
|
||||
{ const a: boolean = is.conforms({}, {}); }
|
||||
{ const a: boolean = is.conforms({}, {}, true); }
|
||||
{ const a: boolean = is.arrayLikeObject({}); }
|
||||
{
|
||||
const a: boolean = is.arrayLikeObject({});
|
||||
const b: any = {};
|
||||
if (is.arrayLikeObject(b)) {
|
||||
const c: number = b.length;
|
||||
b[0];
|
||||
}
|
||||
}
|
||||
{ const a: boolean = is.inArray(1, [1, 2, 3]); }
|
||||
{ const a: boolean = is.inArray(1, [1, 2, 3], 0); }
|
||||
{ const a: boolean = is.inArray(1, [1, 2, 3], 0, (a, b) => a === b); }
|
||||
@@ -133,8 +152,20 @@ namespace isTests {
|
||||
}
|
||||
}
|
||||
{ const a: boolean = is.dotfile("abc"); }
|
||||
{ const a: boolean = is.function(() => { }); }
|
||||
{ const a: boolean = is.asyncFunction(async () => { }); }
|
||||
{
|
||||
const a: boolean = is.function(() => { });
|
||||
const b: any = 2;
|
||||
if (is.function(b)) {
|
||||
b();
|
||||
}
|
||||
}
|
||||
{
|
||||
const a: boolean = is.asyncFunction(async () => { });
|
||||
const b: any = 2;
|
||||
if (is.asyncFunction(b)) {
|
||||
b().then(() => {});
|
||||
}
|
||||
}
|
||||
{
|
||||
const a: boolean = is.promise({});
|
||||
const b: any = 2;
|
||||
@@ -155,7 +186,13 @@ namespace isTests {
|
||||
}
|
||||
}
|
||||
{ const a: boolean = is.callback({}); }
|
||||
{ const a: boolean = is.generator({}); }
|
||||
{
|
||||
const a: boolean = is.generator({});
|
||||
const b: any = 2;
|
||||
if (is.generator(b)) {
|
||||
b().next();
|
||||
}
|
||||
}
|
||||
{ const a: boolean = is.nan({}); }
|
||||
{
|
||||
const a: boolean = is.finite({});
|
||||
@@ -226,13 +263,51 @@ namespace isTests {
|
||||
}
|
||||
}
|
||||
{ const a: boolean = is.transform({}); }
|
||||
{ const a: boolean = is.subsystem({}); }
|
||||
{ const a: boolean = is.application({}); }
|
||||
{
|
||||
const a: boolean = is.subsystem({});
|
||||
const b: any = 2;
|
||||
if (is.subsystem(b)) {
|
||||
b.configureSubsystems().then(() => {});
|
||||
}
|
||||
}
|
||||
{
|
||||
const a: boolean = is.application({});
|
||||
const b: any = 2;
|
||||
if (is.application(b)) {
|
||||
b.exitOnSignal("SIGINT");
|
||||
}
|
||||
}
|
||||
{ const a: boolean = is.logger({}); }
|
||||
{ const a: boolean = is.coreStream({}); }
|
||||
{ const a: boolean = is.fastStream({}); }
|
||||
{ const a: boolean = is.fastLocalStream({}); }
|
||||
{ const a: boolean = is.fastLocalMapStream({}); }
|
||||
{
|
||||
const a: boolean = is.coreStream({});
|
||||
const b: any = 2;
|
||||
if (is.coreStream(b)) {
|
||||
b.map((x) => 2).forEach((t: number) => {
|
||||
//
|
||||
});
|
||||
}
|
||||
}
|
||||
{
|
||||
const a: boolean = is.fastStream({});
|
||||
const b: any = 2;
|
||||
if (is.fastStream(b)) {
|
||||
b.compress("deflate");
|
||||
}
|
||||
}
|
||||
{
|
||||
const a: boolean = is.fastLocalStream({});
|
||||
const b: any = 2;
|
||||
if (is.fastLocalStream(b)) {
|
||||
b.compress("gz");
|
||||
}
|
||||
}
|
||||
{
|
||||
const a: boolean = is.fastLocalMapStream({});
|
||||
const b: any = 2;
|
||||
if (is.fastLocalMapStream(b)) {
|
||||
b.decompress("gz");
|
||||
}
|
||||
}
|
||||
{ const a: boolean = is.genesisNetron({}); }
|
||||
{ const a: boolean = is.genesisPeer({}); }
|
||||
{ const a: boolean = is.netronAdapter({}); }
|
||||
@@ -248,7 +323,14 @@ namespace isTests {
|
||||
{ const a: boolean = is.netronStub({}); }
|
||||
{ const a: boolean = is.netronRemoteStub({}); }
|
||||
{ const a: boolean = is.netronStream({}); }
|
||||
{ const a: boolean = is.iterable({}); }
|
||||
{
|
||||
const a: boolean = is.iterable({});
|
||||
const b: any = 2;
|
||||
if (is.iterable(b)) {
|
||||
const it = b[Symbol.iterator]();
|
||||
it.next();
|
||||
}
|
||||
}
|
||||
{ const a: boolean = is.windows; }
|
||||
{ const a: boolean = is.linux; }
|
||||
{ const a: boolean = is.freebsd; }
|
||||
|
||||
@@ -0,0 +1,499 @@
|
||||
namespace adoneTests.net.http.client {
|
||||
const {
|
||||
net: {
|
||||
http: {
|
||||
client
|
||||
}
|
||||
}
|
||||
} = adone;
|
||||
|
||||
let bool: boolean;
|
||||
let num: number;
|
||||
let str: string;
|
||||
let buf: Buffer;
|
||||
let stream: nodestd.stream.Readable;
|
||||
|
||||
namespace Client {
|
||||
const {
|
||||
Client
|
||||
} = client;
|
||||
|
||||
new Client();
|
||||
new Client({});
|
||||
new Client({
|
||||
auth: {
|
||||
username: "a"
|
||||
}
|
||||
});
|
||||
new Client({
|
||||
auth: {
|
||||
password: "a"
|
||||
}
|
||||
});
|
||||
new Client({
|
||||
cancelToken: new client.CancelToken(() => {})
|
||||
});
|
||||
new Client({
|
||||
data: Buffer.from("hello")
|
||||
});
|
||||
new Client({
|
||||
data: "hello"
|
||||
});
|
||||
new Client({
|
||||
data: adone.fs.createReadStream(__filename)
|
||||
});
|
||||
new Client({
|
||||
data: new ArrayBuffer(10)
|
||||
});
|
||||
new Client({
|
||||
formData: {
|
||||
a: "string"
|
||||
}
|
||||
});
|
||||
new Client({
|
||||
formData: {
|
||||
a: ["string"]
|
||||
}
|
||||
});
|
||||
new Client({
|
||||
formData: {
|
||||
a: [adone.fs.createReadStream(__filename)]
|
||||
}
|
||||
});
|
||||
new Client({
|
||||
formData: {
|
||||
a: {
|
||||
value: "string",
|
||||
options: {}
|
||||
}
|
||||
}
|
||||
});
|
||||
new Client({
|
||||
formData: {
|
||||
a: {
|
||||
value: "string",
|
||||
options: {
|
||||
contentType: "a"
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
new Client({
|
||||
formData: {
|
||||
a: {
|
||||
value: "string",
|
||||
options: {
|
||||
filename: "a"
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
new Client({
|
||||
formData: {
|
||||
a: {
|
||||
value: "string",
|
||||
options: {
|
||||
header: "a"
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
new Client({
|
||||
formData: {
|
||||
a: {
|
||||
value: "string",
|
||||
options: {
|
||||
header: {
|
||||
a: "a"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
new Client({
|
||||
formData: {
|
||||
a: {
|
||||
value: "string",
|
||||
options: {
|
||||
knownLength: 100500
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
new Client({
|
||||
formData: {
|
||||
a: [{
|
||||
value: "string",
|
||||
options: {
|
||||
knownLength: 100500
|
||||
}
|
||||
}]
|
||||
}
|
||||
});
|
||||
new Client({
|
||||
headers: {
|
||||
"User-Agent": "true"
|
||||
}
|
||||
});
|
||||
new Client({
|
||||
httpAgent: {}
|
||||
});
|
||||
new Client({
|
||||
httpsAgent: {}
|
||||
});
|
||||
new Client({
|
||||
maxContentLength: 100500
|
||||
});
|
||||
new Client({
|
||||
maxRedirects: 100500
|
||||
});
|
||||
new Client({
|
||||
method: "GET"
|
||||
});
|
||||
new Client({
|
||||
onUploadProgress(event) {
|
||||
bool = event.lengthComputable;
|
||||
num = event.loaded;
|
||||
num = event.total;
|
||||
}
|
||||
});
|
||||
new Client({
|
||||
params: {
|
||||
a: 1
|
||||
}
|
||||
});
|
||||
new Client({
|
||||
paramsSerializer(params: object) {
|
||||
return "asd";
|
||||
}
|
||||
});
|
||||
new Client({
|
||||
proxy: "socks5://localhost"
|
||||
});
|
||||
new Client({
|
||||
proxy: {
|
||||
protocol: "socks5",
|
||||
host: "127.0.0.1",
|
||||
port: 9000,
|
||||
auth: {
|
||||
username: "hello",
|
||||
password: "world"
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
new Client({
|
||||
rejectUnauthorized: true
|
||||
});
|
||||
new Client({
|
||||
responseEncoding: "CP1251"
|
||||
});
|
||||
new Client({
|
||||
responseType: "stream"
|
||||
});
|
||||
new Client({
|
||||
timeout: 100
|
||||
});
|
||||
new Client({
|
||||
transformRequest: [(data, headers, config) => {
|
||||
return data;
|
||||
}]
|
||||
});
|
||||
new Client({
|
||||
transformResponse: [(data, headers, config) => {
|
||||
return data;
|
||||
}]
|
||||
});
|
||||
new Client({
|
||||
transport: adone.std.http
|
||||
});
|
||||
new Client({
|
||||
validateStatus(status) {
|
||||
return status > 100;
|
||||
}
|
||||
});
|
||||
new Client({
|
||||
xsrfCookieName: "a"
|
||||
});
|
||||
new Client({
|
||||
xsrfHeaderName: "a"
|
||||
});
|
||||
|
||||
const req = new Client();
|
||||
|
||||
namespace request {
|
||||
req.request({
|
||||
method: "GET"
|
||||
}).then((resp) => {
|
||||
num = resp.status;
|
||||
str = resp.statusText;
|
||||
const len = resp.headers["content-length"];
|
||||
if (!adone.is.undefined(len)) {
|
||||
str = len;
|
||||
}
|
||||
const data = resp.data;
|
||||
if (!adone.is.object(data)) {
|
||||
str = data;
|
||||
}
|
||||
});
|
||||
req.request({
|
||||
method: "GET",
|
||||
responseType: "string"
|
||||
}).then((resp) => {
|
||||
num = resp.status;
|
||||
str = resp.statusText;
|
||||
str = resp.data;
|
||||
});
|
||||
req.request({
|
||||
method: "GET",
|
||||
responseType: "buffer"
|
||||
}).then((resp) => {
|
||||
num = resp.status;
|
||||
str = resp.statusText;
|
||||
buf = resp.data;
|
||||
});
|
||||
req.request({
|
||||
method: "GET",
|
||||
responseType: "stream"
|
||||
}).then((resp) => {
|
||||
num = resp.status;
|
||||
str = resp.statusText;
|
||||
stream = resp.data;
|
||||
});
|
||||
}
|
||||
|
||||
namespace get {
|
||||
req.get("url").then((resp) => {
|
||||
num = resp.status;
|
||||
str = resp.statusText;
|
||||
const data = resp.data;
|
||||
if (!adone.is.object(data)) {
|
||||
str = data;
|
||||
}
|
||||
});
|
||||
req.get("url", {
|
||||
responseType: "string"
|
||||
}).then((resp) => {
|
||||
num = resp.status;
|
||||
str = resp.statusText;
|
||||
str = resp.data;
|
||||
});
|
||||
req.get("url", {
|
||||
responseType: "buffer"
|
||||
}).then((resp) => {
|
||||
num = resp.status;
|
||||
str = resp.statusText;
|
||||
buf = resp.data;
|
||||
});
|
||||
req.get("url", {
|
||||
responseType: "stream"
|
||||
}).then((resp) => {
|
||||
num = resp.status;
|
||||
str = resp.statusText;
|
||||
stream = resp.data;
|
||||
});
|
||||
}
|
||||
|
||||
namespace post {
|
||||
req.post("url", {}).then((resp) => {
|
||||
num = resp.status;
|
||||
str = resp.statusText;
|
||||
const data = resp.data;
|
||||
if (!adone.is.object(data)) {
|
||||
str = data;
|
||||
}
|
||||
});
|
||||
req.post("url", {}, {
|
||||
responseType: "string"
|
||||
}).then((resp) => {
|
||||
num = resp.status;
|
||||
str = resp.statusText;
|
||||
str = resp.data;
|
||||
});
|
||||
req.post("url", {}, {
|
||||
responseType: "buffer"
|
||||
}).then((resp) => {
|
||||
num = resp.status;
|
||||
str = resp.statusText;
|
||||
buf = resp.data;
|
||||
});
|
||||
req.post("url", {}, {
|
||||
responseType: "stream"
|
||||
}).then((resp) => {
|
||||
num = resp.status;
|
||||
str = resp.statusText;
|
||||
stream = resp.data;
|
||||
});
|
||||
}
|
||||
|
||||
namespace put {
|
||||
req.put("url", {}).then((resp) => {
|
||||
num = resp.status;
|
||||
str = resp.statusText;
|
||||
const data = resp.data;
|
||||
if (!adone.is.object(data)) {
|
||||
str = data;
|
||||
}
|
||||
});
|
||||
req.put("url", {}, {
|
||||
responseType: "string"
|
||||
}).then((resp) => {
|
||||
num = resp.status;
|
||||
str = resp.statusText;
|
||||
str = resp.data;
|
||||
});
|
||||
req.put("url", {}, {
|
||||
responseType: "buffer"
|
||||
}).then((resp) => {
|
||||
num = resp.status;
|
||||
str = resp.statusText;
|
||||
buf = resp.data;
|
||||
});
|
||||
req.put("url", {}, {
|
||||
responseType: "stream"
|
||||
}).then((resp) => {
|
||||
num = resp.status;
|
||||
str = resp.statusText;
|
||||
stream = resp.data;
|
||||
});
|
||||
}
|
||||
|
||||
namespace patch {
|
||||
req.patch("url", {}).then((resp) => {
|
||||
num = resp.status;
|
||||
str = resp.statusText;
|
||||
const data = resp.data;
|
||||
if (!adone.is.object(data)) {
|
||||
str = data;
|
||||
}
|
||||
});
|
||||
req.patch("url", {}, {
|
||||
responseType: "string"
|
||||
}).then((resp) => {
|
||||
num = resp.status;
|
||||
str = resp.statusText;
|
||||
str = resp.data;
|
||||
});
|
||||
req.patch("url", {}, {
|
||||
responseType: "buffer"
|
||||
}).then((resp) => {
|
||||
num = resp.status;
|
||||
str = resp.statusText;
|
||||
buf = resp.data;
|
||||
});
|
||||
req.patch("url", {}, {
|
||||
responseType: "stream"
|
||||
}).then((resp) => {
|
||||
num = resp.status;
|
||||
str = resp.statusText;
|
||||
stream = resp.data;
|
||||
});
|
||||
}
|
||||
|
||||
namespace _delete {
|
||||
req.delete("url").then((resp) => {
|
||||
num = resp.status;
|
||||
str = resp.statusText;
|
||||
const data = resp.data;
|
||||
if (!adone.is.object(data)) {
|
||||
str = data;
|
||||
}
|
||||
});
|
||||
req.delete("url", {
|
||||
responseType: "string"
|
||||
}).then((resp) => {
|
||||
num = resp.status;
|
||||
str = resp.statusText;
|
||||
str = resp.data;
|
||||
});
|
||||
req.delete("url", {
|
||||
responseType: "buffer"
|
||||
}).then((resp) => {
|
||||
num = resp.status;
|
||||
str = resp.statusText;
|
||||
buf = resp.data;
|
||||
});
|
||||
req.delete("url", {
|
||||
responseType: "stream"
|
||||
}).then((resp) => {
|
||||
num = resp.status;
|
||||
str = resp.statusText;
|
||||
stream = resp.data;
|
||||
});
|
||||
}
|
||||
|
||||
namespace options {
|
||||
req.options("url").then((resp) => {
|
||||
num = resp.status;
|
||||
str = resp.statusText;
|
||||
const data = resp.data;
|
||||
if (!adone.is.object(data)) {
|
||||
str = data;
|
||||
}
|
||||
});
|
||||
req.options("url", {
|
||||
responseType: "string"
|
||||
}).then((resp) => {
|
||||
num = resp.status;
|
||||
str = resp.statusText;
|
||||
str = resp.data;
|
||||
});
|
||||
req.options("url", {
|
||||
responseType: "buffer"
|
||||
}).then((resp) => {
|
||||
num = resp.status;
|
||||
str = resp.statusText;
|
||||
buf = resp.data;
|
||||
});
|
||||
req.options("url", {
|
||||
responseType: "stream"
|
||||
}).then((resp) => {
|
||||
num = resp.status;
|
||||
str = resp.statusText;
|
||||
stream = resp.data;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
namespace request {
|
||||
client.request.get("htllo").then((x) => {
|
||||
num = x.status;
|
||||
});
|
||||
}
|
||||
|
||||
namespace create {
|
||||
client.create();
|
||||
client.create({});
|
||||
const req = client.create({
|
||||
headers: {
|
||||
"User-Agent": "Hello"
|
||||
}
|
||||
});
|
||||
req.get("hello world").then((x) => {
|
||||
num = x.status;
|
||||
});
|
||||
}
|
||||
|
||||
namespace cancel {
|
||||
const {
|
||||
Cancel,
|
||||
CancelToken,
|
||||
isCancel
|
||||
} = client;
|
||||
|
||||
new CancelToken((s: string) => 123).promise.then((x) => {
|
||||
str = x.message;
|
||||
});
|
||||
new CancelToken((s: string) => 123).reason;
|
||||
CancelToken.source().token.promise;
|
||||
CancelToken.source().cancel("hello");
|
||||
|
||||
new Cancel("hello").message;
|
||||
|
||||
const a: any = 2;
|
||||
|
||||
if (isCancel(a)) {
|
||||
str = a.message;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
namespace adoneTests.regex {
|
||||
const {
|
||||
regex
|
||||
} = adone;
|
||||
|
||||
regex.ansi().test("a");
|
||||
regex.filename().test("a");
|
||||
regex.idn().test("a");
|
||||
regex.ip4().test("a");
|
||||
regex.ip6().test("a");
|
||||
regex.protocol().test("a");
|
||||
regex.punycode().test("a");
|
||||
regex.shebang().test("a");
|
||||
regex.uri().test("a");
|
||||
regex.uuid4().test("a");
|
||||
regex.uuid5().test("a");
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user