Adding descriptions to Document.get/setSelectedDataAsync

This commit is contained in:
Alex Jerabek
2018-06-20 14:10:16 -07:00
347 changed files with 43743 additions and 1037 deletions
+1
View File
@@ -1104,6 +1104,7 @@
/types/ffprobe-static/ @iamstevetran
/types/fhir-js-client/ @rmchndrng
/types/fibers/ @soywiz
/types/fibjs/ @richardo2016
/types/figures/ @BendingBender
/types/file-exists/ @BendingBender
/types/file-saver/ @cyrilschumacher @DaIgeb @chrismbarr
+1 -1
View File
@@ -54,7 +54,7 @@ Before you share your improvement with the world, use it yourself.
#### Test editing an existing package
To add new features you can use [module augmentation](http://www.typescriptlang.org/docs/handbook/declaration-merging.html).
To add new features you can use [module augmentation](http://www.typescriptlang.org/docs/handbook/declaration-merging.html#module-augmentation).
You can also directly edit the types in `node_modules/@types/foo/index.d.ts`, or copy them from there and follow the steps below.
+2 -1
View File
@@ -832,8 +832,9 @@ declare namespace AceAjax {
/**
* [Sets the value of the distance between the left of the editor and the leftmost part of the visible content.]{: #EditSession.setScrollLeft}
* @param scrollLeft The new scroll left value
**/
setScrollLeft(): void;
setScrollLeft(scrollLeft: number): void;
/**
* [Returns the value of the distance between the left of the editor and the leftmost part of the visible content.]{: #EditSession.getScrollLeft}
+38 -1
View File
@@ -18,6 +18,23 @@ function createFoldTestSession() {
return session;
}
function createScrollTestRenderer(): AceAjax.VirtualRenderer | null {
var el = document.createElement("div");
if (!el.getBoundingClientRect) {
console.log("Skipping test: This test only runs in the browser");
return null;
}
el.style.left = "20px";
el.style.top = "30px";
el.style.width = "300px";
el.style.height = "100px";
document.body.appendChild(el);
return new AceAjax.VirtualRenderer(el);
}
function assertArray(a, b) {
assert.equal(a + "", b + "");
assert.ok(a.length == b.length);
@@ -915,5 +932,25 @@ const aceEditSessionTests = {
session = new AceAjax.EditSession(new Array(30).join("\n"));
session.documentToScreenPosition(2, 0);
session.documentToScreenPosition(2, 0);
},
"test setScrollTop()": function() {
var renderer = createScrollTestRenderer();
var session = new AceAjax.EditSession(["1", "2", "3", "2", "3", "4"]);
renderer.setSession(session);
assert.equal(renderer.getScrollTop(), 0);
session.setScrollTop(40);
assert.equal(renderer.getScrollTop(), 40);
renderer.getScrollTop()
},
"test setScrollLeft()": function() {
var renderer = createScrollTestRenderer();
var session = new AceAjax.EditSession(["1", "2", "3", "2", "3", "4"]);
renderer.setSession(session);
assert.equal(renderer.getScrollLeft(), 0);
session.setScrollLeft(40);
assert.equal(renderer.getScrollLeft(), 40);
renderer.getScrollLeft()
}
};
};
+6
View File
@@ -0,0 +1,6 @@
import bufferFrom = require('buffer-from');
bufferFrom([1, 2, 3, 4]); // $ExpectType Buffer
bufferFrom(new Uint8Array([1, 2, 3, 4]).buffer, 1, 2); // $ExpectType Buffer
bufferFrom('test', 'utf8'); // $ExpectType Buffer
bufferFrom(bufferFrom('test')); // $ExpectType Buffer
+12
View File
@@ -0,0 +1,12 @@
// Type definitions for buffer-from 1.1
// Project: https://github.com/LinusU/buffer-from#readme
// Definitions by: Nat Burns <https://github.com/burnnat>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference types="node" />
declare function bufferFrom(arrayBuffer: ArrayBuffer, byteOffset?: number, length?: number): Buffer;
declare function bufferFrom(str: string, encoding?: string): Buffer;
declare function bufferFrom(data: ReadonlyArray<any> | Buffer): Buffer;
export = bufferFrom;
+23
View File
@@ -0,0 +1,23 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"buffer-from-tests.ts"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }
+5
View File
@@ -0,0 +1,5 @@
import yaml = require('config-yaml');
yaml('./simple.yaml');
yaml('./simple.yaml', { encoding: 'gbk' });
yaml('./simple.yaml', { encoding: 'utf-8' });
+19
View File
@@ -0,0 +1,19 @@
// Type definitions for config-yaml 1.1
// Project: https://github.com/neolao/config-yaml#readme
// Definitions by: My Self <https://github.com/me>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.1
/// <reference types="node" />
import * as fs from 'fs';
export = Yaml;
declare namespace Yaml {
interface Options {
encoding: string;
}
}
declare function Yaml(path: fs.PathLike, options?: Partial<Yaml.Options>): any;
+24
View File
@@ -0,0 +1,24 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"allowSyntheticDefaultImports": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"config-yaml-tests.ts"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }
+5 -2
View File
@@ -7,7 +7,10 @@
"paths": {
"mongodb": [
"mongodb/v2"
]
],
"mongoose": [
"mongoose/v4"
]
},
"noImplicitAny": true,
"noImplicitThis": true,
@@ -25,4 +28,4 @@
"index.d.ts",
"connect-mongo-tests.ts"
]
}
}
+16 -15
View File
@@ -2,14 +2,8 @@
// TODO: document all aliases as aliases, not as duplicates!
const assert = (tag: boolean) => { if (!tag) throw new Error(); };
const aliases = (...obj: Array<{}>) => { if (obj.slice(1).some((alias) => alias !== obj[0])) throw new Error(); };
const events = (obj: any) => {
aliases(obj.on, obj.bind, obj.listen, obj.addListener);
aliases(obj.promiseOn, obj.pon);
aliases(obj.off, obj.unbind, obj.unlisten, obj.removeListener);
aliases(obj.emit, obj.trigger);
};
const assert = (tag: boolean) => {};
const aliases = (...obj: Array<{}>) => {};
// definitions
function oneOf<A, B, C, D, E>(a: A, b: B, c: C, d: D, e: E): A | B | C | D | E;
@@ -129,7 +123,7 @@ cy.on('zoom', (event) => {
}
});
cy.off('zoom');
events(cy);
// events(cy); - TODO
cy.add({ data: { id: 'g' }, position: {x: 200, y: 150} });
cy.add([
@@ -383,11 +377,18 @@ assert(eles.removed());
assert(!eles.inside());
eles.restore();
([ele, eles, node, nodes, edge, edges] as cytoscape.CollectionReturnValue[]).forEach((elem) => {
aliases(elem.clone, elem.copy);
events(elem);
aliases(elem.data, elem.attr);
aliases(elem.removeData, elem.removeAttr);
([ele, eles, node, nodes, edge, edges] as [
cytoscape.SingularElementReturnValue,
cytoscape.CollectionReturnValue,
cytoscape.NodeSingular,
cytoscape.NodeCollection,
cytoscape.EdgeSingular,
cytoscape.EdgeCollection
]).forEach((elemType) => {
aliases(elemType.clone, elemType.copy);
// events(elemType); - TODO
aliases(elemType.data, elemType.attr);
aliases(elemType.removeData, elemType.removeAttr);
});
// TODO: tests for data flow
@@ -490,6 +491,6 @@ eles.reduce<any[]>((prev, ele, i, eles) => [...prev, [ele, i]], []).concat(['fin
const min = eles.min((ele, i, eles) => ele.id.length + i); min.ele.scratch('min', min.value);
const max = eles.max((ele, i, eles) => ele.id.length + i); max.ele.scratch('max', max.value);
// TODO: traversing (need to actively check the nodes/edeges distinction)
// TODO: traversing (need to actively check the nodes/edges distinction)
// TODO: algorithms
// TODO: compound nodes (there aren't any in current test case)
+25 -10
View File
@@ -1118,7 +1118,7 @@ declare namespace cytoscape {
* http://js.cytoscape.org/#collection
*/
interface Collection<TOut = SingularElementReturnValue, TIn = SingularElementArgument>
extends Singular,
extends
CollectionGraphManipulation, CollectionEvents,
CollectionData, CollectionPosition,
CollectionLayout,
@@ -1129,8 +1129,10 @@ declare namespace cytoscape {
/**
* ele --> Cy.Singular
* a collection of a single element (node or edge)
* NB: every singular collection is a general collection too (but not vice versa)!
*/
interface Singular extends
interface Singular<TOut = SingularElementReturnValue, TIn = SingularElementArgument>
extends Collection<TOut, TIn>,
SingularGraphManipulation,
SingularData, SingularPosition,
SingularSelection, SingularStyle, SingularAnimation { }
@@ -1154,7 +1156,7 @@ declare namespace cytoscape {
*
* The output is a collection of edge elements OR single edge.
*/
interface EdgeCollection extends Collection<EdgeSingular, EdgeSingular>, EdgeSingular,
interface EdgeCollection extends EdgeSingular,
EdgeCollectionTraversing { }
/**
* nodes -> Cy.NodeCollection
@@ -1162,7 +1164,7 @@ declare namespace cytoscape {
*
* The output is a collection of node elements OR single node.
*/
interface NodeCollection extends Collection<NodeSingular, NodeSingular>, NodeSingular,
interface NodeCollection extends NodeSingular,
NodeCollectionMetadata, NodeCollectionPosition, NodeCollectionTraversing,
NodeCollectionCompound { }
@@ -1172,14 +1174,14 @@ declare namespace cytoscape {
* edge --> Cy.EdgeSingular
* a collection of a single edge
*/
interface EdgeSingular extends Singular,
interface EdgeSingular extends Singular<EdgeSingular, EdgeSingular>,
EdgeSingularData, EdgeSingularPoints, EdgeSingularTraversing { }
/**
* node --> Cy.NodeSingular
* a collection of a single node
*/
interface NodeSingular extends Singular,
interface NodeSingular extends Singular<NodeSingular, NodeSingular>,
NodeSingularMetadata, NodeSingularPosition, NodeSingularCompound { }
/**
@@ -1251,6 +1253,15 @@ declare namespace cytoscape {
on(events: EventNames, selector: string, data: any, handler: EventHandler): void;
on(events: EventNames, selector: string, handler: EventHandler): void;
on(events: EventNames, handler: EventHandler): void;
bind(events: EventNames, selector: string, data: any, handler: EventHandler): void;
bind(events: EventNames, selector: string, handler: EventHandler): void;
bind(events: EventNames, handler: EventHandler): void;
listen(events: EventNames, selector: string, data: any, handler: EventHandler): void;
listen(events: EventNames, selector: string, handler: EventHandler): void;
listen(events: EventNames, handler: EventHandler): void;
addListener(events: EventNames, selector: string, data: any, handler: EventHandler): void;
addListener(events: EventNames, selector: string, handler: EventHandler): void;
addListener(events: EventNames, handler: EventHandler): void;
/**
* http://js.cytoscape.org/#eles.promiseOn
* alias: pon
@@ -1280,11 +1291,15 @@ declare namespace cytoscape {
* alias unbind, unlisten, removeListener
*/
off(events: EventNames, selector?: string, handler?: EventHandler): void;
unbind(events: EventNames, selector?: string, handler?: EventHandler): void;
unlisten(events: EventNames, selector?: string, handler?: EventHandler): void;
removeListener(events: EventNames, selector?: string, handler?: EventHandler): void;
/**
* http://js.cytoscape.org/#eles.trigger
* alias: emit
*/
trigger(events: EventNames, extra?: string[]): void;
emit(events: EventNames, extra?: string[]): void;
}
/**
@@ -2747,28 +2762,28 @@ declare namespace cytoscape {
*
* @param selector [optional] An optional selector that is used to filter the resultant collection.
*/
outgoers(selector?: Selector): EdgeCollection;
outgoers(selector?: Selector): CollectionReturnValue;
/**
* Recursively get edges (and their targets) coming out of the nodes in the collection (i.e. the outgoers, the outgoers' outgoers, ...).
*
* @param selector [optional] An optional selector that is used to filter the resultant collection.
*/
successors(selector?: Selector): EdgeCollection;
successors(selector?: Selector): CollectionReturnValue;
/**
* Get edges (and their sources) coming into the nodes in the collection.
*
* @param selector [optional] An optional selector that is used to filter the resultant collection.
*/
incomers(selector?: Selector): EdgeCollection;
incomers(selector?: Selector): CollectionReturnValue;
/**
* Recursively get edges (and their sources) coming into the nodes in the collection (i.e. the incomers, the incomers' incomers, ...).
*
* @param selector [optional] An optional selector that is used to filter the resultant collection.
*/
predecessors(selector?: Selector): EdgeCollection;
predecessors(selector?: Selector): CollectionReturnValue;
}
/**
@@ -0,0 +1,13 @@
$(document).ready(() => {
const config: DataTables.Settings = {
// Scroller extension options
scroller: {
trace: true,
rowHeight: 30,
serverWait: 1000,
displayBuffer: 10,
boundaryScale: 0.6,
loadingIndicator: true
}
};
});
+106
View File
@@ -0,0 +1,106 @@
// Type definitions for datatables.net-scroller 1.4
// Project: https://datatables.net
// Definitions by: Konstantin Rohde <https://github.com/RohdeK>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.4
/// <reference types="jquery" />
/// <reference types="datatables.net"/>
declare namespace DataTables {
interface Settings {
/*
* Select extension options
*/
scroller?: boolean | ScrollerSettings;
}
interface ScrollerSettings {
/*
* Indicate if Scroller show show trace information on the console or not.
*/
trace?: boolean;
/*
* Scroller will attempt to automatically calculate the height of rows for it's internal
* calculations. However the height that is used can be overridden using this parameter.
*/
rowHeight?: number | string;
/*
* When using server-side processing, Scroller will wait a small amount of time to allow
* the scrolling to finish before requesting more data from the server.
*/
serverWait?: number;
/*
* The display buffer is what Scroller uses to calculate how many rows it should pre-fetch
* for scrolling.
*/
displayBuffer?: number;
/*
* Scroller uses the boundary scaling factor to decide when to redraw the table - which it
* typically does before you reach the end of the currently loaded data set (in order to
* allow the data to look continuous to a user scrolling through the data).
*/
boundaryScale?: number;
/*
* Show (or not) the loading element in the background of the table. Note that you should
* include the dataTables.scroller.css file for this to be displayed correctly.
*/
loadingIndicator?: boolean;
}
interface Api {
scroller: ScrollerMethodsModel;
}
interface ScrollerMethodsModel {
/*
* Calculate and store information about how many rows are to be displayed
* in the scrolling viewport, based on current dimensions in the browser's
* rendering.
*/
measure(redraw?: boolean): Api;
/*
* Get information about current displayed record range.
*/
page(): PageInfo;
/*
* Get Scroller Api
*/
scroller(): ScrollerMethods;
}
interface ScrollerMethods extends Api {
/*
* Calculate the pixel position from the top of the scrolling container for
* a given row
*/
rowToPixels(rowIdx: number, intParse?: boolean, virtual?: boolean): number;
/*
* Calculate the row number that will be found at the given pixel position
* (y-scroll).
*/
pixelsToRow(pixels: number, intParse?: boolean, virtual?: boolean): number;
scrollToRow(rowIdx: number, animate?: boolean): Api;
}
/*
* start: {int}, // the 0-indexed record at the top of the viewport
* end: {int}, // the 0-indexed record at the bottom of the viewport
*/
interface PageInfo {
start: number;
end: number;
}
interface RowMethods {
/**
* Scroll to a row
*/
scrollTo(animate?: boolean): Api;
}
}
@@ -0,0 +1,24 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6",
"dom"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"datatables.net-scroller-tests.ts"
]
}
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }
@@ -0,0 +1,4 @@
import { CallData, BlockParamLiteral } from 'ethereum-protocol';
BlockParamLiteral.Earliest;
BlockParamLiteral.Latest;
BlockParamLiteral.Pending;
+293
View File
@@ -0,0 +1,293 @@
// Type definitions for ethereum-protocol 1.0
// Project: https://www.npmjs.com/package/ethereum-protocol
// Definitions by: Leonid Logvinov <https://github.com/LogvinovLeon>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.4
import BigNumber from 'bignumber.js';
export type JSONRPCErrorCallback = (err: Error | null, result?: JSONRPCResponsePayload) => void;
/**
* Do not create your own provider. Use an existing provider from a Web3 or ProviderEngine library
* Read more about Providers in the 0x wiki.
*/
export interface Provider {
sendAsync(payload: JSONRPCRequestPayload, callback: JSONRPCErrorCallback): void;
}
export type ContractAbi = AbiDefinition[];
export type AbiDefinition = FunctionAbi | EventAbi;
export type FunctionAbi = MethodAbi | ConstructorAbi | FallbackAbi;
export type ConstructorStateMutability = 'nonpayable' | 'payable';
export type StateMutability = 'pure' | 'view' | ConstructorStateMutability;
export enum AbiType {
Function = 'function',
Constructor = 'constructor',
Event = 'event',
Fallback = 'fallback',
}
export interface MethodAbi {
type: AbiType.Function;
name: string;
inputs: DataItem[];
outputs: DataItem[];
constant: boolean;
stateMutability: StateMutability;
payable: boolean;
}
export interface ConstructorAbi {
type: AbiType.Constructor;
inputs: DataItem[];
payable: boolean;
stateMutability: ConstructorStateMutability;
}
export interface FallbackAbi {
type: AbiType.Fallback;
payable: boolean;
}
export interface EventParameter extends DataItem {
indexed: boolean;
}
export interface EventAbi {
type: AbiType.Event;
name: string;
inputs: EventParameter[];
anonymous: boolean;
}
export interface DataItem {
name: string;
type: string;
components?: DataItem[];
}
export enum OpCode {
DelegateCall = 'DELEGATECALL',
Revert = 'REVERT',
Create = 'CREATE',
Stop = 'STOP',
Invalid = 'INVALID',
CallCode = 'CALLCODE',
StaticCall = 'STATICCALL',
Return = 'RETURN',
Call = 'CALL',
SelfDestruct = 'SELFDESTRUCT',
}
export interface StructLog {
depth: number;
error: string;
gas: number;
gasCost: number;
memory: string[];
op: OpCode;
pc: number;
stack: string[];
storage: { [location: string]: string };
}
export interface TransactionTrace {
gas: number;
returnValue: any;
structLogs: StructLog[];
}
export type Unit =
| 'kwei'
| 'ada'
| 'mwei'
| 'babbage'
| 'gwei'
| 'shannon'
| 'szabo'
| 'finney'
| 'ether'
| 'kether'
| 'grand'
| 'einstein'
| 'mether'
| 'gether'
| 'tether';
export interface JSONRPCRequestPayload {
params: any[];
method: string;
id: number;
jsonrpc: string;
}
export interface JSONRPCResponsePayload {
result: any;
id: number;
jsonrpc: string;
}
export interface AbstractBlock {
number: number | null;
hash: string | null;
parentHash: string;
nonce: string | null;
sha3Uncles: string;
logsBloom: string | null;
transactionsRoot: string;
stateRoot: string;
miner: string;
difficulty: BigNumber;
totalDifficulty: BigNumber;
extraData: string;
size: number;
gasLimit: number;
gasUsed: number;
timestamp: number;
uncles: string[];
}
export interface BlockWithoutTransactionData extends AbstractBlock {
transactions: string[];
}
export interface BlockWithTransactionData extends AbstractBlock {
transactions: Transaction[];
}
export interface Transaction {
hash: string;
nonce: number;
blockHash: string | null;
blockNumber: number | null;
transactionIndex: number | null;
from: string;
to: string | null;
value: BigNumber;
gasPrice: BigNumber;
gas: number;
input: string;
}
export interface CallTxDataBase {
to?: string;
value?: number | string | BigNumber;
gas?: number | string | BigNumber;
gasPrice?: number | string | BigNumber;
data?: string;
nonce?: number;
}
export interface TxData extends CallTxDataBase {
from: string;
}
export interface CallData extends CallTxDataBase {
from?: string;
}
export interface FilterObject {
fromBlock?: number | string;
toBlock?: number | string;
address?: string;
topics?: LogTopic[];
}
export type LogTopic = null | string | string[];
export interface DecodedLogEntry<A> extends LogEntry {
event: string;
args: A;
}
export interface DecodedLogEntryEvent<A> extends DecodedLogEntry<A> {
removed: boolean;
}
export interface LogEntryEvent extends LogEntry {
removed: boolean;
}
export interface LogEntry {
logIndex: number | null;
transactionIndex: number | null;
transactionHash: string;
blockHash: string | null;
blockNumber: number | null;
address: string;
data: string;
topics: string[];
}
export interface TxDataPayable extends TxData {
value?: BigNumber;
}
export interface TransactionReceipt {
blockHash: string;
blockNumber: number;
transactionHash: string;
transactionIndex: number;
from: string;
to: string;
status: null | string | 0 | 1;
cumulativeGasUsed: number;
gasUsed: number;
contractAddress: string | null;
logs: LogEntry[];
}
export type ContractEventArg = string | BigNumber | number | boolean;
export interface DecodedLogArgs {
[argName: string]: ContractEventArg;
}
export interface LogWithDecodedArgs<ArgsType extends DecodedLogArgs> extends DecodedLogEntry<ArgsType> {}
export type RawLog = LogEntry;
export enum BlockParamLiteral {
Earliest = 'earliest',
Latest = 'latest',
Pending = 'pending',
}
export type BlockParam = BlockParamLiteral | number;
export interface RawLogEntry {
logIndex: string | null;
transactionIndex: string | null;
transactionHash: string;
blockHash: string | null;
blockNumber: string | null;
address: string;
data: string;
topics: string[];
}
export enum SolidityTypes {
Address = 'address',
Uint256 = 'uint256',
Uint8 = 'uint8',
Uint = 'uint',
}
/**
* Contains the logs returned by a TransactionReceipt. We attempt to decode the
* logs using AbiDecoder. If we have the logs corresponding ABI, we decode it,
* otherwise we don't.
*/
export interface TransactionReceiptWithDecodedLogs extends TransactionReceipt {
logs: Array<LogWithDecodedArgs<DecodedLogArgs> | LogEntry>;
}
export interface TraceParams {
disableMemory?: boolean;
disableStack?: boolean;
disableStorage?: boolean;
}
+4
View File
@@ -0,0 +1,4 @@
{
"private": true,
"dependencies": { "bignumber.js": "7.2.1" }
}
+16
View File
@@ -0,0 +1,16 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": ["es6"],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": ["../"],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": ["index.d.ts", "ethereum-protocol-tests.ts"]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }
@@ -0,0 +1,11 @@
import StatusBarHeight from '@expo/status-bar-height';
const onChangeHeight = (height: number) => console.log(`New height: ${height}`);
StatusBarHeight.addEventListener(onChangeHeight);
StatusBarHeight.getAsync()
.then((height: number) => console.log(`Current height: ${height}`))
.catch((error: Error) => console.error('Threw an error in StatusBarHeight.getAsync():', error));
StatusBarHeight.removeEventListener(onChangeHeight);
+24
View File
@@ -0,0 +1,24 @@
// Type definitions for @expo/status-bar-height 0.0
// Project: https://github.com/expo/status-bar-height
// Definitions by: Janeene Beeforth <https://github.com/dawnmist>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
export type StatusBarHeightHandler = (height: number) => void;
export class StatusBarHeight {
/**
* Get the current status bar height
*/
getAsync(): Promise<number>;
/**
* Add 'willChange' event listener
*/
addEventListener(handler: StatusBarHeightHandler): void;
/**
* Remove 'willChange' event listener
*/
removeEventListener(handler: StatusBarHeightHandler): void;
}
declare const StatusBarHeightStatic: StatusBarHeight;
export default StatusBarHeightStatic;
@@ -0,0 +1,29 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"dom",
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"paths": {
"@expo/status-bar-height": [
"expo__status-bar-height"
]
},
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"expo__status-bar-height-tests.ts"
]
}
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }
@@ -0,0 +1,105 @@
import express = require('express');
import redis = require('redis');
import expressRedisCache = require('express-redis-cache');
const app = express();
const cache = expressRedisCache();
expressRedisCache({ host: 'localhsot', port: 6379, auth_pass: 'passw0rd' });
expressRedisCache({ client: redis.createClient() });
cache.on('error', (error) => {
throw new Error('Cache error!');
});
app.get('/',
cache.route(), // cache entry name is `cache.prefix + "/"`
(req, res, next) => { });
app.get('/',
cache.route('home'), // cache entry name is now `cache.prefix + "home"`
(req, res, next) => { });
app.get('/',
cache.route({ name: 'home' }), // cache entry name is `cache.prefix + "home"`
(req, res, next) => { });
app.get('/user/:userid',
// middleware to define cache name
(req, res, next) => {
// set cache name
res.express_redis_cache_name = 'user-' + req.params.userid;
next();
},
// cache middleware
cache.route(),
// content middleware
(req, res) => {
res.render('user');
}
);
app.get('/user',
// middleware to decide if using cache
(req, res, next) => {
// Use only cache if user not signed in
res.use_express_redis_cache = !req.signedCookies.user;
next();
},
cache.route(), // this will be skipped if user is signed in
(req, res) => {
res.render('user');
}
);
// Prefix
expressRedisCache({ prefix: 'test' });
// Expiration
expressRedisCache({ expire: 60 });
app.get('/index.html',
cache.route({ expire: 5000 }), // cache entry will live 5000 seconds
(req, res) => { }
);
// You can also use the number sugar syntax
cache.route(5000);
// Or
cache.route('index', 5000);
app.get('/index.html',
cache.route({
expire: {
200: 5000,
'4xx': 10,
403: 5000,
'5xx': 10,
xxx: 1
}
}),
(req, res) => { }
);
cache.get((error, entries) => {
if (error) throw error;
entries.forEach(console.log);
});
cache.get('home', (error, entries) => {});
cache.add(
'user:info',
JSON.stringify({ id: 1, email: 'john@doe.com' }),
{ expire: 60 * 60 * 24, type: 'json' },
(error, added) => {}
);
cache.add(
'user:info',
JSON.stringify({ id: 1, email: 'john@doe.com' }),
(error, added) => {}
);
cache.del('home', (error, deleted) => {});
cache.size((error, bytes) => {});
+77
View File
@@ -0,0 +1,77 @@
// Type definitions for express-redis-cache 1.1
// Project: https://github.com/rv-kip/express-redis-cache
// Definitions by: AJ Livingston <https://github.com/ajliv>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.3
import events = require('events');
import express = require('express');
import redis = require('redis');
declare module 'express-serve-static-core' {
interface Response {
express_redis_cache_name?: string;
use_express_redis_cache?: boolean;
}
}
declare function expressRedisCache(options?: expressRedisCache.Options): expressRedisCache.ExpressRedisCache;
declare namespace expressRedisCache {
class ExpressRedisCache extends events.EventEmitter {
constructor(options?: Options);
static init(options?: Options): ExpressRedisCache;
readonly FOREVER: number;
options: Options;
host: string;
port: string | number;
prefix: string;
auth_pass: string;
connected: boolean;
expire: number;
client: redis.RedisClient;
add(name: string, body: string, options: AddOptions, callback: (error: any, added: Entry) => void): void;
add(name: string, body: string, callback: (error: any, added: Entry) => void): void;
del(name: string, callback: (error: any, deleted: number) => void): void;
get(name: string, callback: (error: any, entries: Entry[]) => void): void;
get(callback: (error: any, entries: Entry[]) => void): void;
route(nameOrOptions: string | RouteOptions, expire?: ExpireOption): express.RequestHandler;
route(expire?: number): express.RequestHandler;
size(callback: (error: any, bytes: number) => void): void;
}
interface AddOptions {
type?: string;
expire?: number;
}
interface Entry {
body: string;
touched: number;
expire: number;
type: string;
}
interface ExpirationConfig {
[statusCode: string]: number;
}
type ExpireOption = number | ExpirationConfig;
type ExpirationPolicy = (req: express.Request, res: express.Response) => number;
interface Options {
auth_pass?: string;
client?: redis.RedisClient;
expire?: number;
host?: string;
port?: string | number;
prefix?: string;
}
interface RouteOptions {
name?: string;
expire?: ExpireOption | ExpirationPolicy;
binary?: boolean;
}
}
export = expressRedisCache;
+23
View File
@@ -0,0 +1,23 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictFunctionTypes": true,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"express-redis-cache-tests.ts"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }
+1
View File
@@ -0,0 +1 @@
declare/_test_env.d.ts
+1131
View File
File diff suppressed because it is too large Load Diff
+144
View File
@@ -0,0 +1,144 @@
/***************************************************************************
* *
* This file was automatically generated with idlc.js *
* build info: *
* - fibjs : 0.25.0 *
* - date : Jun 11 2018 14:17:22 *
* *
***************************************************************************/
/**
* @author Richard <richardo2016@gmail.com>
*
*/
/// <reference path="object.d.ts" />
/** module Or Internal Object */
/**
* @brief 缓存读取对象
* @detail BufferedReader 对象用于对二进制流对象数据进行缓存,并提供文本读取能力,仅支持 utf-8 格式转换。创建方法:,```JavaScript,var reader = new io.BufferedStream(stream);,```
*/
/// <reference path="Stream.d.ts" />
declare class Class_BufferedStream extends Class_Stream {
/**
* class prop
*
*
* @brief 查询创建缓存对象时的流对象
*
* @readonly
* @type Stream
*/
stream: Class_Stream
/**
* class prop
*
*
* @brief 查询和设置当前对象处理文本时的字符集,缺省为 utf-8
*
*
* @type String
*/
charset: string
/**
* class prop
*
*
* @brief 查询和设置行结尾标识,缺省时,posix:\"\\n\";windows:\"\\r\\n\"
*
*
* @type String
*/
EOL: string
/**
*
* @brief BufferedStream 构造函数
* @param stm BufferedStream 的二进制基础流对象
*
*
*
*/
constructor(stm: Class_Stream);
/**
*
* @brief 读取指定字符的文本
* @param size 指定读取的文本字符个数,以 utf8 或者指定的编码字节数为准
* @return 返回读取的文本字符串,若无数据可读,或者连接中断,则返回 null
*
*
* @async
*/
readText(size: number): string;
/**
*
* @brief 读取一行文本,行结尾标识基于 EOL 属性的设置,缺省时,posix:\"\\n\";windows:\"\\r\\n\"
* @param maxlen 指定此次读取的最大字符串,以 utf8 编码字节数为准,缺省不限制字符数
* @return 返回读取的文本字符串,若无数据可读,或者连接中断,则返回 null
*
*
* @async
*/
readLine(maxlen?: number/** = -1*/): string;
/**
*
* @brief 以数组方式读取一组文本行,行结尾标识基于 EOL 属性的设置,缺省时,posix:\"\\n\";windows:\"\\r\\n\"
* @param maxlines 指定此次读取的最大行数,缺省读取全部文本行
* @return 返回读取的文本行数组,若无数据可读,或者连接中断,空数组
*
*
*
*/
readLines(maxlines?: number/** = -1*/): any[];
/**
*
* @brief 读取一个文本字符串,以指定的字节为结尾
* @param mk 指定结尾的字符串
* @param maxlen 指定此次读取的最大字符串,以 utf8 编码字节数为准,缺省不限制字符数
* @return 返回读取的文本字符串,若无数据可读,或者连接中断,则返回 null
*
*
* @async
*/
readUntil(mk: string, maxlen?: number/** = -1*/): string;
/**
*
* @brief 写入一个字符串
* @param txt 指定写入的字符串
*
*
* @async
*/
writeText(txt: string): void;
/**
*
* @brief 写入一个字符串,并写入换行符
* @param txt 指定写入的字符串
*
*
* @async
*/
writeLine(txt: string): void;
} /** endof class */
/** } /** endof `module Or Internal Object` */
+63
View File
@@ -0,0 +1,63 @@
/***************************************************************************
* *
* This file was automatically generated with idlc.js *
* build info: *
* - fibjs : 0.25.0 *
* - date : Jun 11 2018 14:17:22 *
* *
***************************************************************************/
/**
* @author Richard <richardo2016@gmail.com>
*
*/
/// <reference path="object.d.ts" />
/** module Or Internal Object */
/**
* @brief 消息处理器链处理对象
* @detail 消息处理器链处理对象用于链接一系列消息处理器,按照指定的顺序链式处理。创建方法:,```JavaScript,var chain = new mq.Chain([, func1, func2,]);,```
*/
/// <reference path="Handler.d.ts" />
declare class Class_Chain extends Class_Handler {
/**
*
* @brief 构造一个消息处理器链处理对象
* @param hdlrs 处理器数组
*
*
*
*/
constructor(hdlrs: any[]);
/**
*
* @brief 添加处理器数组
* @param hdlrs 处理器数组
*
*
*
*/
append(hdlrs: any[]): void;
/**
*
* @brief 添加处理器
* @param hdlr 内置消息处理器,处理函数,链式处理数组,路由对象,详见 mq.Handler
*
*
*
*/
append(hdlr: Class_Handler): void;
} /** endof class */
/** } /** endof `module Or Internal Object` */
+149
View File
@@ -0,0 +1,149 @@
/***************************************************************************
* *
* This file was automatically generated with idlc.js *
* build info: *
* - fibjs : 0.25.0 *
* - date : Jun 11 2018 14:17:22 *
* *
***************************************************************************/
/**
* @author Richard <richardo2016@gmail.com>
*
*/
/// <reference path="object.d.ts" />
/** module Or Internal Object */
/**
* @brief 对称加密算法对象
* @detail Cipher 对象属于 crypto 模块,创建:,```JavaScript,var c = new crypto.Cipher(crypto.AES, crypto.ECB, ...);,```
*/
declare class Class_Cipher extends Class__object {
/**
* class prop
*
*
* @brief 返回当前算法名称
*
* @readonly
* @type String
*/
name: string
/**
* class prop
*
*
* @brief 返回当前算法密码长度,以位为单位
*
* @readonly
* @type Integer
*/
keySize: number
/**
* class prop
*
*
* @brief 返回当前算法初始向量长度,以字节为单位
*
* @readonly
* @type Integer
*/
ivSize: number
/**
* class prop
*
*
* @brief 返回当前算法数据块长度,以字节为单位
*
* @readonly
* @type Integer
*/
blockSize: number
/**
*
* @brief Cipher 构造函数,仅用于 ARC4 初始化
* @param provider 指定加密算法
* @param key 指定加密解密密码
*
*
*
*/
constructor(provider: number, key: Class_Buffer);
/**
*
* @brief Cipher 构造函数
* @param provider 指定加密算法
* @param mode 指定分组密码工作模式
* @param key 指定加密解密密码
*
*
*
*/
constructor(provider: number, mode: number, key: Class_Buffer);
/**
*
* @brief Cipher 构造函数
* @param provider 指定加密算法
* @param mode 指定分组密码工作模式
* @param key 指定加密解密密码
* @param iv 指定初始向量
*
*
*
*/
constructor(provider: number, mode: number, key: Class_Buffer, iv: Class_Buffer);
/**
*
* @brief 使用填充模式
* @param mode 指定填充模式,缺省为 PADDING_PKCS7
*
*
*
*/
paddingMode(mode: number): void;
/**
*
* @brief 使用当前算法密码加密数据
* @param data 指定要加密的数据
* @return 返回加密后的数据
*
*
* @async
*/
encrypt(data: Class_Buffer): Class_Buffer;
/**
*
* @brief 使用当前算法密码解密数据
* @param data 指定要解密的数据
* @return 返回解密后的数据
*
*
* @async
*/
decrypt(data: Class_Buffer): Class_Buffer;
} /** endof class */
/** } /** endof `module Or Internal Object` */
+75
View File
@@ -0,0 +1,75 @@
/***************************************************************************
* *
* This file was automatically generated with idlc.js *
* build info: *
* - fibjs : 0.25.0 *
* - date : Jun 11 2018 14:17:22 *
* *
***************************************************************************/
/**
* @author Richard <richardo2016@gmail.com>
*
*/
/// <reference path="object.d.ts" />
/** module Or Internal Object */
/**
* @brief 条件变量对象
* @detail 条件变量是利用纤程间共享的全局变量来进行同步的一种机制,主要包括两个动作:,1)一个线程等待某个条件成立,而将自己挂起;,2)另一个线程使条件成立,并通知等待的纤程向下执行。,,为了防止竞争,每个条件变量都需要一个Lock的配合(Lock可自行显式创建并传递进来,也可交由fibjs为您创建),,通过使用条件变量,可以利用一个条件变量控制一批纤程的开关;,,以下是两个纤程调度的实例:,```JavaScript,var coroutine = require("coroutine");,var cond = new coroutine.Condition();,var ready = false;,var state = "ready";,,function funcwait() {, cond.acquire();, while (!ready), cond.wait();, state = "go", cond.release();,},,coroutine.start(funcwait);,,cond.acquire();,console.log(state),ready = true;,cond.notify();,coroutine.sleep();,console.log(state);,```,will output:,```sh,ready,go,```
*/
/// <reference path="Lock.d.ts" />
declare class Class_Condition extends Class_Lock {
/**
*
* @brief 条件变量构造函数(条件变量所需的锁由fibjs内部构造)
*
*
*/
constructor();
/**
*
* @brief 条件变量构造函数
* @param lock 使用自行构造的锁
*
*
*
*/
constructor(lock: Class_Lock);
/**
*
* @brief 使纤程进入阻塞状态
*
*
*/
wait(): void;
/**
*
* @brief 通知一个被阻塞的纤程(最后加入纤程池的)向下继续执行
*
*
*/
notify(): void;
/**
*
* @brief 通知所有被阻塞的纤程向下继续执行
*
*
*/
notifyAll(): void;
} /** endof class */
/** } /** endof `module Or Internal Object` */
+119
View File
@@ -0,0 +1,119 @@
/***************************************************************************
* *
* This file was automatically generated with idlc.js *
* build info: *
* - fibjs : 0.25.0 *
* - date : Jun 11 2018 14:17:22 *
* *
***************************************************************************/
/**
* @author Richard <richardo2016@gmail.com>
*
*/
/// <reference path="object.d.ts" />
/** module Or Internal Object */
/**
* @brief 数据库连接对象,用于建立和维护一个数据库连接会话。
* @detail
*/
declare class Class_DbConnection extends Class__object {
/**
* class prop
*
*
* @brief 查询当前连接数据库类型
*
* @readonly
* @type String
*/
type: string
/**
*
* @brief 关闭当前数据库连接
*
* @async
*/
close(): void;
/**
*
* @brief 在当前数据库连接上启动一个事务
*
* @async
*/
begin(): void;
/**
*
* @brief 提交当前数据库连接上的事务
*
* @async
*/
commit(): void;
/**
*
* @brief 回滚当前数据库连接上的事务
*
* @async
*/
rollback(): void;
/**
*
* @brief 进入事务执行一个函数,并根据函数执行情况提交或者回滚
* func 执行有三种结果:
* * 函数正常返回,包括运行结束和主动 return,此时事务将自动提交
* * 函数返回 false,此时事务将回滚
* * 函数运行错误,事务自动回滚
*
* @param func 以事务方式执行的函数
* @return 返回事务是否提交,正常 commit 时返回 true, rollback 时返回 false,如果事务出错则抛出错误
*
*
*
*/
trans(func: Function): boolean;
/**
*
* @brief 执行一个 sql 命令,并返回执行结果,可根据参数格式化字符串
*
* @param sql 格式化字符串,可选参数用 ? 指定。例如:'SELECT FROM TEST WHERE [id]=?'
* @param args 可选参数列表
* @return 返回包含结果记录的数组,如果请求是 UPDATE 或者 INSERT,返回结果还会包含 affected 和 insertId,mssql 不支持 insertId。
*
*
* @async
*/
execute(sql: string, ...args: any[]): any[];
/**
*
* @brief 格式化一个 sql 命令,并返回格式化结果
*
* @param sql 格式化字符串,可选参数用 ? 指定。例如:'SELECT FROM TEST WHERE [id]=?'
* @param args 可选参数列表
* @return 返回格式化之后的 sql 命令
*
*
*
*/
format(sql: string, ...args: any[]): string;
} /** endof class */
/** } /** endof `module Or Internal Object` */
+180
View File
@@ -0,0 +1,180 @@
/***************************************************************************
* *
* This file was automatically generated with idlc.js *
* build info: *
* - fibjs : 0.25.0 *
* - date : Jun 11 2018 14:17:22 *
* *
***************************************************************************/
/**
* @author Richard <richardo2016@gmail.com>
*
*/
/// <reference path="object.d.ts" />
/** module Or Internal Object */
/**
* @brief dgram.Socket 对象是一个封装了数据包函数功能的 EventEmitter。
* @detail DgramSocket 实例是由 dgram.createSocket() 创建的。创建 dgram.Socket 实例不需要使用 new 关键字。,,创建方法:,```JavaScript,var dgram = require('dgram');,var sock = dgram.createSocket('udp4');,```,,## 事件,DgramSocket 继承于 EventEmitter,对象的状态变化,以及数据接受,都是以事件的方式实现。,,### close 事件,** `close` 事件将在使用 `close()` 关闭一个 `socket` 之后触发。该事件一旦触发,这个 `socket` 上将不会触发新的 `message` 事件。**,,### error 事件,** 当有任何错误发生时,`error` 事件将被触发。 **,,### listening 事件,** 当一个 `socket` 开始监听数据包信息时,`listening` 事件将被触发。该事件会在创建 UDP socket 之后被立即触发。 **,,### message 事件,** 当有新的数据包被 `socket` 接收时,`message` 事件会被触发。`msg` 和 `rinfo` 会作为参数传递到该事件的处理函数中。 **,- msg: Buffer,消息,- rinfo: Object,远程地址信息, - address: string,发送方地址, - family: string,地址类型 ('IPv4' or 'IPv6'), - port: number,发送者端口, - size: number,消息大小
*/
/// <reference path="EventEmitter.d.ts" />
declare class Class_DgramSocket extends Class_EventEmitter {
/**
*
* @brief 该方法会令 dgram.Socket 在指定的 `port` 和 `addr` 上监听数据包信息。绑定完成时会触发一个 `listening` 事件。
* @param port 指定绑定端口,若 `port` 未指定或为 0,操作系统会尝试绑定一个随机的端口
* @param addr 指定绑定地址,若 address 未指定,操作系统会尝试在所有地址上监听。
*
*
* @async
*/
bind(port?: number/** = 0*/, addr?: string/** = ""*/): void;
/**
*
* @brief 该方法会令 dgram.Socket 在 `opts` 指定的 `port` 和 `address` 上监听数据包信息。绑定完成时会触发一个 `listening` 事件。
* @param opts 指定绑定参数
*
*
* @async
*/
bind(opts: Object): void;
/**
*
* @brief 在 socket 上发送一个数据包
* @param msg 指定发送的数据
* @param port 指定发送的目的端口
* @param address 指定发送的目的地址
* @return 返回发送尺寸
*
*
* @async
*/
send(msg: Class_Buffer, port: number, address?: string/** = ""*/): number;
/**
*
* @brief 在 socket 上发送一个数据包
* @param msg 指定发送的数据
* @param offset 从指定偏移开始发送
* @param length 之发送指定长度
* @param port 指定发送的目的端口
* @param address 指定发送的目的地址
* @return 返回发送尺寸
*
*
* @async
*/
send(msg: Class_Buffer, offset: number, length: number, port: number, address?: string/** = ""*/): number;
/**
*
* @brief 返回一个包含 socket 地址信息的对象。对于 UDP socket,该对象将包含 address、family 和 port 属性。
* @return 返回对象绑定地址
*
*
*
*/
address(): any;
/**
*
* @brief 关闭当前 socket
*
*
*/
close(): void;
/**
*
* @brief 关闭当前 socket
* @param callback 关闭完成后的回调函数,它相当于为 `close` 事件添加了一个监听器
*
*
*
*/
close(callback: Function): void;
/**
*
* @brief 查询 socket 接收缓冲区大小
* @return 返回查询结果
*
*
*
*/
getRecvBufferSize(): number;
/**
*
* @brief 查询 socket 发送缓冲区大小
* @return 返回查询结果
*
*
*
*/
getSendBufferSize(): number;
/**
*
* @brief 设置 socket 接收缓冲区大小
* @param size 指定要设置的尺寸
*
*
*
*/
setRecvBufferSize(size: number): void;
/**
*
* @brief 设置 socket 发送缓冲区大小
* @param size 指定要设置的尺寸
*
*
*
*/
setSendBufferSize(size: number): void;
/**
*
* @brief 设置或清除 SO_BROADCAST socket 选项
* @param flag 当设置为 true, UDP包会被发送到一个本地接口的广播地址
*
*
*
*/
setBroadcast(flag: boolean): void;
/**
*
* @brief 维持 fibjs 进程不退出,在对象绑定期间阻止 fibjs 进程退出
* @return 返回当前对象
*
*
*
*/
ref(): Class_DgramSocket;
/**
*
* @brief 允许 fibjs 进程退出,在对象绑定期间允许 fibjs 进程退出
* @return 返回当前对象
*
*
*
*/
unref(): Class_DgramSocket;
} /** endof class */
/** } /** endof `module Or Internal Object` */
+77
View File
@@ -0,0 +1,77 @@
/***************************************************************************
* *
* This file was automatically generated with idlc.js *
* build info: *
* - fibjs : 0.25.0 *
* - date : Jun 11 2018 14:17:22 *
* *
***************************************************************************/
/**
* @author Richard <richardo2016@gmail.com>
*
*/
/// <reference path="object.d.ts" />
/** module Or Internal Object */
/**
* @brief 信息摘要对象
* @detail
*/
declare class Class_Digest extends Class__object {
/**
* class prop
*
*
* @brief 查询当前信息摘要算法的摘要字节数
*
* @readonly
* @type Integer
*/
size: number
/**
*
* @brief 更新二进制摘要信息
* @param data 二进制数据块
* @return 返回信息摘要对象本身
*
*
*
*/
update(data: Class_Buffer): Class_Digest;
/**
*
* @brief 计算并返回摘要
* @param data 二进制数据块,此数据块将在计算前更新进摘要
* @return 返回摘要的二进制数据
*
*
*
*/
digest(data: Class_Buffer): Class_Buffer;
/**
*
* @brief 计算并返回摘要
* @return 返回摘要的二进制数据
*
*
*
*/
digest(): Class_Buffer;
} /** endof class */
/** } /** endof `module Or Internal Object` */
+85
View File
@@ -0,0 +1,85 @@
/***************************************************************************
* *
* This file was automatically generated with idlc.js *
* build info: *
* - fibjs : 0.25.0 *
* - date : Jun 11 2018 14:17:22 *
* *
***************************************************************************/
/**
* @author Richard <richardo2016@gmail.com>
*
*/
/// <reference path="object.d.ts" />
/** module Or Internal Object */
/**
* @brief 事件对象
* @detail 通过一个事件达到对一组纤程进行控制的目的(事件对象的状态为bool类型)
*/
/// <reference path="Lock.d.ts" />
declare class Class_Event extends Class_Lock {
/**
*
* @brief 事件对象构造函数
* @param value 指定是否等待,为 true 时等待,缺省为 false
*
*
*
*/
constructor(value?: boolean/** = false*/);
/**
*
* @brief 判断事件对象是否为真
* @return 如果事件为真,返回 true
*
*
*
*/
isSet(): boolean;
/**
*
* @brief 激活事件(将事件状态改为true),并调用pulse()
*
*
*/
set(): void;
/**
*
* @brief 激活等待该事件的所有纤程
*
*
*/
pulse(): void;
/**
*
* @brief 重置事件(将事件状态改为false)
*
*
*/
clear(): void;
/**
*
* @brief 等待一个事件
*
*
*/
wait(): void;
} /** endof class */
/** } /** endof `module Or Internal Object` */
+311
View File
@@ -0,0 +1,311 @@
/***************************************************************************
* *
* This file was automatically generated with idlc.js *
* build info: *
* - fibjs : 0.25.0 *
* - date : Jun 11 2018 14:17:22 *
* *
***************************************************************************/
/**
* @author Richard <richardo2016@gmail.com>
*
*/
/// <reference path="object.d.ts" />
/** module Or Internal Object */
/**
* @brief 事件触发对象,可用于建立观察者模式,支持事件触发的对象均继承于此,同一事件的同一函数只会产生一次回调
* @detail Event 对象可独立创建,以用于组建自定义的事件系统:,```JavaScript,var EventEmitter = require('events');,,var e = new EventEmitter();,```
*/
declare class Class_EventEmitter extends Class__object {
/**
* class prop
*
*
* @brief 默认全局最大监听器数
* @static
*
* @type Integer
*/
defaultMaxListeners: number
/**
*
* @brief 构造函数
*
*
*/
constructor();
/**
*
* @brief 绑定一个事件处理函数到对象
* @param ev 指定事件的名称
* @param func 指定事件处理函数
* @return 返回成功绑定的数量,如果函数已绑定则返回 0
*
*
*
*/
on(ev: string, func: Function): Object;
/**
*
* @brief 绑定一个事件处理函数到对象
* @param map 指定事件映射关系,对象属性名称将作为事件名称,属性的值将作为事件处理函数
* @return 返回事件对象本身,便于链式调用
*
*
*
*/
on(map: Object): Object;
/**
*
* @brief 绑定一个事件处理函数到对象
* @param ev 指定事件的名称
* @param func 指定事件处理函数
* @return 返回事件对象本身,便于链式调用
*
*
*
*/
addListener(ev: string, func: Function): Object;
/**
*
* @brief 绑定一个事件处理函数到对象
* @param map 指定事件映射关系,对象属性名称将作为事件名称,属性的值将作为事件处理函数
* @return 返回事件对象本身,便于链式调用
*
*
*
*/
addListener(map: Object): Object;
/**
*
* @brief 绑定一个事件处理函数到对象起始
* @param ev 指定事件的名称
* @param func 指定事件处理函数
* @return 返回成功绑定的数量,如果函数已绑定则返回 0
*
*
*
*/
prependListener(ev: string, func: Function): Object;
/**
*
* @brief 绑定一个事件处理函数到对象起始
* @param map 指定事件映射关系,对象属性名称将作为事件名称,属性的值将作为事件处理函数
* @return 返回成功绑定的数量,如果函数已绑定则返回 0
*
*
*
*/
prependListener(map: Object): Object;
/**
*
* @brief 绑定一个一次性事件处理函数到对象,一次性处理函数只会触发一次
* @param ev 指定事件的名称
* @param func 指定事件处理函数
* @return 返回事件对象本身,便于链式调用
*
*
*
*/
once(ev: string, func: Function): Object;
/**
*
* @brief 绑定一个一次性事件处理函数到对象,一次性处理函数只会触发一次
* @param map 指定事件映射关系,对象属性名称将作为事件名称,属性的值将作为事件处理函数
* @return 返回事件对象本身,便于链式调用
*
*
*
*/
once(map: Object): Object;
/**
*
* @brief 绑定一个事件处理函数到对象起始
* @param ev 指定事件的名称
* @param func 指定事件处理函数
* @return 返回成功绑定的数量,如果函数已绑定则返回 0
*
*
*
*/
prependOnceListener(ev: string, func: Function): Object;
/**
*
* @brief 绑定一个事件处理函数到对象起始
* @param map 指定事件映射关系,对象属性名称将作为事件名称,属性的值将作为事件处理函数
* @return 返回成功绑定的数量,如果函数已绑定则返回 0
*
*
*
*/
prependOnceListener(map: Object): Object;
/**
*
* @brief 从对象处理队列中取消指定函数
* @param ev 指定事件的名称
* @param func 指定事件处理函数
* @return 返回事件对象本身,便于链式调用
*
*
*
*/
off(ev: string, func: Function): Object;
/**
*
* @brief 取消对象处理队列中的全部函数
* @param ev 指定事件的名称
* @return 返回事件对象本身,便于链式调用
*
*
*
*/
off(ev: string): Object;
/**
*
* @brief 从对象处理队列中取消指定函数
* @param map 指定事件映射关系,对象属性名称作为事件名称,属性的值作为事件处理函数
* @return 返回事件对象本身,便于链式调用
*
*
*
*/
off(map: Object): Object;
/**
*
* @brief 从对象处理队列中取消指定函数
* @param ev 指定事件的名称
* @param func 指定事件处理函数
* @return 返回事件对象本身,便于链式调用
*
*
*
*/
removeListener(ev: string, func: Function): Object;
/**
*
* @brief 取消对象处理队列中的全部函数
* @param ev 指定事件的名称
* @return 返回事件对象本身,便于链式调用
*
*
*
*/
removeListener(ev: string): Object;
/**
*
* @brief 从对象处理队列中取消指定函数
* @param map 指定事件映射关系,对象属性名称作为事件名称,属性的值作为事件处理函数
* @return 返回事件对象本身,便于链式调用
*
*
*
*/
removeListener(map: Object): Object;
/**
*
* @brief 从对象处理队列中取消所有事件的所有监听器, 如果指定事件,则移除指定事件的所有监听器。
* @param evs 指定事件的名称
* @return 返回事件对象本身,便于链式调用
*
*
*
*/
removeAllListeners(evs?: any[]/** = v8::Array::New(isolate)*/): Object;
/**
*
* 监听器的默认限制的数量,仅用于兼容
* @param n 指定事件的数量
*
*
*
*/
setMaxListeners(n: number): void;
/**
*
* 获取监听器的默认限制的数量,仅用于兼容
* @return 返回默认限制数量
*
*
*
*/
getMaxListeners(): number;
/**
*
* @brief 查询对象指定事件的监听器数组
* @param ev 指定事件的名称
* @return 返回指定事件的监听器数组
*
*
*
*/
listeners(ev: string): any[];
/**
*
* @brief 查询对象指定事件的监听器数量
* @param ev 指定事件的名称
* @return 返回指定事件的监听器数量
*
*
*
*/
listenerCount(ev: string): number;
/**
*
* @brief 查询监听器事件名称
* @return 返回事件名称数组
*
*
*
*/
eventNames(): any[];
/**
*
* @brief 主动触发一个事件
* @param ev 事件名称
* @param args 事件参数,将会传递给事件处理函数
* @return 返回事件触发状态,有响应事件返回 true,否则返回 false
*
*
*
*/
emit(ev: string, ...args: any[]): boolean;
} /** endof class */
/** } /** endof `module Or Internal Object` */
+81
View File
@@ -0,0 +1,81 @@
/***************************************************************************
* *
* This file was automatically generated with idlc.js *
* build info: *
* - fibjs : 0.25.0 *
* - date : Jun 11 2018 14:17:22 *
* *
***************************************************************************/
/**
* @author Richard <richardo2016@gmail.com>
*
*/
/// <reference path="object.d.ts" />
/** module Or Internal Object */
/**
* @brief 事件信息对象,用于在事件中传递信息
* @detail
*/
declare class Class_EventInfo extends Class__object {
/**
* class prop
*
*
* 查询事件错误编码
*
* @readonly
* @type Integer
*/
code: number
/**
* class prop
*
*
* 查询事件错误信息
*
* @readonly
* @type String
*/
reason: string
/**
* class prop
*
*
* 查询事件类型
*
* @readonly
* @type String
*/
type: string
/**
* class prop
*
*
* 查询触发事件的对象
*
* @readonly
* @type Object
*/
target: Object
} /** endof class */
/** } /** endof `module Or Internal Object` */
+77
View File
@@ -0,0 +1,77 @@
/***************************************************************************
* *
* This file was automatically generated with idlc.js *
* build info: *
* - fibjs : 0.25.0 *
* - date : Jun 11 2018 14:17:22 *
* *
***************************************************************************/
/**
* @author Richard <richardo2016@gmail.com>
*
*/
/// <reference path="object.d.ts" />
/** module Or Internal Object */
/**
* @brief 纤程操作对象,此对象不可直接创建
* @detail 使用 coroutine.start 创建纤程后,将返回此对象,用于纤程处理和纤程间通信。,纤程主函数可以通过 this 访问本纤程对象,也可通过 coroutine.current 获取当前纤程。,```JavaScript,function func(v1),{, console.log(v1 + this.v);,},,var fb = coroutine.start(func,100);,,fb.v = 123;,,fb.join();,```,,纤程局部存储通过共享的 Fiber 对象完成,通过 coroutine.current 获取当前纤程,通过修改和查询其变量达到共享数据的目的。,,```JavaScript,function func(),{, console.log(coroutine.current().v);,},,coroutine.current().v = 100;,,func();,```,,纤程在创建时,会自动复制当前纤程的局部变量到新的纤程,之后,各自的局部变量的修改不会相互影响,除非变量本身为对象引用。,,```JavaScript,function func(),{, console.log(coroutine.current().v);,},,coroutine.current().v = 100;,,var fb = coroutine.start(func);,,coroutine.current().v = 200;,,fb.join();,```
*/
declare class Class_Fiber extends Class__object {
/**
* class prop
*
*
* @brief 查询纤程的唯一 id
*
* @readonly
* @type Long
*/
id: number
/**
* class prop
*
*
* @brief 查询纤程的调用纤程
*
* @readonly
* @type Fiber
*/
caller: Class_Fiber
/**
* class prop
*
*
* @brief 查询纤程的调用堆栈
*
* @readonly
* @type String
*/
stack: string
/**
*
* @brief 等待纤程结束
*
*
*/
join(): void;
} /** endof class */
/** } /** endof `module Or Internal Object` */
+67
View File
@@ -0,0 +1,67 @@
/***************************************************************************
* *
* This file was automatically generated with idlc.js *
* build info: *
* - fibjs : 0.25.0 *
* - date : Jun 11 2018 14:17:22 *
* *
***************************************************************************/
/**
* @author Richard <richardo2016@gmail.com>
*
*/
/// <reference path="object.d.ts" />
/** module Or Internal Object */
/**
* @brief 文件操作对象,用于二进制文件读写
* @detail 文件操作对象用于对二进制文件进行操作,可使用 fs 模块打开和创建文件:,```JavaScript,var f = fs.openFile('test.txt');,```
*/
/// <reference path="SeekableStream.d.ts" />
declare class Class_File extends Class_SeekableStream {
/**
* class prop
*
*
* @brief 查询当前文件名
*
* @readonly
* @type String
*/
name: string
/**
* class prop
*
*
* @brief 查询当前文件描述符
*
* @readonly
* @type Integer
*/
fd: number
/**
*
* @brief 查询当前文件的访问权限,Windows 不支持此方法
* @param mode 指定设定的访问权限
*
*
* @async
*/
chmod(mode: number): void;
} /** endof class */
/** } /** endof `module Or Internal Object` */
+74
View File
@@ -0,0 +1,74 @@
/***************************************************************************
* *
* This file was automatically generated with idlc.js *
* build info: *
* - fibjs : 0.25.0 *
* - date : Jun 11 2018 14:17:22 *
* *
***************************************************************************/
/**
* @author Richard <richardo2016@gmail.com>
*
*/
/// <reference path="object.d.ts" />
/** module Or Internal Object */
/**
* @brief 消息处理器接口
* @detail
*/
declare class Class_Handler extends Class__object {
/**
*
* @brief 构造一个消息处理器链处理对象
* @param hdlrs 处理器数组
*
*
*
*/
constructor(hdlrs: any[]);
/**
*
* @brief 创建一个消息处理器路由对象
* @param map 初始化路由参数
*
*
*
*/
constructor(map: Object);
/**
*
* @brief 创建一个 JavaSvript 消息处理器
* @param hdlr JavaScript 处理器函数
*
*
*
*/
constructor(hdlr: Function);
/**
*
* @brief 处理一个消息或对象
* @param v 指定处理的消息或对象
* @return 返回下一步的处理器
*
*
* @async
*/
invoke(v: Class__object): Class_Handler;
} /** endof class */
/** } /** endof `module Or Internal Object` */
+90
View File
@@ -0,0 +1,90 @@
/***************************************************************************
* *
* This file was automatically generated with idlc.js *
* build info: *
* - fibjs : 0.25.0 *
* - date : Jun 11 2018 14:17:22 *
* *
***************************************************************************/
/**
* @author Richard <richardo2016@gmail.com>
*
*/
/// <reference path="object.d.ts" />
/** module Or Internal Object */
/**
* @brief 扩展消息处理器接口
* @detail
*/
/// <reference path="Handler.d.ts" />
declare class Class_HandlerEx extends Class_Handler {
/**
* class prop
*
*
* @brief WebSocket 协议转换处理器当前事件处理接口对象
*
*
* @type Handler
*/
handler: Class_Handler
/**
* class prop
*
*
* @brief 查询 WebSocket 包协议转换处理器的工作状态
*
* 返回的结果为一个 Stats 对象,结构如下:
* ```JavaScript
* {
* total : 1000, // 总计处理的请求
* pendding : 100, // 当前正在处理的请求
* request : 10, // 新建的请求
* response : 10, // 发送的响应
* error : 100 // 发生的错误
* }
* ```
*
*
* @readonly
* @type Stats
*/
stats: Class_Stats
/**
*
* @brief 设置错误处理器
*
* 使用方式:
* ```JavaScript
* hdlr.onerror({
* "404": function(v)
* {
* ...
* },
* "500": new mq.Routing(...)
* })
* ```
* @param hdlrs 指定不同的错误的处理器,key 是错误号,value 是处理器,可以是内置消息处理器,处理函数,链式处理数组,路由对象,详见 mq.Handler
*
*
*
*/
onerror(hdlrs: Object): void;
} /** endof class */
/** } /** endof `module Or Internal Object` */
+97
View File
@@ -0,0 +1,97 @@
/***************************************************************************
* *
* This file was automatically generated with idlc.js *
* build info: *
* - fibjs : 0.25.0 *
* - date : Jun 11 2018 14:17:22 *
* *
***************************************************************************/
/**
* @author Richard <richardo2016@gmail.com>
*
*/
/// <reference path="object.d.ts" />
/** module Or Internal Object */
/**
* @brief HeapGraphEdge表示两个HeapGraphNode节点间的关联,从上游节点到下游节点
* @detail
*/
declare class Class_HeapGraphEdge extends Class__object {
/**
* class prop
*
*
* @brief 下游节点的链接方式,可能的值:
* - profiler.Edge_ContextVariable, 函数中的变量
* - profiler.Edge_Element, 数组中的元素
* - profiler.Edge_Property, 有名对象的属性
* - profiler.Edge_Internal, JS无法进入的链接
* - profiler.Edge_Hidden, 指向需要事先计算出空间大小的节点
* - profiler.Edge_Shortcut, 指向无法事先计算出空间大小的节点
* - profiler.Edge_Weak, 一个弱引用(被GC忽视)
*
*
* @readonly
* @type Integer
*/
type: number
/**
* class prop
*
*
* @brief 链接名称
*
* @readonly
* @type String
*/
name: string
/**
* class prop
*
*
* @brief 链接的描述
*
* @readonly
* @type String
*/
description: string
/**
*
* @brief 获取HeapGraphEdge的上游HeapGraphNode节点
* @return 返回源HeapGraphNode节点
*
*
*
*/
getFromNode(): Class_HeapGraphNode;
/**
*
* @brief 获取HeapGraphEdge的下游HeapGraphNode节点
* @return 返回目的HeapGraphNode节点
*
*
*
*/
getToNode(): Class_HeapGraphNode;
} /** endof class */
/** } /** endof `module Or Internal Object` */
+120
View File
@@ -0,0 +1,120 @@
/***************************************************************************
* *
* This file was automatically generated with idlc.js *
* build info: *
* - fibjs : 0.25.0 *
* - date : Jun 11 2018 14:17:22 *
* *
***************************************************************************/
/**
* @author Richard <richardo2016@gmail.com>
*
*/
/// <reference path="object.d.ts" />
/** module Or Internal Object */
/**
* @brief HeapGraphNode表示堆视图中的一个节点
* @detail
*/
declare class Class_HeapGraphNode extends Class__object {
/**
* class prop
*
*
* @brief 节点类型,可能的值:
* - profiler.Node_Hidden, 隐藏节点,当显示给用户时可以被过滤掉
* - profiler.Node_Array, 数组
* - profiler.Node_String, 字符串
* - profiler.Node_Object, JS对象(字符串和数组除外)
* - profiler.Node_Code, 编译后的代码
* - profiler.Node_Closure, 函数闭包
* - profiler.Node_RegExp, 正则表达式
* - profiler.Node_HeapNumber, 堆中排好序的数字
* - profiler.Node_Native, Native对象(非v8堆上的)
* - profiler.Node_Synthetic, Synthetic对象
* - profiler.Node_ConsString, 拼接的字符串
* - profiler.Node_SlicedString, 分割的字符串
* - profiler.Node_Symbol, 符号(ES6)
* - profiler.Node_SimdValue, 堆中排好序的SIMD值(ES7)
*
*
* @readonly
* @type Integer
*/
type: number
/**
* class prop
*
*
* @brief 节点名称
*
* @readonly
* @type String
*/
name: string
/**
* class prop
*
*
* @brief 节点的描述
*
* @readonly
* @type String
*/
description: string
/**
* class prop
*
*
* @brief 节点ID
*
* @readonly
* @type Integer
*/
id: number
/**
* class prop
*
*
* @brief 节点大小,单位为字节
*
* @readonly
* @type Integer
*/
shallowSize: number
/**
* class prop
*
*
* @brief 子节点列表,由HeapGraphEdge类型对象组成
*
* @readonly
* @type NArray
*/
childs: any[]
} /** endof class */
/** } /** endof `module Or Internal Object` */
+101
View File
@@ -0,0 +1,101 @@
/***************************************************************************
* *
* This file was automatically generated with idlc.js *
* build info: *
* - fibjs : 0.25.0 *
* - date : Jun 11 2018 14:17:22 *
* *
***************************************************************************/
/**
* @author Richard <richardo2016@gmail.com>
*
*/
/// <reference path="object.d.ts" />
/** module Or Internal Object */
/**
* @brief HeapSnapshots记录JS堆在某个时刻的状态
* @detail
*/
declare class Class_HeapSnapshot extends Class__object {
/**
* class prop
*
*
* @brief 时间信息
*
* @readonly
* @type Date
*/
time: Date
/**
* class prop
*
*
* @brief 堆视图的根节点
*
* @readonly
* @type HeapGraphNode
*/
root: Class_HeapGraphNode
/**
* class prop
*
*
* @brief 堆视图节点组成的列表
*
* @readonly
* @type NArray
*/
nodes: any[]
/**
*
* @brief 和指定的堆快照进行比较
* @param before 待比较的堆快照
* @return 返回堆快照的比较结果
*
*
*
*/
diff(before: Class_HeapSnapshot): Object;
/**
*
* @brief 根据ID获取堆视图节点
* @param id 数字类型的节点ID
* @return 返回获取到的堆视图节点
*
*
*
*/
getNodeById(id: number): Class_HeapGraphNode;
/**
*
* @brief 根据指定名称保存HeapSnapshot
* @param fname 快照名称
*
*
* @async
*/
save(fname: string): void;
} /** endof class */
/** } /** endof `module Or Internal Object` */
+258
View File
@@ -0,0 +1,258 @@
/***************************************************************************
* *
* This file was automatically generated with idlc.js *
* build info: *
* - fibjs : 0.25.0 *
* - date : Jun 11 2018 14:17:22 *
* *
***************************************************************************/
/**
* @author Richard <richardo2016@gmail.com>
*
*/
/// <reference path="object.d.ts" />
/** module Or Internal Object */
/**
* @brief http客户端对象
* @detail http客户端对象模拟浏览器环境缓存cookie,并在访问url的时候携带对应的cookie,不同的http客户端对象是相互隔离的,提供http的request、get、post等方法。,用法如下:,,```JavaScript,var http = require('http');,var httpClient = new http.Client();,httpClient.request('GET', 'http://fibjs.org');,```
*/
declare class Class_HttpClient extends Class__object {
/**
* class prop
*
*
* @brief 返回http客户端的 HttpCookie 对象列表
*
* @readonly
* @type NArray
*/
cookies: any[]
/**
* class prop
*
*
* @brief 查询和设置超时时间 单位毫秒
*
*
* @type Integer
*/
timeout: number
/**
* class prop
*
*
* @brief 查询和设置 body 最大尺寸,以 MB 为单位,缺省为 -1,不限制尺寸
*
*
* @type Integer
*/
maxBodySize: number
/**
* class prop
*
*
* @brief cookie功能开关,默认开启
*
*
* @type Boolean
*/
enableCookie: boolean
/**
* class prop
*
*
* @brief 自动redirect功能开关,默认开启
*
*
* @type Boolean
*/
autoRedirect: boolean
/**
* class prop
*
*
* @brief 查询和设置 http 请求中的浏览器标识
*
*
* @type String
*/
userAgent: string
/**
*
* @brief HttpClient 构造函数,创建一个新的HttpClient对象
*
*
*/
constructor();
/**
*
* @brief 发送 http 请求到指定的流对象,并返回结果
* @param conn 指定处理请求的流对象
* @param req 要发送的 HttpRequest 对象
* @return 返回服务器响应
*
*
* @async
*/
request(conn: Class_Stream, req: Class_HttpRequest): Class_HttpResponse;
/**
*
* @brief 请求指定的 url,并返回结果
* opts 包含请求的附加选项,支持的内容如下:
* ```JavaScript
* {
* "query": {},
* "body": SeekedStream | Buffer | String | {},
* "json": {},
* "headers": {}
* }
* ```
* 其中 body,json 不得同时出现。缺省为 {},不包含任何附加信息
* @param method 指定 http 请求方法:GET, POST 等
* @param url 指定 url,必须是包含主机的完整 url
* @param opts 指定附加信息
* @return 返回服务器响应
*
*
* @async
*/
request(method: string, url: string, opts?: Object/** = v8::Object::New(isolate)*/): Class_HttpResponse;
/**
*
* @brief 用 GET 方法请求指定的 url,并返回结果,等同于 request("GET", ...)
* opts 包含请求的附加选项,支持的内容如下:
* ```JavaScript
* {
* "query": {},
* "body": SeekedStream | Buffer | String | {},
* "json": {},
* "headers": {}
* }
* ```
* 其中 body,json 不得同时出现。缺省为 {},不包含任何附加信息
* @param url 指定 url,必须是包含主机的完整 url
* @param opts 指定附加信息
* @return 返回服务器响应
*
*
* @async
*/
get(url: string, opts?: Object/** = v8::Object::New(isolate)*/): Class_HttpResponse;
/**
*
* @brief 用 POST 方法请求指定的 url,并返回结果,等同于 request("POST", ...)
* opts 包含请求的附加选项,支持的内容如下:
* ```JavaScript
* {
* "query": {},
* "body": SeekedStream | Buffer | String | {},
* "json": {},
* "headers": {}
* }
* ```
* 其中 body,json 不得同时出现。缺省为 {},不包含任何附加信息
* @param url 指定 url,必须是包含主机的完整 url
* @param opts 指定附加信息
* @return 返回服务器响应
*
*
* @async
*/
post(url: string, opts?: Object/** = v8::Object::New(isolate)*/): Class_HttpResponse;
/**
*
* @brief 用 DELETE 方法请求指定的 url,并返回结果,等同于 request("DELETE", ...)
* opts 包含请求的附加选项,支持的内容如下:
* ```JavaScript
* {
* "query": {},
* "body": SeekedStream | Buffer | String | {},
* "json": {},
* "headers": {}
* }
* ```
* 其中 body,json 不得同时出现。缺省为 {},不包含任何附加信息
* @param url 指定 url,必须是包含主机的完整 url
* @param opts 指定附加信息
* @return 返回服务器响应
*
*
* @async
*/
del(url: string, opts?: Object/** = v8::Object::New(isolate)*/): Class_HttpResponse;
/**
*
* @brief 用 PUT 方法请求指定的 url,并返回结果,等同于 request("PUT", ...)
* opts 包含请求的附加选项,支持的内容如下:
* ```JavaScript
* {
* "query": {},
* "body": SeekedStream | Buffer | String | {},
* "json": {},
* "headers": {}
* }
* ```
* 其中 body,json 不得同时出现。缺省为 {},不包含任何附加信息
* @param url 指定 url,必须是包含主机的完整 url
* @param opts 指定附加信息
* @return 返回服务器响应
*
*
* @async
*/
put(url: string, opts?: Object/** = v8::Object::New(isolate)*/): Class_HttpResponse;
/**
*
* @brief 用 PATCH 方法请求指定的 url,并返回结果,等同于 request("PATCH", ...)
* opts 包含请求的附加选项,支持的内容如下:
* ```JavaScript
* {
* "query": {},
* "body": SeekedStream | Buffer | String | {},
* "json": {},
* "headers": {}
* }
* ```
* 其中 body,json 不得同时出现。缺省为 {},不包含任何附加信息
* @param url 指定 url,必须是包含主机的完整 url
* @param opts 指定附加信息
* @return 返回服务器响应
*
*
* @async
*/
patch(url: string, opts?: Object/** = v8::Object::New(isolate)*/): Class_HttpResponse;
} /** endof class */
/** } /** endof `module Or Internal Object` */
+126
View File
@@ -0,0 +1,126 @@
/***************************************************************************
* *
* This file was automatically generated with idlc.js *
* build info: *
* - fibjs : 0.25.0 *
* - date : Jun 11 2018 14:17:22 *
* *
***************************************************************************/
/**
* @author Richard <richardo2016@gmail.com>
*
*/
/// <reference path="object.d.ts" />
/** module Or Internal Object */
/**
* @brief http 容器对象,用于 http header,cookie,query,form,等数据的存储与组织
* @detail
*/
declare class Class_HttpCollection extends Class__object {
/**
*
* @brief 清除容器数据
*
*
*/
clear(): void;
/**
*
* @brief 检查容器内是否存在指定键值的数据
* @param name 指定要检查的键值
* @return 返回键值是否存在
*
*
*
*/
has(name: string): boolean;
/**
*
* @brief 查询指定键值的第一个值
* @param name 指定要查询的键值
* @return 返回键值所对应的值,若不存在,则返回 undefined
*
*
*
*/
first(name: string): any;
/**
*
* @brief 查询指定键值的全部值
* @param name 指定要查询的键值
* @return 返回键值所对应全部值的数组,若数据不存在,则返回 null
*
*
*
*/
all(name: string): any[];
/**
*
* @brief 添加一个键值数据,添加数据并不修改已存在的键值的数据
* @param map 指定要添加的键值数据字典
*
*
*
*/
add(map: Object): void;
/**
*
* @brief 添加一个键值数据,添加数据并不修改已存在的键值的数据
* @param name 指定要添加的键值
* @param value 指定要添加的数据
*
*
*
*/
add(name: string, value: any): void;
/**
*
* @brief 设定一个键值数据,设定数据将修改键值所对应的第一个数值,并清除相同键值的其余数据
* @param map 指定要设定的键值数据字典
*
*
*
*/
set(map: Object): void;
/**
*
* @brief 设定一个键值数据,设定数据将修改键值所对应的第一个数值,并清除相同键值的其余数据
* @param name 指定要设定的键值
* @param value 指定要设定的数据
*
*
*
*/
set(name: string, value: any): void;
/**
*
* @brief 删除指定键值的全部值
* @param name 指定要删除的键值
*
*
*
*/
remove(name: string): void;
} /** endof class */
/** } /** endof `module Or Internal Object` */
+160
View File
@@ -0,0 +1,160 @@
/***************************************************************************
* *
* This file was automatically generated with idlc.js *
* build info: *
* - fibjs : 0.25.0 *
* - date : Jun 11 2018 14:17:22 *
* *
***************************************************************************/
/**
* @author Richard <richardo2016@gmail.com>
*
*/
/// <reference path="object.d.ts" />
/** module Or Internal Object */
/**
* @brief http Cookie 对象,用于添加和处理 cookie
* @detail
*/
declare class Class_HttpCookie extends Class__object {
/**
* class prop
*
*
* @brief 查询和设置 cookie 名称
*
*
* @type String
*/
name: string
/**
* class prop
*
*
* @brief 查询和设置 cookie 的值
*
*
* @type String
*/
value: string
/**
* class prop
*
*
* @brief 查询和设置 cookie 的域名范围
*
*
* @type String
*/
domain: string
/**
* class prop
*
*
* @brief 查询和设置 cookie 的路径范围
*
*
* @type String
*/
path: string
/**
* class prop
*
*
* @brief 查询和设置 cookie 的过期时间
*
*
* @type Date
*/
expires: Date
/**
* class prop
*
*
* @brief 查询和设置 cookie 是否仅允许 http 请求,缺省 false
*
*
* @type Boolean
*/
httpOnly: boolean
/**
* class prop
*
*
* @brief 查询和设置 cookie 是否仅通过 https 传递,缺省 false
*
*
* @type Boolean
*/
secure: boolean
/**
*
* @brief HttpCookie 构造函数,创建一个新的 HttpCookie 对象
* @param opts 指定创建的 cookie 的属性
*
*
*
*/
constructor(opts?: Object/** = v8::Object::New(isolate)*/);
/**
*
* @brief HttpCookie 构造函数,创建一个新的 HttpCookie 对象
* @param name 指定创建的 cookie 名称
* @param value 指定创建的 cookie 值
* @param opts 指定创建的 cookie 的其它属性
*
*
*
*/
constructor(name: string, value: string, opts?: Object/** = v8::Object::New(isolate)*/);
/**
*
* @brief 解析给定的字符串,填充 cookie 对象
* @param header 指定需要解析的 header 字符串
*
*
*
*/
parse(header: string): void;
/**
*
* @brief 检测给定的 url 是否匹配当前设置
* @param url 指定测试的 url
* @return 匹配成功返回 true
*
*
*
*/
match(url: string): boolean;
} /** endof class */
/** } /** endof `module Or Internal Object` */
+101
View File
@@ -0,0 +1,101 @@
/***************************************************************************
* *
* This file was automatically generated with idlc.js *
* build info: *
* - fibjs : 0.25.0 *
* - date : Jun 11 2018 14:17:22 *
* *
***************************************************************************/
/**
* @author Richard <richardo2016@gmail.com>
*
*/
/// <reference path="object.d.ts" />
/** module Or Internal Object */
/**
* @brief http 协议转换处理器
* @detail 用以将数据流转换为 http 协议消息,创建方式:,```JavaScript,var hdlr = new mq.HttpHandler(...);,```,或者:,```JavaScript,var hdlr = new http.Handler(...);,```
*/
/// <reference path="HandlerEx.d.ts" />
declare class Class_HttpHandler extends Class_HandlerEx {
/**
* class prop
*
*
* @brief 查询和设置是否允强制使用 gzip 压缩输出,缺省为 false
*
*
* @type Boolean
*/
forceGZIP: boolean
/**
* class prop
*
*
* @brief 查询和设置最大请求头个数,缺省为 128
*
*
* @type Integer
*/
maxHeadersCount: number
/**
* class prop
*
*
* @brief 查询和设置 body 最大尺寸,以 MB 为单位,缺省为 64
*
*
* @type Integer
*/
maxBodySize: number
/**
* class prop
*
*
* @brief 查询和设置服务器名称,缺省为:fibjs/0.x.0
*
*
* @type String
*/
serverName: string
/**
*
* @brief 创建一个 http 协议处理器对象,将流对象的数据转变为 http 消息对象
* @param hdlr 内置消息处理器,处理函数,链式处理数组,路由对象,详见 mq.Handler
*
*
*
*/
constructor(hdlr: Class_Handler);
/**
*
* @brief 允许跨域请求
* @param allowHeaders 指定接受的 http 头字段
*
*
*
*/
enableCrossOrigin(allowHeaders?: string/** = "Content-Type"*/): void;
} /** endof class */
/** } /** endof `module Or Internal Object` */
+202
View File
@@ -0,0 +1,202 @@
/***************************************************************************
* *
* This file was automatically generated with idlc.js *
* build info: *
* - fibjs : 0.25.0 *
* - date : Jun 11 2018 14:17:22 *
* *
***************************************************************************/
/**
* @author Richard <richardo2016@gmail.com>
*
*/
/// <reference path="object.d.ts" />
/** module Or Internal Object */
/**
* @brief http 基础消息对象
* @detail
*/
/// <reference path="Message.d.ts" />
declare class Class_HttpMessage extends Class_Message {
/**
* class prop
*
*
* @brief 协议版本信息,允许的格式为:HTTP/#.#
*
*
* @type String
*/
protocol: string
/**
* class prop
*
*
* @brief 包含消息中 http 消息头的容器,只读属性
*
* @readonly
* @type HttpCollection
*/
headers: Class_HttpCollection
/**
* class prop
*
*
* @brief 查询和设定是否保持连接
*
*
* @type Boolean
*/
keepAlive: boolean
/**
* class prop
*
*
* @brief 查询和设定是否是升级协议
*
*
* @type Boolean
*/
upgrade: boolean
/**
* class prop
*
*
* @brief 查询和设置最大请求头个数,缺省为 128
*
*
* @type Integer
*/
maxHeadersCount: number
/**
* class prop
*
*
* @brief 查询和设置 body 最大尺寸,以 MB 为单位,缺省为 64
*
*
* @type Integer
*/
maxBodySize: number
/**
* class prop
*
*
* @brief 查询当前对象的来源 socket
*
* @readonly
* @type Stream
*/
socket: Class_Stream
/**
*
* @brief 检查是否存在指定键值的消息头
* @param name 指定要检查的键值
* @return 返回键值是否存在
*
*
*
*/
hasHeader(name: string): boolean;
/**
*
* @brief 查询指定键值的第一个消息头
* @param name 指定要查询的键值
* @return 返回键值所对应的值,若不存在,则返回 undefined
*
*
*
*/
firstHeader(name: string): any;
/**
*
* @brief 查询指定键值的全部消息头
* @param name 指定要查询的键值
* @return 返回键值所对应全部值的数组,若数据不存在,则返回 null
*
*
*
*/
allHeader(name: string): any[];
/**
*
* @brief 添加一个消息头,添加数据并不修改已存在的键值的消息头
* @param map 指定要添加的键值数据字典
*
*
*
*/
addHeader(map: Object): void;
/**
*
* @brief 添加一个消息头,添加数据并不修改已存在的键值的消息头
* @param name 指定要添加的键值
* @param value 指定要添加的数据
*
*
*
*/
addHeader(name: string, value: any): void;
/**
*
* @brief 设定一个消息头,设定数据将修改键值所对应的第一个数值,并清除相同键值的其余消息头
* @param map 指定要设定的键值数据字典
*
*
*
*/
setHeader(map: Object): void;
/**
*
* @brief 设定一个消息头,设定数据将修改键值所对应的第一个数值,并清除相同键值的其余消息头
* @param name 指定要设定的键值
* @param value 指定要设定的数据
*
*
*
*/
setHeader(name: string, value: any): void;
/**
*
* @brief 删除指定键值的全部消息头
* @param name 指定要删除的键值
*
*
*
*/
removeHeader(name: string): void;
} /** endof class */
/** } /** endof `module Or Internal Object` */
+125
View File
@@ -0,0 +1,125 @@
/***************************************************************************
* *
* This file was automatically generated with idlc.js *
* build info: *
* - fibjs : 0.25.0 *
* - date : Jun 11 2018 14:17:22 *
* *
***************************************************************************/
/**
* @author Richard <richardo2016@gmail.com>
*
*/
/// <reference path="object.d.ts" />
/** module Or Internal Object */
/**
* @brief http 请求消息对象
* @detail
*/
/// <reference path="HttpMessage.d.ts" />
declare class Class_HttpRequest extends Class_HttpMessage {
/**
* class prop
*
*
* @brief 获取响应消息对象
*
* @readonly
* @type HttpResponse
*/
response: Class_HttpResponse
/**
* class prop
*
*
* @brief 查询和设置请求方法
*
*
* @type String
*/
method: string
/**
* class prop
*
*
* @brief 查询和设置请求地址
*
*
* @type String
*/
address: string
/**
* class prop
*
*
* @brief 查询和设置请求查询字符串
*
*
* @type String
*/
queryString: string
/**
* class prop
*
*
* @brief 获取包含消息 cookies 的容器
*
* @readonly
* @type HttpCollection
*/
cookies: Class_HttpCollection
/**
* class prop
*
*
* @brief 获取包含消息 form 的容器
*
* @readonly
* @type HttpCollection
*/
form: Class_HttpCollection
/**
* class prop
*
*
* @brief 获取包含消息 query 的容器
*
* @readonly
* @type HttpCollection
*/
query: Class_HttpCollection
/**
*
* @brief HttpRequest 构造函数,创建一个新的 HttpRequest 对象
*
*
*/
constructor();
} /** endof class */
/** } /** endof `module Or Internal Object` */
+130
View File
@@ -0,0 +1,130 @@
/***************************************************************************
* *
* This file was automatically generated with idlc.js *
* build info: *
* - fibjs : 0.25.0 *
* - date : Jun 11 2018 14:17:22 *
* *
***************************************************************************/
/**
* @author Richard <richardo2016@gmail.com>
*
*/
/// <reference path="object.d.ts" />
/** module Or Internal Object */
/**
* @brief http 响应消息对象
* @detail
*/
/// <reference path="HttpMessage.d.ts" />
declare class Class_HttpResponse extends Class_HttpMessage {
/**
* class prop
*
*
* @brief 查询和设置响应消息的返回状态
*
*
* @type Integer
*/
statusCode: number
/**
* class prop
*
*
* @brief 查询和设置响应消息的返回消息
*
*
* @type String
*/
statusMessage: string
/**
* class prop
*
*
* @brief 返回当前消息的 HttpCookie 对象列表
*
* @readonly
* @type NArray
*/
cookies: any[]
/**
*
* @brief HttpResponse 构造函数,创建一个新的 HttpResponse 对象
*
*
*/
constructor();
/**
*
* @brief 设置响应消息的返回状态,返回消息,并添加响应头
* @param statusCode 指定响应消息的返回状态
* @param statusMessage 指定响应消息的返回消息
* @param headers 指定响应消息添加的响应头
*
*
*
*/
writeHead(statusCode: number, statusMessage: string, headers?: Object/** = v8::Object::New(isolate)*/): void;
/**
*
* @brief 设置响应消息的返回状态,返回消息,并添加响应头
* @param statusCode 指定响应消息的返回状态
* @param headers 指定响应消息添加的响应头
*
*
*
*/
writeHead(statusCode: number, headers?: Object/** = v8::Object::New(isolate)*/): void;
/**
*
* @brief 向 cookies 添加一个 HttpCookie 对象
* @param cookie 指定要添加的 HttpCookie 对象
*
*
*
*/
addCookie(cookie: Class_HttpCookie): void;
/**
*
* @brief 发送重定向到客户端
* @param url 重定向的地址
*
*
*
*/
redirect(url: string): void;
/**
*
* @brief 仅发送格式化 http 头到给定的流对象
* @param stm 指定接收格式化消息的流对象
*
*
* @async
*/
sendHeader(stm: Class_Stream): void;
} /** endof class */
/** } /** endof `module Or Internal Object` */
+162
View File
@@ -0,0 +1,162 @@
/***************************************************************************
* *
* This file was automatically generated with idlc.js *
* build info: *
* - fibjs : 0.25.0 *
* - date : Jun 11 2018 14:17:22 *
* *
***************************************************************************/
/**
* @author Richard <richardo2016@gmail.com>
*
*/
/// <reference path="object.d.ts" />
/** module Or Internal Object */
/**
* @brief http 服务器对象
* @detail http 服务器对象是将 TcpServer 和 HttpHandler 组合封装的对象,方便快速搭建服务器,逻辑上相当于:,```JavaScript,var svr = new net.TcpServer(addr, port, new http.Handler(function(req){, ...,}));,```,,创建方法:,```JavaScript,var http = require("http");,var svr = new http.Server(80, function(req){, ...,});,```
*/
/// <reference path="TcpServer.d.ts" />
declare class Class_HttpServer extends Class_TcpServer {
/**
* class prop
*
*
* @brief 查询和设置是否允强制使用 gzip 压缩输出,缺省为 false
*
*
* @type Boolean
*/
forceGZIP: boolean
/**
* class prop
*
*
* @brief 查询和设置最大请求头个数,缺省为 128
*
*
* @type Integer
*/
maxHeadersCount: number
/**
* class prop
*
*
* @brief 查询和设置 body 最大尺寸,以 MB 为单位,缺省为 64
*
*
* @type Integer
*/
maxBodySize: number
/**
* class prop
*
*
* @brief 查询和设置服务器名称,缺省为:fibjs/0.x.0
*
*
* @type String
*/
serverName: string
/**
* class prop
*
*
* @brief 查询 http 协议转换处理器的工作状态
*
* 返回的结果为一个 Stats 对象,结构如下:
* ```JavaScript
* {
* total : 1000, // 总计处理的请求
* pendding : 100, // 当前正在处理的请求
* request : 10, // 新建的请求
* response : 10, // 发送的响应
* error : 100, // 发生的错误(不计入 404)
* error_400 : 10, // 发生的请求错误
* error_404 : 12, // 文件未找到的数量
* error_500 : 2 // 内部处理错误
* }
* ```
*
*
* @readonly
* @type Stats
*/
httpStats: Class_Stats
/**
*
* @brief HttpServer 构造函数,在所有本机地址侦听
* @param port 指定 http 服务器侦听端口
* @param hdlr http 内置消息处理器,处理函数,链式处理数组,路由对象,详见 mq.Handler
*
*
*
*/
constructor(port: number, hdlr: Class_Handler);
/**
*
* @brief HttpServer 构造函数
* @param addr 指定 http 服务器侦听地址,为 "" 则在本机所有地址侦听
* @param port 指定 http 服务器侦听端口
* @param hdlr http 内置消息处理器,处理函数,链式处理数组,路由对象,详见 mq.Handler
*
*
*
*/
constructor(addr: string, port: number, hdlr: Class_Handler);
/**
*
* @brief 设置错误处理器
*
* 使用方式:
* ```JavaScript
* hdlr.onerror({
* "404": function(v)
* {
* ...
* },
* "500": new mq.Routing(...)
* })
* ```
* @param hdlrs 指定不同的错误的处理器,key 是错误号,value 是处理器,可以是内置消息处理器,处理函数,链式处理数组,路由对象,详见 mq.Handler
*
*
*
*/
onerror(hdlrs: Object): void;
/**
*
* @brief 允许跨域请求
* @param allowHeaders 指定接受的 http 头字段
*
*
*
*/
enableCrossOrigin(allowHeaders?: string/** = "Content-Type"*/): void;
} /** endof class */
/** } /** endof `module Or Internal Object` */
+81
View File
@@ -0,0 +1,81 @@
/***************************************************************************
* *
* This file was automatically generated with idlc.js *
* build info: *
* - fibjs : 0.25.0 *
* - date : Jun 11 2018 14:17:22 *
* *
***************************************************************************/
/**
* @author Richard <richardo2016@gmail.com>
*
*/
/// <reference path="object.d.ts" />
/** module Or Internal Object */
/**
* @brief 包含 multipart 的一个条目数据
* @detail
*/
declare class Class_HttpUploadData extends Class__object {
/**
* class prop
*
*
* @brief 包含本条目数据的文件名
*
* @readonly
* @type String
*/
fileName: string
/**
* class prop
*
*
* @brief 包含本条目数据的类型
*
* @readonly
* @type String
*/
contentType: string
/**
* class prop
*
*
* @brief 包含本条目数据的传输编码类型
*
* @readonly
* @type String
*/
contentTransferEncoding: string
/**
* class prop
*
*
* @brief 包含本条目数据部分的流对象
*
* @readonly
* @type SeekableStream
*/
body: Class_SeekableStream
} /** endof class */
/** } /** endof `module Or Internal Object` */
+137
View File
@@ -0,0 +1,137 @@
/***************************************************************************
* *
* This file was automatically generated with idlc.js *
* build info: *
* - fibjs : 0.25.0 *
* - date : Jun 11 2018 14:17:22 *
* *
***************************************************************************/
/**
* @author Richard <richardo2016@gmail.com>
*
*/
/// <reference path="object.d.ts" />
/** module Or Internal Object */
/**
* @brief https 服务器对象
* @detail https 服务器对象是将 SslServer 和 HttpHandler 组合封装的对象,方便快速搭建服务器,逻辑上相当于:,```JavaScript,var svr = new net.SslServer(crt, key, addr, port, new http.Handler(function(req){, ...,}));,```,,创建方法:,```JavaScript,var http = require("http");,var svr = new http.HttpsServer(crt, key, 443, function(req){, ...,});,```
*/
/// <reference path="HttpServer.d.ts" />
declare class Class_HttpsServer extends Class_HttpServer {
/**
* class prop
*
*
* @brief 设定证书验证模式,缺省为 VERIFY_NONE
*
*
* @type Integer
*/
verification: number
/**
* class prop
*
*
* @brief 客户端证书验证 ca
*
* @readonly
* @type X509Cert
*/
ca: Class_X509Cert
/**
*
* @brief HttpsServer 构造函数,在所有本机地址侦听
*
* certs 格式为:
* ```JavaScript
* [
* {
* crt: [X509Cert object],
* key: [PKey object]
* },
* {
* crt: [X509Cert object],
* key: [PKey object]
* }
* ]
* ```
* @param certs 服务器证书列表
* @param port 指定 http 服务器侦听端口
* @param hdlr http 内置消息处理器,处理函数,链式处理数组,路由对象,详见
*
*
*
*/
constructor(certs: any[], port: number, hdlr: Class_Handler);
/**
*
* @brief HttpsServer 构造函数
*
* certs 格式为:
* ```JavaScript
* [
* {
* crt: [X509Cert object],
* key: [PKey object]
* },
* {
* crt: [X509Cert object],
* key: [PKey object]
* }
* ]
* ```
* @param certs 服务器证书列表
* @param addr 指定 http 服务器侦听地址,为 "" 则在本机所有地址侦听
* @param port 指定 http 服务器侦听端口
* @param hdlr http 内置消息处理器,处理函数,链式处理数组,路由对象,详见
*
*
*
*/
constructor(certs: any[], addr: string, port: number, hdlr: Class_Handler);
/**
*
* @brief HttpsServer 构造函数,在所有本机地址侦听
* @param crt X509Cert 证书,用于客户端验证服务器
* @param key PKey 私钥,用于与客户端会话
* @param port 指定 http 服务器侦听端口
* @param hdlr http 内置消息处理器,处理函数,链式处理数组,路由对象,详见
*
*
*
*/
constructor(crt: Class_X509Cert, key: Class_PKey, port: number, hdlr: Class_Handler);
/**
*
* @brief HttpsServer 构造函数
* @param crt X509Cert 证书,用于客户端验证服务器
* @param key PKey 私钥,用于与客户端会话
* @param addr 指定 http 服务器侦听地址,为 "" 则在本机所有地址侦听
* @param port 指定 http 服务器侦听端口
* @param hdlr http 内置消息处理器,处理函数,链式处理数组,路由对象,详见
*
*
*
*/
constructor(crt: Class_X509Cert, key: Class_PKey, addr: string, port: number, hdlr: Class_Handler);
} /** endof class */
/** } /** endof `module Or Internal Object` */
+856
View File
@@ -0,0 +1,856 @@
/***************************************************************************
* *
* This file was automatically generated with idlc.js *
* build info: *
* - fibjs : 0.25.0 *
* - date : Jun 11 2018 14:17:22 *
* *
***************************************************************************/
/**
* @author Richard <richardo2016@gmail.com>
*
*/
/// <reference path="object.d.ts" />
/** module Or Internal Object */
/**
* @brief 图像处理对象,用以对图像进行转换,绘制,存储等操作
* @detail Image 对象属于 gd 模块,创建:,```JavaScript,var img = gd.create(640, 480);,var img1 = gd.load(data);,```
*/
declare class Class_Image extends Class__object {
/**
* class prop
*
*
* @brief 查询图像宽度
*
* @readonly
* @type Integer
*/
width: number
/**
* class prop
*
*
* @brief 查询图像高度
*
* @readonly
* @type Integer
*/
height: number
/**
* class prop
*
*
* @brief 查询图像来源格式,结果为 gd.PNG, gd.JPEG, gd.GIF, gd.BMP, gd.WEBP
*
* @readonly
* @type Integer
*/
format: number
/**
* class prop
*
*
* @brief 查询图像类型,结果为 gd.TRUECOLOR, gd.PALETTE
*
* @readonly
* @type Integer
*/
type: number
/**
* class prop
*
*
* @brief 查询图像颜色表内的颜色总数
*
* @readonly
* @type Integer
*/
colorsTotal: number
/**
* class prop
*
*
* @brief 查询和设定指定的颜色为透明色
*
*
* @type Integer
*/
transparent: number
/**
* class prop
*
*
* @brief 查询和设定图像是否渐进式,仅支持 jpeg 格式时
*
*
* @type Boolean
*/
progressive: boolean
/**
* class prop
*
*
* @brief查询和设定绘图时是否计算 alpha 层,缺省为 true
*
*
* @type Boolean
*/
alphaBlending: boolean
/**
*
* @brief 按照指定的格式返回图像数据
* @param format 指定返回数据的格式,允许值为 gd.PNG, gd.JPEG, gd.GIF, gd.BMP, gd.WEBP, 缺省为 gd.PNG
* @param quality 当格式为 gd.JPEG 或 gd.WEBP 时用于指定压缩质量,缺省为 85,其他格式忽略此参数
* @return 返回格式化的数据
*
*
* @async
*/
getData(format?: number/** = undefined*/, quality?: number/** = 85*/): Class_Buffer;
/**
*
* @brief 按照指定的格式将图像数据存入流对象
* @param stm 指定要存入的流对象
* @param format 指定返回数据的格式,允许值为 gd.PNG, gd.JPEG, gd.GIF, gd.BMP, gd.WEBP, 缺省为 gd.PNG
* @param quality 当格式为 gd.JPEG 或 gd.WEBP 时用于指定压缩质量,缺省为 85,其他格式忽略此参数
*
*
* @async
*/
save(stm: Class_Stream, format?: number/** = undefined*/, quality?: number/** = 85*/): void;
/**
*
* @brief 按照指定的格式将图像数据存入指定文件,文件将被强制覆盖
* @param fname 指定文件名
* @param format 指定返回数据的格式,允许值为 gd.PNG, gd.JPEG, gd.GIF, gd.BMP, gd.WEBP, 缺省为 gd.PNG
* @param quality 当格式为 gd.JPEG 时用于指定压缩质量,缺省为 85,其他格式忽略此参数
*
*
* @async
*/
save(fname: string, format?: number/** = undefined*/, quality?: number/** = 85*/): void;
/**
*
* @brief 为指定的颜色申请一个颜色号,对于 gd.PALETTE 图像,颜色号为调色板索引,对于 gd.TRUECOLOR 图像,颜色号为 rgb 编码数值
* @param red 红色分量,范围为 0-255
* @param green 绿色分量,范围为 0-255
* @param blue 蓝色分量,范围为 0-255
* @return 返回颜色号,不成功返回 -1
*
*
*
*/
colorAllocate(red: number, green: number, blue: number): number;
/**
*
* @brief 为指定的颜色申请一个颜色号,对于 gd.PALETTE 图像,颜色号为调色板索引,对于 gd.TRUECOLOR 图像,颜色号为 rgb 编码数值
* @param color 组合颜色值,可由 gd.color, gb.rgb, gd.rgba 等函数生成
* @return 返回颜色号,不成功返回 -1
*
*
*
*/
colorAllocate(color: number): number;
/**
*
* @brief 为指定的颜色及透明申请一个颜色号,对于 gd.PALETTE 图像,颜色号为调色板索引,对于 gd.TRUECOLOR 图像,颜色号为 rgba 编码数值
* @param red 红色分量,范围为 0-255
* @param green 绿色分量,范围为 0-255
* @param blue 蓝色分量,范围为 0-255
* @param alpha 透明分量,范围为 0-1.0
* @return 返回颜色号,不成功返回 -1
*
*
*
*/
colorAllocateAlpha(red: number, green: number, blue: number, alpha: number): number;
/**
*
* @brief 为指定的颜色及透明申请一个颜色号,对于 gd.PALETTE 图像,颜色号为调色板索引,对于 gd.TRUECOLOR 图像,颜色号为 rgba 编码数值
* @param color 组合颜色值,可由 gd.color, gb.rgb, gd.rgba 等函数生成
* @return 返回颜色号,不成功返回 -1
*
*
*
*/
colorAllocateAlpha(color: number): number;
/**
*
* @brief 为指定的颜色查找一个最接近的颜色号,对于 gd.PALETTE 图像,颜色号为调色板索引,对于 gd.TRUECOLOR 图像,颜色号为 rgb 编码数值
* @param red 红色分量,范围为 0-255
* @param green 绿色分量,范围为 0-255
* @param blue 蓝色分量,范围为 0-255
* @return 返回颜色号,不成功返回 -1
*
*
*
*/
colorClosest(red: number, green: number, blue: number): number;
/**
*
* @brief 为指定的颜色查找一个最接近的颜色号,对于 gd.PALETTE 图像,颜色号为调色板索引,对于 gd.TRUECOLOR 图像,颜色号为 rgb 编码数值
* @param color 组合颜色值,可由 gd.color, gb.rgb, gd.rgba 等函数生成
* @return 返回颜色号,不成功返回 -1
*
*
*
*/
colorClosest(color: number): number;
/**
*
* @brief 为指定的颜色查找一个最接近的颜色号,此方法使用 Hue/White/Black 计算查找最接近颜色,对于 gd.PALETTE 图像,颜色号为调色板索引,对于 gd.TRUECOLOR 图像,颜色号为 rgb 编码数值
* @param red 红色分量,范围为 0-255
* @param green 绿色分量,范围为 0-255
* @param blue 蓝色分量,范围为 0-255
* @return 返回颜色号,不成功返回 -1
*
*
*
*/
colorClosestHWB(red: number, green: number, blue: number): number;
/**
*
* @brief 为指定的颜色查找一个最接近的颜色号,此方法使用 Hue/White/Black 计算查找最接近颜色,对于 gd.PALETTE 图像,颜色号为调色板索引,对于 gd.TRUECOLOR 图像,颜色号为 rgb 编码数值
* @param color 组合颜色值,可由 gd.color, gb.rgb, gd.rgba 等函数生成
* @return 返回颜色号,不成功返回 -1
*
*
*
*/
colorClosestHWB(color: number): number;
/**
*
* @brief 为指定的颜色及透明查找一个最接近的颜色号,对于 gd.PALETTE 图像,颜色号为调色板索引,对于 gd.TRUECOLOR 图像,颜色号为 rgba 编码数值
* @param red 红色分量,范围为 0-255
* @param green 绿色分量,范围为 0-255
* @param blue 蓝色分量,范围为 0-255
* @param alpha 透明分量,范围为 0-1.0
* @return 返回颜色号,不成功返回 -1
*
*
*
*/
colorClosestAlpha(red: number, green: number, blue: number, alpha: number): number;
/**
*
* @brief 为指定的颜色及透明查找一个最接近的颜色号,对于 gd.PALETTE 图像,颜色号为调色板索引,对于 gd.TRUECOLOR 图像,颜色号为 rgba 编码数值
* @param color 组合颜色值,可由 gd.color, gb.rgb, gd.rgba 等函数生成
* @return 返回颜色号,不成功返回 -1
*
*
*
*/
colorClosestAlpha(color: number): number;
/**
*
* @brief 查找指定的颜色对应的颜色号,对于 gd.PALETTE 图像,颜色号为调色板索引,对于 gd.TRUECOLOR 图像,颜色号为 rgb 编码数值
* @param red 红色分量,范围为 0-255
* @param green 绿色分量,范围为 0-255
* @param blue 蓝色分量,范围为 0-255
* @return 返回颜色号,不成功返回 -1
*
*
*
*/
colorExact(red: number, green: number, blue: number): number;
/**
*
* @brief 查找指定的颜色对应的颜色号,对于 gd.PALETTE 图像,颜色号为调色板索引,对于 gd.TRUECOLOR 图像,颜色号为 rgb 编码数值
* @param color 组合颜色值,可由 gd.color, gb.rgb, gd.rgba 等函数生成
* @return 返回颜色号,不成功返回 -1
*
*
*
*/
colorExact(color: number): number;
/**
*
* @brief 查找指定的颜色及透明对应的颜色号,对于 gd.PALETTE 图像,颜色号为调色板索引,对于 gd.TRUECOLOR 图像,颜色号为 rgba 编码数值
* @param red 红色分量,范围为 0-255
* @param green 绿色分量,范围为 0-255
* @param blue 蓝色分量,范围为 0-255
* @param alpha 透明分量,范围为 0-1.0
* @return 返回颜色号,不成功返回 -1
*
*
*
*/
colorExactAlpha(red: number, green: number, blue: number, alpha: number): number;
/**
*
* @brief 查找指定的颜色及透明对应的颜色号,对于 gd.PALETTE 图像,颜色号为调色板索引,对于 gd.TRUECOLOR 图像,颜色号为 rgba 编码数值
* @param color 组合颜色值,可由 gd.color, gb.rgb, gd.rgba 等函数生成
* @return 返回颜色号,不成功返回 -1
*
*
*
*/
colorExactAlpha(color: number): number;
/**
*
* @brief 查找指定的颜色对应的颜色号,如果颜色不存在,则为其申请一个新颜色号,对于 gd.PALETTE 图像,颜色号为调色板索引,对于 gd.TRUECOLOR 图像,颜色号为 rgb 编码数值
* @param red 红色分量,范围为 0-255
* @param green 绿色分量,范围为 0-255
* @param blue 蓝色分量,范围为 0-255
* @return 返回颜色号,不成功返回 -1
*
*
*
*/
colorResolve(red: number, green: number, blue: number): number;
/**
*
* @brief 查找指定的颜色对应的颜色号,如果颜色不存在,则为其申请一个新颜色号,对于 gd.PALETTE 图像,颜色号为调色板索引,对于 gd.TRUECOLOR 图像,颜色号为 rgb 编码数值
* @param color 组合颜色值,可由 gd.color, gb.rgb, gd.rgba 等函数生成
* @return 返回颜色号,不成功返回 -1
*
*
*
*/
colorResolve(color: number): number;
/**
*
* @brief 查找指定的颜色及透明对应的颜色号,如果颜色不存在,则为其申请一个新颜色号,对于 gd.PALETTE 图像,颜色号为调色板索引,对于 gd.TRUECOLOR 图像,颜色号为 rgba 编码数值
* @param red 红色分量,范围为 0-255
* @param green 绿色分量,范围为 0-255
* @param blue 蓝色分量,范围为 0-255
* @param alpha 透明分量,范围为 0-1.0
* @return 返回颜色号,不成功返回 -1
*
*
*
*/
colorResolveAlpha(red: number, green: number, blue: number, alpha: number): number;
/**
*
* @brief 查找指定的颜色及透明对应的颜色号,如果颜色不存在,则为其申请一个新颜色号,对于 gd.PALETTE 图像,颜色号为调色板索引,对于 gd.TRUECOLOR 图像,颜色号为 rgba 编码数值
* @param color 组合颜色值,可由 gd.color, gb.rgb, gd.rgba 等函数生成
* @return 返回颜色号,不成功返回 -1
*
*
*
*/
colorResolveAlpha(color: number): number;
/**
*
* @brief 释放指定的颜色号,释放的颜色号将会被再次申请后替换
* @param color 指定要释放的颜色号
*
*
*
*/
colorDeallocate(color: number): void;
/**
*
* @brief 设定绘图的剪切窗口,设定后,所有的绘制将被剪切在窗口内部
* @param x1 剪切窗口的左上 x 坐标
* @param y1 剪切窗口的左上 y 坐标
* @param x2 剪切窗口的右下 x 坐标
* @param y2 剪切窗口的右下 y 坐标
*
*
*
*/
clip(x1: number, y1: number, x2: number, y2: number): void;
/**
*
* @brief 查询指定位置点的颜色
* @param x 指定查询的 x 坐标
* @param y 指定查询的 y 坐标
* @return 返回指定点的颜色号
*
*
*
*/
getPixel(x: number, y: number): number;
/**
*
* @brief 查询指定位置点的真彩色颜色
* @param x 指定查询的 x 坐标
* @param y 指定查询的 y 坐标
* @return 返回指定点的颜色号
*
*
*
*/
getTrueColorPixel(x: number, y: number): number;
/**
*
* @brief 在指定位置画一个点
* @param x 指定画点的 x 坐标
* @param y 指定画点的 y 坐标
* @param color 指定画点的颜色号
*
*
*
*/
setPixel(x: number, y: number, color: number): void;
/**
*
* @brief 设定画线的宽度,line, rectangle, arc 等方法画线时缺省宽度为一个像素,可使用此方法改变线的宽度
* @param thickness 画线的宽度
*
*
*
*/
setThickness(thickness: number): void;
/**
*
* @brief 在指定的位置画一条线
* @param x1 指定画线的起始 x 坐标
* @param y1 指定画线的起始 y 坐标
* @param x2 指定画线的结束 x 坐标
* @param y2 指定画线的结束 y 坐标
* @param color 指定画线的颜色号
*
*
*
*/
line(x1: number, y1: number, x2: number, y2: number, color: number): void;
/**
*
* @brief 在指定的位置画一个矩形
* @param x1 指定左上角 x 坐标
* @param y1 指定左上角 y 坐标
* @param x2 指定右下角 x 坐标
* @param y2 指定右下角 y 坐标
* @param color 指定矩形的颜色号
*
*
*
*/
rectangle(x1: number, y1: number, x2: number, y2: number, color: number): void;
/**
*
* @brief 在指定的位置画一个填充的矩形
* @param x1 指定左上角 x 坐标
* @param y1 指定左上角 y 坐标
* @param x2 指定右下角 x 坐标
* @param y2 指定右下角 y 坐标
* @param color 指定矩形的颜色号
*
*
*
*/
filledRectangle(x1: number, y1: number, x2: number, y2: number, color: number): void;
/**
*
* @brief 根据给定的点绘制一个多边形
* @param points 包含多边形点的数组,如 [[1, 1], [1, 10], [10, 15], [10, 20]]
* @param color 指定矩形的颜色号
*
*
*
*/
polygon(points: any[], color: number): void;
/**
*
* @brief 根据给定的点绘制一个开放多边形
* @param points 包含多边形点的数组,如 [[1, 1], [1, 10], [10, 15], [10, 20]]
* @param color 指定矩形的颜色号
*
*
*
*/
openPolygon(points: any[], color: number): void;
/**
*
* @brief 根据给定的点绘制一个填充多边形
* @param points 包含多边形点的数组,如 [[1, 1], [1, 10], [10, 15], [10, 20]]
* @param color 指定矩形的颜色号
*
*
*
*/
filledPolygon(points: any[], color: number): void;
/**
*
* @brief 画一个椭圆
* @param x 椭圆中心的 x 坐标
* @param y 椭圆中心的 y 坐标
* @param width 椭圆的宽度
* @param height 椭圆的高度
* @param color 指定矩形的颜色号
*
*
*
*/
ellipse(x: number, y: number, width: number, height: number, color: number): void;
/**
*
* @brief 画一个填充的椭圆
* @param x 椭圆中心的 x 坐标
* @param y 椭圆中心的 y 坐标
* @param width 椭圆的宽度
* @param height 椭圆的高度
* @param color 指定矩形的颜色号
*
*
*
*/
filledEllipse(x: number, y: number, width: number, height: number, color: number): void;
/**
*
* @brief 画一个扇形
* @param x 扇形中心的 x 坐标
* @param y 扇形中心的 y 坐标
* @param width 扇形所在椭圆的宽度
* @param height 扇形所在椭圆的高度
* @param start 扇形开始的角度,范围为 0-360
* @param end 扇形结束的角度,范围为 0-360
* @param color 指定矩形的颜色号
*
*
*
*/
arc(x: number, y: number, width: number, height: number, start: number, end: number, color: number): void;
/**
*
* @brief 画一个填充扇形
* @param x 扇形中心的 x 坐标
* @param y 扇形中心的 y 坐标
* @param width 扇形所在椭圆的宽度
* @param height 扇形所在椭圆的高度
* @param start 扇形开始的角度,范围为 0-360
* @param end 扇形结束的角度,范围为 0-360
* @param color 指定矩形的颜色号
* @param style 指定扇形的样式,允许的值有 gd.ARC, gd.CHORD, gd.NOFILL, gd.EDGED 及其组合
*
*
*
*/
filledArc(x: number, y: number, width: number, height: number, start: number, end: number, color: number, style?: number/** = undefined*/): void;
/**
*
* @brief 从指定的点开始填充封闭区域
* @param x 开始填充的 x 坐标
* @param y 开始填充的 y 坐标
* @param color 指定填充的颜色号
*
*
*
*/
fill(x: number, y: number, color: number): void;
/**
*
* @brief 从指定的点开始在指定颜色的边框内填充封闭区域
* @param x 开始填充的 x 坐标
* @param y 开始填充的 y 坐标
* @param borderColor 指定边框的颜色号
* @param color 指定填充的颜色号
*
*
*
*/
fillToBorder(x: number, y: number, borderColor: number, color: number): void;
/**
*
* @brief 替换图像中指定的颜色为新颜色
* @param src 指定要替换的颜色
* @param dst 指定新颜色
*
*
* @async
*/
colorReplace(src: number, dst: number): void;
/**
*
* @brief 复制当前图像为一个新图像
* @return 返回复制的新图像对象
*
*
* @async
*/
clone(): Class_Image;
/**
*
* @brief 根据图像拉伸生成一个新尺寸的图像
* @param width 指定拉伸的宽度
* @param height 指定拉伸的高度
* @return 返回新图像对象
*
*
* @async
*/
resample(width: number, height: number): Class_Image;
/**
*
* @brief 剪切图像的一部分为一个新的图像
* @param x 剪切窗口的左上 x 坐标
* @param y 剪切窗口的左上 y 坐标
* @param width 剪切窗口的宽度
* @param height 剪切窗口的高度
* @return 返回剪切出的图像
*
*
* @async
*/
crop(x: number, y: number, width: number, height: number): Class_Image;
/**
*
* @brief 镜像当前图像
* @param dir 镜像方向,允许值为 gd.BOTH,gd.HORIZONTAL, gd.VERTICAL, 缺省为 gd.HORIZONTAL
*
*
* @async
*/
flip(dir?: number/** = undefined*/): void;
/**
*
* @brief 旋转当前图像
* @param dir 旋转方向,允许值为 gd.LEFT, gd.RIGHT
*
*
* @async
*/
rotate(dir: number): void;
/**
*
* @brief 转换当前图像类型
* @param color 指定图像类型,允许值为 gd.TRUECOLOR 或 gd.PALETTE
*
*
* @async
*/
convert(color?: number/** = undefined*/): void;
/**
*
* @brief 从一个图像中复制一个区域到指定的位置
* @param source 源图像对象
* @param dstX 指定复制目标的 x 坐标
* @param dstY 指定复制目标的 y 坐标
* @param srcX 指定复制源左上角的 x 坐标
* @param srcY 指定复制源左上角的 y 坐标
* @param width 指定复制的宽度
* @param height 指定复制的高度
*
*
* @async
*/
copy(source: Class_Image, dstX: number, dstY: number, srcX: number, srcY: number, width: number, height: number): void;
/**
*
* @brief 从一个图像中复制一个区域覆盖到指定的位置
* @param source 源图像对象
* @param dstX 指定复制目标的 x 坐标
* @param dstY 指定复制目标的 y 坐标
* @param srcX 指定复制源左上角的 x 坐标
* @param srcY 指定复制源左上角的 y 坐标
* @param width 指定复制的宽度
* @param height 指定复制的高度
* @param percent 指定覆盖的透明度
*
*
* @async
*/
copyMerge(source: Class_Image, dstX: number, dstY: number, srcX: number, srcY: number, width: number, height: number, percent: number): void;
/**
*
* @brief 从一个图像中复制一个区域的灰度覆盖到指定的位置
* @param source 源图像对象
* @param dstX 指定复制目标的 x 坐标
* @param dstY 指定复制目标的 y 坐标
* @param srcX 指定复制源左上角的 x 坐标
* @param srcY 指定复制源左上角的 y 坐标
* @param width 指定复制的宽度
* @param height 指定复制的高度
* @param percent 指定覆盖的透明度
*
*
* @async
*/
copyMergeGray(source: Class_Image, dstX: number, dstY: number, srcX: number, srcY: number, width: number, height: number, percent: number): void;
/**
*
* @brief 将一个图像中的一个区域拉伸后复制到指定的位置
* @param source 源图像对象
* @param dstX 指定复制目标的 x 坐标
* @param dstY 指定复制目标的 y 坐标
* @param srcX 指定复制源左上角的 x 坐标
* @param srcY 指定复制源左上角的 y 坐标
* @param dstW 指定复制的拉伸宽度
* @param dstH 指定复制的拉伸高度
* @param srcW 指定复制的源宽度
* @param srcH 指定复制的源高度
*
*
* @async
*/
copyResized(source: Class_Image, dstX: number, dstY: number, srcX: number, srcY: number, dstW: number, dstH: number, srcW: number, srcH: number): void;
/**
*
* @brief 将一个图像中的一个区域拉伸后复制到指定的位置,不同与 copyResized,此方法拉伸时会对图像进行抖动
* @param source 源图像对象
* @param dstX 指定复制目标的 x 坐标
* @param dstY 指定复制目标的 y 坐标
* @param srcX 指定复制源左上角的 x 坐标
* @param srcY 指定复制源左上角的 y 坐标
* @param dstW 指定复制的拉伸宽度
* @param dstH 指定复制的拉伸高度
* @param srcW 指定复制的源宽度
* @param srcH 指定复制的源高度
*
*
* @async
*/
copyResampled(source: Class_Image, dstX: number, dstY: number, srcX: number, srcY: number, dstW: number, dstH: number, srcW: number, srcH: number): void;
/**
*
* @brief 将一个图像中的一个区域旋转后复制到指定的位置
* @param source 源图像对象
* @param dstX 指定复制目标的 x 坐标
* @param dstY 指定复制目标的 y 坐标
* @param srcX 指定复制源左上角的 x 坐标
* @param srcY 指定复制源左上角的 y 坐标
* @param width 指定复制的宽度
* @param height 指定复制的高度
* @param angle 指定旋转的角度
*
*
* @async
*/
copyRotated(source: Class_Image, dstX: number, dstY: number, srcX: number, srcY: number, width: number, height: number, angle: number): void;
/**
*
* @brief 把过滤器 filterType应用到图像上,根据过滤器类型传入所需参数
*
* 参数 filterType 可以为以下数值:
* - MEAN_REMOVAL, 用平均移除法来达到轮廓效果
* - EDGEDETECT, 用边缘检测来突出图像的边缘
* - EMBOSS, 使图像浮雕化
* - SELECTIVE_BLUR, 模糊图像
* - GAUSSIAN_BLUR, 用高斯算法模糊图像
* - NEGATE, 将图像中所有颜色反转
* - GRAYSCALE, 将图像转换为灰度图
* - SMOOTH, 使图像更柔滑,用arg1设定柔滑级别
* - BRIGHTNESS, 改变图像的亮度,用arg1设定亮度级别,取值范围是-255~255
* - CONTRAST, 改变图像的对比度,用arg1设定对比度级别,取值范围是0~100
* - COLORIZE, 改变图像的色调,用arg1、arg2、arg3分别指定red、blue、green分值,每种颜色范围是0~255,arg4为透明度,取值返回是0~127
* @param filterType 过滤器类型
* @param arg1 过滤器所需参数: SMOOTH 的平滑级别、BRIGHTNESS 的亮度级别、CONTRAST 的对比度级别、COLORIZE 的 red 分值
* @param arg2 过滤器所需参数: COLORIZE 的 green 分值
* @param arg3 过滤器所需参数: COLORIZE 的 blue 分值
* @param arg4 过滤器所需参数: COLORIZE 的透明度 alpha 分值
*
*
* @async
*/
filter(filterType: number, arg1?: number/** = 0*/, arg2?: number/** = 0*/, arg3?: number/** = 0*/, arg4?: number/** = 0*/): void;
/**
*
* @brief 根据给定的矩阵,对当前图像进行仿射
*
* 参数 affine 是一个数组:
* ```JavaScript
* affine = [ a0, a1, b0, b1, a2, b2 ];
* x' = a0x + a1y + a2;
* y' = b0x + b1y + b2;
* ```
* @param affine 仿射矩阵,由 6 个 double 类型的数字组成
* @param x 可选剪切区域的原点 x 坐标
* @param y 可选剪切区域的原点 y 坐标
* @param width 可选剪切区域的的宽度
* @param height 可选剪切区域的的高度
* @return 返回仿射后的图像
*
*
* @async
*/
affine(affine: any[], x?: number/** = -1*/, y?: number/** = -1*/, width?: number/** = -1*/, height?: number/** = -1*/): Class_Image;
/**
*
* @brief 对当前图像进行高斯模糊处理
* @param radius 模糊半径
*
*
* @async
*/
gaussianBlur(radius: number): void;
} /** endof class */
/** } /** endof `module Or Internal Object` */
+241
View File
@@ -0,0 +1,241 @@
/***************************************************************************
* *
* This file was automatically generated with idlc.js *
* build info: *
* - fibjs : 0.25.0 *
* - date : Jun 11 2018 14:17:22 *
* *
***************************************************************************/
/**
* @author Richard <richardo2016@gmail.com>
*
*/
/// <reference path="object.d.ts" />
/** module Or Internal Object */
/**
* @brief 64位整数对象
* @detail 创建方法:,```JavaScript,var n = new Int64(123);,```
*/
declare class Class_Int64 extends Class__object {
/**
* class prop
*
*
* @brief 高 32 位数值
*
*
* @type Long
*/
hi: number
/**
* class prop
*
*
* @brief 低 32 位数值
*
*
* @type Long
*/
lo: number
/**
*
* @brief Int64 构造函数
* @param num 初始化的值
*
*
*
*/
constructor(num?: number/** = 0*/);
/**
*
* @brief Int64 构造函数
* @param hi 高32位数
* @param lo 低32位数
*
*
*
*/
constructor(hi: number, lo: number);
/**
*
* @brief Int64 构造函数
* @param num 初始化的值
*
*
*
*/
constructor(num: Class_Int64);
/**
*
* @brief Int64 构造函数
* @param num 数字字符串
* @param base 数字字符串的编码方式,可以接受 2-16, 32, 64,默认为 10,为 10 时自动识别 0x 编码
*
*
*
*/
constructor(num: string, base?: number/** = 10*/);
/**
*
* @brief 将 Int64 内的数值与给定数值比较大小
* @param num 指定比较的数值
* @return 返回 1 表示 Int64 内的数值比指定数值更大,0 表示相等,-1 表示更小
*
*
*
*/
compare(num: Class_Int64): number;
/**
*
* @brief 将 Int64 内的数值左移相应的位数,此操作不影响 Int64 原有数值
* @param bits 指定移动的位数
* @return 返回包含移位以后数值的对象
*
*
*
*/
shiftLeft(bits: number): Class_Int64;
/**
*
* @brief 将 Int64 内的数值右移相应的位数,此操作不影响 Int64 原有数值
* @param bits 指定移动的位数
* @return 返回包含移位以后数值的对象
*
*
*
*/
shiftRight(bits: number): Class_Int64;
/**
*
* @brief 将 Int64 内的数值与给定的数值进行按位 and 操作,此操作不影响 Int64 原有数值
* @param num 指定运算的数值
* @return 返回包含预算以后数值的对象
*
*
*
*/
and(num: Class_Int64): Class_Int64;
/**
*
* @brief 将 Int64 内的数值与给定的数值进行按位 or 操作,此操作不影响 Int64 原有数值
* @param num 指定运算的数值
* @return 返回包含预算以后数值的对象
*
*
*
*/
or(num: Class_Int64): Class_Int64;
/**
*
* @brief 将 Int64 内的数值与给定的数值进行按位 xor 操作,此操作不影响 Int64 原有数值
* @param num 指定运算的数值
* @return 返回包含预算以后数值的对象
*
*
*
*/
xor(num: Class_Int64): Class_Int64;
/**
*
* @brief 将 Int64 内的数值与给定的数值进行加操作,此操作不影响 Int64 原有数值
* @param num 指定运算的数值
* @return 返回包含预算以后数值的对象
*
*
*
*/
add(num: Class_Int64): Class_Int64;
/**
*
* @brief 将 Int64 内的数值与给定的数值进行减操作,此操作不影响 Int64 原有数值
* @param num 指定运算的数值
* @return 返回包含预算以后数值的对象
*
*
*
*/
sub(num: Class_Int64): Class_Int64;
/**
*
* @brief 将 Int64 内的数值与给定的数值进行乘操作,此操作不影响 Int64 原有数值
* @param num 指定运算的数值
* @return 返回包含预算以后数值的对象
*
*
*
*/
multi(num: Class_Int64): Class_Int64;
/**
*
* @brief 将 Int64 内的数值与给定的数值进行除操作,此操作不影响 Int64 原有数值
* @param num 指定运算的数值
* @return 返回包含预算以后数值的对象
*
*
*
*/
div(num: Class_Int64): Class_Int64;
/**
*
* @brief 比较当前对象与给定的对象是否相等
* @param expected 制定比较的目标对象
* @return 返回对象比较的结果
*
*
*
*/
equals(expected: Class__object): boolean;
/**
*
* @brief 转换成数字类型
* @return 返回转换后的数字
*
*
*
*/
toNumber(): number;
/**
*
* @brief 转换成字符串类型
* @param base 字符串进制数,可以接受 2-16, 32, 64,默认为 10
* @return 返回转换后的字符串
*
*
*
*/
toString(base?: number/** = 10*/): string;
} /** endof class */
/** } /** endof `module Or Internal Object` */
+176
View File
@@ -0,0 +1,176 @@
/***************************************************************************
* *
* This file was automatically generated with idlc.js *
* build info: *
* - fibjs : 0.25.0 *
* - date : Jun 11 2018 14:17:22 *
* *
***************************************************************************/
/**
* @author Richard <richardo2016@gmail.com>
*
*/
/// <reference path="object.d.ts" />
/** module Or Internal Object */
/**
* @brief LevelDB 数据库对象
* @detail 用以创建和管理字典对象,创建方法:,```JavaScript,var db = require("db");,var test = new db.openLevelDB("test.db");,```
*/
declare class Class_LevelDB extends Class__object {
/**
*
* @brief 检查数据库内是否存在指定键值的数据
* @param key 指定要检查的键值
* @return 返回键值是否存在
*
*
* @async
*/
has(key: Class_Buffer): boolean;
/**
*
* @brief 查询指定键值的值
* @param key 指定要查询的键值
* @return 返回键值所对应的值,若不存在,则返回 null
*
*
* @async
*/
get(key: Class_Buffer): Class_Buffer;
/**
*
* @brief 查询一组指定键值的值
* @param keys 指定要查询的键值数组
* @return 返回包含键值得数组
*
*
*
*/
mget(keys: any[]): any[];
/**
*
* @brief 设定一个键值数据,键值不存在则插入新数据
* @param key 指定要设定的键值
* @param value 指定要设定的数据
*
*
* @async
*/
set(key: Class_Buffer, value: Class_Buffer): void;
/**
*
* @brief 设定一组键值数据,键值不存在则插入新数据
* @param map 指定要设定的键值数据字典
*
*
*
*/
mset(map: Object): void;
/**
*
* @brief 删除一组指定键值的值
* @param keys 指定要删除的键值数组
*
*
*
*/
mremove(keys: any[]): void;
/**
*
* @brief 删除指定键值的全部值
* @param key 指定要删除的键值
*
*
* @async
*/
remove(key: Class_Buffer): void;
/**
*
* @brief 枚举数据库中所有的键值对
*
* 回调函数有两个参数,(value, key)
*
* ```JavaScript
* var db = require("db");
* var test = new db.openLevelDB("test.db");
*
* test.forEach(function(value, key){
* ...
* });
* ```
* @param func 枚举回调函数
*
*
*
*/
forEach(func: Function): void;
/**
*
* @brief 枚举数据库中键值在 from 和 to 之间的键值对
*
* 回调函数有两个参数,(value, key)
*
* ```JavaScript
* var db = require("db");
* var test = new db.openLevelDB("test.db");
*
* test.between("aaa", "bbb", function(value, key){
* ...
* });
* ```
* @param from 枚举的最小键值,枚举时包含此键值
* @param to 枚举的最大键值,枚举时不包含此键值
* @param func 枚举回调函数
*
*
*
*/
between(from: Class_Buffer, to: Class_Buffer, func: Function): void;
/**
*
* @brief 在当前数据库上开启一个事务
* @return 返回一个开启的事务对象
*
*
*/
begin(): Class_LevelDB;
/**
*
* @brief 提交当前事务
*
*
*/
commit(): void;
/**
*
* @brief 关闭当前数据库连接或事务
*
* @async
*/
close(): void;
} /** endof class */
/** } /** endof `module Or Internal Object` */
+79
View File
@@ -0,0 +1,79 @@
/***************************************************************************
* *
* This file was automatically generated with idlc.js *
* build info: *
* - fibjs : 0.25.0 *
* - date : Jun 11 2018 14:17:22 *
* *
***************************************************************************/
/**
* @author Richard <richardo2016@gmail.com>
*
*/
/// <reference path="object.d.ts" />
/** module Or Internal Object */
/**
* @brief 纤程锁对象
* @detail 不同于操作系统的锁,纤程锁是纯逻辑实现,加锁与解锁负荷很小,```JavaScript,var l = new coroutine.Lock();,l.acquire();,.....,l.release();,```
*/
declare class Class_Lock extends Class__object {
/**
*
* @brief 构造函数
*
*
*/
constructor();
/**
*
* @brief 获取锁的拥有权
*
* acquire 方法用于获取锁的拥有权,当锁处于可获取状态时,此方法立即返回 true。
*
* 当锁不可获取,且 blocking 为 true,则当前纤程进入休眠,当其他纤程释放锁后,此方法返回 true。
*
* 当锁不可获取,且 blocking 为 false,则方法返回 false。
* @param blocking 指定是否等待,为 true 时等待,缺省为真
* @return 返回是否成功获取锁,为 true 表示成功获取
*
*
*
*/
acquire(blocking?: boolean/** = true*/): boolean;
/**
*
* @brief 释放锁的拥有权
*
* 此方法将释放对锁的拥有权,如果当前纤程未拥有锁,此方法将抛出错误。
*
*
*
*/
release(): void;
/**
*
* @brief 查询当前等待任务数
* @return 返回任务数
*
*
*
*/
count(): number;
} /** endof class */
/** } /** endof `module Or Internal Object` */
+163
View File
@@ -0,0 +1,163 @@
/***************************************************************************
* *
* This file was automatically generated with idlc.js *
* build info: *
* - fibjs : 0.25.0 *
* - date : Jun 11 2018 14:17:22 *
* *
***************************************************************************/
/**
* @author Richard <richardo2016@gmail.com>
*
*/
/// <reference path="object.d.ts" />
/** module Or Internal Object */
/**
* @brief LRU(least recently used) 缓存对象
* @detail LruCache 用以维护一个 LRU 缓存,创建方法:,```JavaScript,var util = require("util");,var c = new util.LruCache(10, 100);,```
*/
/// <reference path="EventEmitter.d.ts" />
declare class Class_LruCache extends Class_EventEmitter {
/**
* class prop
*
*
* @brief 查询容器内数值个数
*
* @readonly
* @type Integer
*/
size: number
/**
* class prop
*
*
* @brief 查询和设置容器内元素失效时间,单位是 ms,小于等于 0 不失效
*
*
* @type Integer
*/
timeout: number
/**
* class prop
*
*
* @brief 查询和绑定数据超时事件,相当于 on("expire", func);
*
*
* @type Function
*/
onexpire: Function
/**
*
* @brief LruCache 对象构造函数
* @param size 缓存最大尺寸
* @param timeout 元素失效时间,单位是 ms,小于等于 0 不失效,缺省为 0
*
*
*
*/
constructor(size: number, timeout?: number/** = 0*/);
/**
*
* @brief 清除容器数据
*
*
*/
clear(): void;
/**
*
* @brief 检查容器内是否存在指定键值的数据
* @param name 指定要检查的键值
* @return 返回键值是否存在
*
*
*
*/
has(name: string): boolean;
/**
*
* @brief 查询指定键值的值
* @param name 指定要查询的键值
* @return 返回键值所对应的值,若不存在,则返回 undefined
*
*
*
*/
get(name: string): any;
/**
*
* @brief 查询指定键值的值,若不存在或过期,则调用回调函数更新数据
* @param name 指定要查询的键值
* @param updater 指定更新函数
* @return 返回键值所对应的值
*
*
*
*/
get(name: string, updater: Function): any;
/**
*
* @brief 设定一个键值数据,键值不存在则插入一条新数据
* @param name 指定要设定的键值
* @param value 指定要设定的数据
*
*
*
*/
set(name: string, value: any): void;
/**
*
* @brief 设定一个键值数据,键值不存在则插入新数据
* @param map 指定要设定的键值数据字典
*
*
*
*/
set(map: Object): void;
/**
*
* @brief 删除指定键值的全部值
* @param name 指定要删除的键值
*
*
*
*/
remove(name: string): void;
/**
*
* @brief 检查容器是否为空
* @return 容器内无数值则返回 true
*
*
*
*/
isEmpty(): boolean;
} /** endof class */
/** } /** endof `module Or Internal Object` */
+43
View File
@@ -0,0 +1,43 @@
/***************************************************************************
* *
* This file was automatically generated with idlc.js *
* build info: *
* - fibjs : 0.25.0 *
* - date : Jun 11 2018 14:17:22 *
* *
***************************************************************************/
/**
* @author Richard <richardo2016@gmail.com>
*
*/
/// <reference path="object.d.ts" />
/** module Or Internal Object */
/**
* @brief SQL Server 数据库连接对象
* @detail 使用 db.open 或 db.openMySQL 创建,创建方式:,```JavaScript,var sql = db.openMSSQL("mssql://user:pass@host/db");,```
*/
/// <reference path="DbConnection.d.ts" />
declare class Class_MSSQL extends Class_DbConnection {
/**
*
* @brief 选择当前数据库连接的缺省数据库
* @param dbName 指定数据库名
*
*
* @async
*/
use(dbName: string): void;
} /** endof class */
/** } /** endof `module Or Internal Object` */
+69
View File
@@ -0,0 +1,69 @@
/***************************************************************************
* *
* This file was automatically generated with idlc.js *
* build info: *
* - fibjs : 0.25.0 *
* - date : Jun 11 2018 14:17:22 *
* *
***************************************************************************/
/**
* @author Richard <richardo2016@gmail.com>
*
*/
/// <reference path="object.d.ts" />
/** module Or Internal Object */
/**
* @brief 内存流对象
* @detail MemoryStream 对象创建一个基于内存的流对象,创建方法:,```JavaScript,var ms = new io.MemoryStream();,```
*/
/// <reference path="SeekableStream.d.ts" />
declare class Class_MemoryStream extends Class_SeekableStream {
/**
*
* @brief MemoryStream 构造函数
*
*
*/
constructor();
/**
*
* @brief 强制设定内存流对象的最后更新时间
* @param d 指定要设定的时间
*
*
*
*/
setTime(d: Date): void;
/**
*
* @brief 创建当前内存流的一个只读副本
* @return 返回只读的内存流对象
*
*
*
*/
clone(): Class_MemoryStream;
/**
*
* @brief 清空内存文件数据,复位指针
*
*
*/
clear(): void;
} /** endof class */
/** } /** endof `module Or Internal Object` */
+235
View File
@@ -0,0 +1,235 @@
/***************************************************************************
* *
* This file was automatically generated with idlc.js *
* build info: *
* - fibjs : 0.25.0 *
* - date : Jun 11 2018 14:17:22 *
* *
***************************************************************************/
/**
* @author Richard <richardo2016@gmail.com>
*
*/
/// <reference path="object.d.ts" />
/** module Or Internal Object */
/**
* @brief 基础消息对象
* @detail Message 对象兼容于 mq 各个模块,可用于构建自定义消息处理系统,创建方法:,```JavaScript,var mq = require("mq");,var m = new mq.Message();,```
*/
declare class Class_Message extends Class__object {
/**
* class prop
*
*
* @brief 消息的基本内容
*
*
* @type String
*/
value: string
/**
* class prop
*
*
* @brief 消息的基本参数
*
* @readonly
* @type NArray
*/
params: any[]
/**
* class prop
*
*
* @brief 消息类型
*
*
* @type Integer
*/
type: number
/**
* class prop
*
*
* @brief 查询消息的数据
*
* @readonly
* @type Value
*/
data: any
/**
* class prop
*
*
* @brief 包含消息数据部分的流对象
*
*
* @type SeekableStream
*/
body: Class_SeekableStream
/**
* class prop
*
*
* @brief 消息数据部分的长度
*
* @readonly
* @type Long
*/
length: number
/**
* class prop
*
*
* @brief 查询消息 readFrom 时的流对象
*
* @readonly
* @type Stream
*/
stream: Class_Stream
/**
* class prop
*
*
* @brief 查询和设置消息处理的最后错误
*
*
* @type String
*/
lastError: string
/**
*
* @brief 消息对象构造函数
*
*
*/
constructor();
/**
*
* @brief 从流内读取指定大小的数据,此方法为 body 相应方法的别名
* @param bytes 指定要读取的数据量,缺省为读取随机大小的数据块,读出的数据尺寸取决于设备
* @return 返回从流内读取的数据,若无数据可读,或者连接中断,则返回 null
*
*
* @async
*/
read(bytes?: number/** = -1*/): Class_Buffer;
/**
*
* @brief 从流内读取剩余的全部数据,此方法为 body 相应方法的别名
* @return 返回从流内读取的数据,若无数据可读,或者连接中断,则返回 null
*
*
* @async
*/
readAll(): Class_Buffer;
/**
*
* @brief 写入给定的数据,此方法为 body 相应方法的别名
* @param data 给定要写入的数据
*
*
* @async
*/
write(data: Class_Buffer): void;
/**
*
* @brief 以 JSON 编码写入给定的数据
* @param data 给定要写入的数据
* @return 此方法不会返回数据
*
*
*
*/
json(data: any): any;
/**
*
* @brief 以 JSON 编码解析消息中的数据
* @return 返回解析的结果
*
*
*
*/
json(): any;
/**
*
* @brief 设置当前消息处理结束,Chain 处理器不再继续后面的事务
*
*
*/
end(): void;
/**
*
* @brief 查询当前消息是否结束
* @return 结束则返回 true
*
*
*
*/
isEnded(): boolean;
/**
*
* @brief 清除消息的内容
*
*
*/
clear(): void;
/**
*
* @brief 发送格式化消息到给定的流对象
* @param stm 指定接收格式化消息的流对象
*
*
* @async
*/
sendTo(stm: Class_Stream): void;
/**
*
* @brief 从给定的缓存流对象中读取格式化消息,并解析填充对象
* @param stm 指定读取格式化消息的流对象
*
*
* @async
*/
readFrom(stm: Class_Stream): void;
} /** endof class */
/** } /** endof `module Or Internal Object` */
+227
View File
@@ -0,0 +1,227 @@
/***************************************************************************
* *
* This file was automatically generated with idlc.js *
* build info: *
* - fibjs : 0.25.0 *
* - date : Jun 11 2018 14:17:22 *
* *
***************************************************************************/
/**
* @author Richard <richardo2016@gmail.com>
*
*/
/// <reference path="object.d.ts" />
/** module Or Internal Object */
/**
* @brief mongodb 数据库数据集对象
* @detail 使用 MongoDB.getCollection 创建:,```JavaScript,var col1 = mdb.getCollection('test');,var col = mdb.test;,```
*/
declare class Class_MongoCollection extends Class__object {
/**
*
* @brief 根据给定的查询条件和返回字段设定,建立游标对象
* @param query 指定查询条件的对象
* @param projection 指定返回字段的对象
* @return 返回游标对象
*
*
*
*/
find(query?: Object/** = v8::Object::New(isolate)*/, projection?: Object/** = v8::Object::New(isolate)*/): Class_MongoCursor;
/**
*
* @brief 根据给定的查询条件和返回字段设定,查询一条结果
* @param query 指定查询条件的对象
* @param projection 指定返回字段的对象
* @return 返回第一条结果
*
*
*
*/
findOne(query?: Object/** = v8::Object::New(isolate)*/, projection?: Object/** = v8::Object::New(isolate)*/): Object;
/**
*
* @brief 查询并修改
* @param query 指定查询条件,修改数据
* @return 返回修改前的结果及其他信息
*
*
*
*/
findAndModify(query: Object): Object;
/**
*
* @brief 插入一组数据
* @param documents 指定要插入的数据数组
*
*
*
*/
insert(documents: any[]): void;
/**
*
* @brief 插入一条数据
* @param document 指定要插入的数据
*
*
*
*/
insert(document: Object): void;
/**
*
* @brief 保存一条数据,若数据包含 _id 字段,则为更新,否则为插入
* @param document 指定要保存的数据
*
*
*
*/
save(document: Object): void;
/**
*
* @brief 根据给定的查询条件更新数据
* @param query 指定查询条件的对象
* @param document 指定要更新的数据
* @param upsert 数据不存在时,插入一条新数据,缺省为 false,不插入
* @param multi 当符合条件的数据多于一条时,更新所有数据,缺省为 false,只更新第一条
*
*
*
*/
update(query: Object, document: Object, upsert?: boolean/** = false*/, multi?: boolean/** = false*/): void;
/**
*
* @brief 根据给定的查询条件更新数据
* @param query 指定查询条件的对象
* @param document 指定要更新的数据
* @param options 以对象字段传递的 upsert 和 multi 选项
*
*
*
*/
update(query: Object, document: Object, options: Object): void;
/**
*
* @brief 根据给定的查询条件删除数据
* @param query 指定查询条件的对象
*
*
*
*/
remove(query: Object): void;
/**
*
* @brief 执行数据库命令
* @param cmd 给定命令对象
* @return 返回命令返回结果
*
*
*
*/
runCommand(cmd: Object): Object;
/**
*
* @brief 执行数据库命令
* @param cmd 给定命令名称
* @param arg 给定命令参数选项
* @return 返回命令返回结果
*
*
*
*/
runCommand(cmd: string, arg?: Object/** = v8::Object::New(isolate)*/): Object;
/**
*
* @brief 删除当前集合
*
*
*/
drop(): void;
/**
*
* @brief 在当前集合上创建索引
* @param keys 给定索引字段、顺序和方向
* @param options 给定索引的选项,唯一索引等
*
*
*
*/
ensureIndex(keys: Object, options?: Object/** = v8::Object::New(isolate)*/): void;
/**
*
* @brief 重建当前集合的索引
* @return 返回命令执行结果
*
*
*
*/
reIndex(): Object;
/**
*
* @brief 删除当前集合指定名称的索引
* @param name 给定要删除的索引名称
* @return 返回命令执行结果
*
*
*
*/
dropIndex(name: string): Object;
/**
*
* @brief 删除当前集合全部索引
* @return 返回命令执行结果
*
*
*
*/
dropIndexes(): Object;
/**
*
* @brief 查询当前集合全部索引
* @return 返回包含索引的结果集
*
*
*
*/
getIndexes(): Class_MongoCursor;
/**
*
* @brief 获取当前集合子命名空间的集合对象
* @param name 子命名空间名称
* @return 返回新集合对象
*
*
*
*/
getCollection(name: string): Class_MongoCollection;
} /** endof class */
/** } /** endof `module Or Internal Object` */
+149
View File
@@ -0,0 +1,149 @@
/***************************************************************************
* *
* This file was automatically generated with idlc.js *
* build info: *
* - fibjs : 0.25.0 *
* - date : Jun 11 2018 14:17:22 *
* *
***************************************************************************/
/**
* @author Richard <richardo2016@gmail.com>
*
*/
/// <reference path="object.d.ts" />
/** module Or Internal Object */
/**
* @brief mongodb 数据库数据游标对象
* @detail
*/
declare class Class_MongoCursor extends Class__object {
/**
*
* @brief 指定返回结果时跳过的记录数
* @param num 记录数
* @return 返回游标对象本身便于链式调用
*
*
* @async
*/
skip(num: number): Class_MongoCursor;
/**
*
* @brief 指定返回结果的最大记录数
* @param size 记录数
* @return 返回游标对象本身便于链式调用
*
*
* @async
*/
limit(size: number): Class_MongoCursor;
/**
*
* @brief 设定返回结果的排序
* @param opts 指定排序条件
* @return 返回游标对象本身便于链式调用
*
*
*
*/
sort(opts: Object): Class_MongoCursor;
/**
*
* @brief 查询当前游标是否有下一条记录
* @return 有记录则返回 true
*
*
*
*/
hasNext(): boolean;
/**
*
* @brief 返回当前游标的下一条记录
* @return 记录对象,无记录则返回 null
*
*
*
*/
next(): Object;
/**
*
* @brief 查询游标的记录总数
* @param applySkipLimit 指定是否查询 skip 和 limit 后的记录数,缺省为 false,查询全部记录数
* @return 返回记录总数
*
*
*
*/
count(applySkipLimit?: boolean/** = false*/): number;
/**
*
* @brief 查询游标的记录总数,相当于 count(true)
* @return 返回记录总数
*
*
*
*/
size(): number;
/**
*
* @brief 遍历全部记录并回调处理函数
* @param func 指定处理函数
*
*
*
*/
forEach(func: Function): void;
/**
*
* @brief 遍历处理全部记录,并返回处理结果
* @param func 指定处理函数
* @return 返回处理结果数组
*
*
*
*/
map(func: Function): any[];
/**
*
* @brief 返回当前游标全部记录的数组
* @return 返回包含全部数据的 Javascript 数组
*
*
*
*/
toArray(): any[];
/**
*
* @brief 修改 mongodb 服务器缺省索引策略,使用指定的索引进行查询
* @param opts 指定强制使用的索引
* @return 返回游标对象本身便于链式调用
*
*
*
*/
hint(opts: Object): Class_MongoCursor;
} /** endof class */
/** } /** endof `module Or Internal Object` */
+86
View File
@@ -0,0 +1,86 @@
/***************************************************************************
* *
* This file was automatically generated with idlc.js *
* build info: *
* - fibjs : 0.25.0 *
* - date : Jun 11 2018 14:17:22 *
* *
***************************************************************************/
/**
* @author Richard <richardo2016@gmail.com>
*
*/
/// <reference path="object.d.ts" />
/** module Or Internal Object */
/**
* @brief mongodb 数据库连接对象
* @detail 使用 db.open 或 db.openMongoDB 创建,创建方式:,```JavaScript,var mdb = db.openMongoDB("mongodb://host/db");,```
*/
declare class Class_MongoDB extends Class__object {
/**
*
* @brief 获取指定集合访问对象
* @param name 指定集合的名称
* @return 返回指定的集合对象
*
*
*
*/
getCollection(name: string): Class_MongoCollection;
/**
*
* @brief 指定一个 MongoDB 数据库命令
* @param cmd 指定命令和参数的字典对象
* @return 返回命令执行结果
*
*
*
*/
runCommand(cmd: Object): Object;
/**
*
* @brief 指定一个简单的 MongoDB 数据库命令
* @param cmd 指定命令名
* @param arg 指定命令参数
* @return 返回命令执行结果
*
*
*
*/
runCommand(cmd: string, arg: any): Object;
/**
*
* @brief 生成一个 mongodb _objectid 对象
* @param hexStr 初始化 16 进制字符串,缺省生成新的 id
* @return 新 _objectid 对象
*
*
*
*/
oid(hexStr?: string/** = ""*/): Class_MongoID;
/**
*
* @brief 关闭当前数据库连接
*
* @async
*/
close(): void;
} /** endof class */
/** } /** endof `module Or Internal Object` */
+33
View File
@@ -0,0 +1,33 @@
/***************************************************************************
* *
* This file was automatically generated with idlc.js *
* build info: *
* - fibjs : 0.25.0 *
* - date : Jun 11 2018 14:17:22 *
* *
***************************************************************************/
/**
* @author Richard <richardo2016@gmail.com>
*
*/
/// <reference path="object.d.ts" />
/** module Or Internal Object */
/**
* @brief mongodb 数据库数据唯一标识对象,用于存储传递 oid
* @detail
*/
declare class Class_MongoID extends Class__object {
} /** endof class */
/** } /** endof `module Or Internal Object` */
+67
View File
@@ -0,0 +1,67 @@
/***************************************************************************
* *
* This file was automatically generated with idlc.js *
* build info: *
* - fibjs : 0.25.0 *
* - date : Jun 11 2018 14:17:22 *
* *
***************************************************************************/
/**
* @author Richard <richardo2016@gmail.com>
*
*/
/// <reference path="object.d.ts" />
/** module Or Internal Object */
/**
* @brief mysql 数据库连接对象
* @detail 使用 db.open 或 db.openMySQL 创建,创建方式:,```JavaScript,var msql = db.openMySQL("mysql://user:pass@host/db");,```
*/
/// <reference path="DbConnection.d.ts" />
declare class Class_MySQL extends Class_DbConnection {
/**
* class prop
*
*
* @brief 数据库连接接收缓存尺寸
*
*
* @type Integer
*/
rxBufferSize: number
/**
* class prop
*
*
* @brief 数据库连接发送缓存尺寸
*
*
* @type Integer
*/
txBufferSize: number
/**
*
* @brief 选择当前数据库连接的缺省数据库
* @param dbName 指定数据库名
*
*
* @async
*/
use(dbName: string): void;
} /** endof class */
/** } /** endof `module Or Internal Object` */
+355
View File
@@ -0,0 +1,355 @@
/***************************************************************************
* *
* This file was automatically generated with idlc.js *
* build info: *
* - fibjs : 0.25.0 *
* - date : Jun 11 2018 14:17:22 *
* *
***************************************************************************/
/**
* @author Richard <richardo2016@gmail.com>
*
*/
/// <reference path="object.d.ts" />
/** module Or Internal Object */
/**
* @brief 不对称加密算法对象
* @detail PKey 对象属于 crypto 模块,创建:,```JavaScript,var k = new crypto.PKey();,```
*/
declare class Class_PKey extends Class__object {
/**
* class prop
*
*
* @brief 返回当前算法名称
*
* @readonly
* @type String
*/
name: string
/**
* class prop
*
*
* @brief 返回当前算法密码长度,以位为单位
*
* @readonly
* @type Integer
*/
keySize: number
/**
* class prop
*
*
* @brief 返回当前密钥的公钥
* @return 当前密钥的公钥
*
*
* @readonly
* @type PKey
*/
publicKey: Class_PKey
/**
*
* @brief PKey 构造函数
*
*
*/
constructor();
/**
*
* @brief 通过 DER 格式的密钥构造 PKey
* @param DerKey DER 格式的密钥
* @param password 解密密码
*
*
*
*/
constructor(DerKey: Class_Buffer, password?: string/** = ""*/);
/**
*
* @brief 通过 PEM 格式的密钥构造 PKey
* @param pemKey PEM 格式的密钥
* @param password 解密密码
*
*
*
*/
constructor(pemKey: string, password?: string/** = ""*/);
/**
*
* @brief 通过 JSON 格式的密钥构造 PKey
*
* jsonKey 的格式支持以下四种,RSA 私钥:
* ```JavaScript
* {
* "kty": "RSA",
* "n": "0m5lvKpWqy9JS7tV2HIPqHCYHLquSuxIC3F8strIQLJKO3rZmTT96KTnhsOfBO7Y1bI7mnT0PB3_vcHd9ekWMEoZJQw7MuB8KeM_Wn54-elJr5DNLk5bMppSGxX7ZnumiXGG51_X3Yp-_EbGtDG80GxXXix7Mucyo7K25uE0uW8=",
* "e": "AQAB",
* "d": "agN2O9NxMHL1MTMi75WfL9Pxvl-KWXKqZSF6mjzAsF9iKI8euyHIXYFepzU8kual1RsjDhCnzvWqFvZplW8lXqrHf_P-rS_9Y4gBUw6pjnI_DnFIRwWHRvrUHHSCfWOdTCIKdOTkgLZuGFuhEY3RMIW0WSYejjLtftwy0RVxAzk=",
* "p": "6a4G1qmfwWmn1biigN7IVFlkbLf9oVe6g7rOmHxI-hn1GRxKDSVuAUrmR1IhuAnca9M0y7SD-7TUs6wjOxWxaw==",
* "q": "5ofkxFKdPBD0CQHMb9q13AMHUVe0rJ-hSjqqIBrmqApUOneyAcMV76M0QyIQnI2p3POa4Qu_7XChDwRVl7LlDQ==",
* "dp": "2mXGiGwCHl8j-FBWuID-1C6z-BRB3MBEVoeKPOOzxOPruatB3mWEGXsqG7A8SWgV9URxTI2K6P3J6Z7RUpBkvw==",
* "dq": "oagn5vfb5NQqnOpS9xkSsD67cfIj821ZSFlNFYhnuOzNVda7z_qCtnHm4zDPH0lEFXoKYMfBhfqWJpaugttjPQ==",
* "qi": "dqEQgxNmOVFrF4s776hTqeC6oEDila8EvpVb2F2ZvwAOLjCQ66OiAZK1BiYGHqUy0NeqNmtlsLSuBEZQZvqZwg=="
* }
* ```
* RSA 公钥:
* ```JavaScript
* {
* "kty": "RSA",
* "n": "0m5lvKpWqy9JS7tV2HIPqHCYHLquSuxIC3F8strIQLJKO3rZmTT96KTnhsOfBO7Y1bI7mnT0PB3_vcHd9ekWMEoZJQw7MuB8KeM_Wn54-elJr5DNLk5bMppSGxX7ZnumiXGG51_X3Yp-_EbGtDG80GxXXix7Mucyo7K25uE0uW8=",
* "e": "AQAB"
* }
* ```
* EC 私钥:
* ```JavaScript
* {
* "kty": "EC",
* "crv": "P-521",
* "x": "ATfNNFuuvlGxrTGoXgyfSAGgRNNDnO3rN3k74urKJdVS14RYhdnSwm91Bm-F1l-T1XKlAY2yRnzG9w1Ukvo8c0wL",
* "y": "ASBHqrruB6kdkEUB3vlW3-UIkk4HtKdUeTwN-7m3j2rgZvYR1ffRAapDvWqKGiBjomqWafxokBkbDI0c95f6f4XU",
* "d": "AfkIbUHXfW41njdpoKuqqKludcoLJS8D_oMEwkj-GVaXFNKccIoF5iKGu2c69kNDjo83R_7wyGlfRczsklkik1ST"
* }
* ```
* EC 公钥:
* ```JavaScript
* {
* "kty": "EC",
* "crv": "P-521",
* "x": "ATfNNFuuvlGxrTGoXgyfSAGgRNNDnO3rN3k74urKJdVS14RYhdnSwm91Bm-F1l-T1XKlAY2yRnzG9w1Ukvo8c0wL",
* "y": "ASBHqrruB6kdkEUB3vlW3-UIkk4HtKdUeTwN-7m3j2rgZvYR1ffRAapDvWqKGiBjomqWafxokBkbDI0c95f6f4XU"
* }
* ```
* @param jsonKey JSON 格式的密钥
*
*
*
*/
constructor(jsonKey: Object);
/**
*
* @brief 生成一个 RSA 私钥
* @param size 指定 RSA 密钥长度,bit 为单位
*
*
* @async
*/
genRsaKey(size: number): void;
/**
*
* @brief 生成一个 EC 私钥
* @param curve 指定预置椭圆曲线,可选值为:"secp521r1", "brainpoolP512r1", "secp384r1", "brainpoolP384r1", "secp256r1", "secp256k1", "brainpoolP256r1", "secp224r1", "secp224k1", "secp192r1", "secp192k1"
*
*
* @async
*/
genEcKey(curve?: string/** = "secp521r1"*/): void;
/**
*
* @brief 查询当前密钥是否为私钥
* @return 为 True 表示为私钥
*
*
*
*/
isPrivate(): boolean;
/**
*
* @brief 复制当前密钥
* @return 当前密钥的复制对象
*
*
*
*/
clone(): Class_PKey;
/**
*
* @brief 加载一个 DER 格式的密钥
* @param DerKey DER 格式的密钥
* @param password 解密密码
*
*
*
*/
importKey(DerKey: Class_Buffer, password?: string/** = ""*/): void;
/**
*
* @brief 加载一个 PEM 格式的密钥
* @param pemKey PEM 格式的密钥
* @param password 解密密码
*
*
*
*/
importKey(pemKey: string, password?: string/** = ""*/): void;
/**
*
* @brief 加载一个 JSON 格式的密钥
*
* jsonKey 的格式支持以下四种,RSA 私钥:
* ```JavaScript
* {
* "kty": "RSA",
* "n": "0m5lvKpWqy9JS7tV2HIPqHCYHLquSuxIC3F8strIQLJKO3rZmTT96KTnhsOfBO7Y1bI7mnT0PB3_vcHd9ekWMEoZJQw7MuB8KeM_Wn54-elJr5DNLk5bMppSGxX7ZnumiXGG51_X3Yp-_EbGtDG80GxXXix7Mucyo7K25uE0uW8=",
* "e": "AQAB",
* "d": "agN2O9NxMHL1MTMi75WfL9Pxvl-KWXKqZSF6mjzAsF9iKI8euyHIXYFepzU8kual1RsjDhCnzvWqFvZplW8lXqrHf_P-rS_9Y4gBUw6pjnI_DnFIRwWHRvrUHHSCfWOdTCIKdOTkgLZuGFuhEY3RMIW0WSYejjLtftwy0RVxAzk=",
* "p": "6a4G1qmfwWmn1biigN7IVFlkbLf9oVe6g7rOmHxI-hn1GRxKDSVuAUrmR1IhuAnca9M0y7SD-7TUs6wjOxWxaw==",
* "q": "5ofkxFKdPBD0CQHMb9q13AMHUVe0rJ-hSjqqIBrmqApUOneyAcMV76M0QyIQnI2p3POa4Qu_7XChDwRVl7LlDQ==",
* "dp": "2mXGiGwCHl8j-FBWuID-1C6z-BRB3MBEVoeKPOOzxOPruatB3mWEGXsqG7A8SWgV9URxTI2K6P3J6Z7RUpBkvw==",
* "dq": "oagn5vfb5NQqnOpS9xkSsD67cfIj821ZSFlNFYhnuOzNVda7z_qCtnHm4zDPH0lEFXoKYMfBhfqWJpaugttjPQ==",
* "qi": "dqEQgxNmOVFrF4s776hTqeC6oEDila8EvpVb2F2ZvwAOLjCQ66OiAZK1BiYGHqUy0NeqNmtlsLSuBEZQZvqZwg=="
* }
* ```
* RSA 公钥:
* ```JavaScript
* {
* "kty": "RSA",
* "n": "0m5lvKpWqy9JS7tV2HIPqHCYHLquSuxIC3F8strIQLJKO3rZmTT96KTnhsOfBO7Y1bI7mnT0PB3_vcHd9ekWMEoZJQw7MuB8KeM_Wn54-elJr5DNLk5bMppSGxX7ZnumiXGG51_X3Yp-_EbGtDG80GxXXix7Mucyo7K25uE0uW8=",
* "e": "AQAB"
* }
* ```
* EC 私钥:
* ```JavaScript
* {
* "kty": "EC",
* "crv": "P-521",
* "x": "ATfNNFuuvlGxrTGoXgyfSAGgRNNDnO3rN3k74urKJdVS14RYhdnSwm91Bm-F1l-T1XKlAY2yRnzG9w1Ukvo8c0wL",
* "y": "ASBHqrruB6kdkEUB3vlW3-UIkk4HtKdUeTwN-7m3j2rgZvYR1ffRAapDvWqKGiBjomqWafxokBkbDI0c95f6f4XU",
* "d": "AfkIbUHXfW41njdpoKuqqKludcoLJS8D_oMEwkj-GVaXFNKccIoF5iKGu2c69kNDjo83R_7wyGlfRczsklkik1ST"
* }
* ```
* EC 公钥:
* ```JavaScript
* {
* "kty": "EC",
* "crv": "P-521",
* "x": "ATfNNFuuvlGxrTGoXgyfSAGgRNNDnO3rN3k74urKJdVS14RYhdnSwm91Bm-F1l-T1XKlAY2yRnzG9w1Ukvo8c0wL",
* "y": "ASBHqrruB6kdkEUB3vlW3-UIkk4HtKdUeTwN-7m3j2rgZvYR1ffRAapDvWqKGiBjomqWafxokBkbDI0c95f6f4XU"
* }
* ```
* @param jsonKey JSON 格式的密钥
*
*
*
*/
importKey(jsonKey: Object): void;
/**
*
* @brief 加载一个 PEM/DER 格式的密钥文件
* @param filename 密钥文件名
* @param password 解密密码
*
*
*
*/
importFile(filename: string, password?: string/** = ""*/): void;
/**
*
* @brief 返回当前 key 的 PEM 格式编码
* @return 当前 key 的 PEM 格式编码
*
*
*
*/
exportPem(): string;
/**
*
* @brief 返回当前 key 的 DER 格式编码
* @return 当前 key 的 DER 格式编码
*
*
*
*/
exportDer(): Class_Buffer;
/**
*
* @brief 返回当前 key 的 DER 格式编码
* @return 当前 key 的 DER 格式编码
*
*
*
*/
exportJson(): Object;
/**
*
* @brief 使用当前算法密码公钥加密数据
* @param data 指定要加密的数据
* @return 返回加密后的数据
*
*
* @async
*/
encrypt(data: Class_Buffer): Class_Buffer;
/**
*
* @brief 使用当前算法密码私钥解密数据
* @param data 指定要解密的数据
* @return 返回解密后的数据
*
*
* @async
*/
decrypt(data: Class_Buffer): Class_Buffer;
/**
*
* @brief 使用当前算法密码私钥签名数据
* @param data 指定要签名的数据
* @param alg 指定要签名的算法, 默认0. 支持算法: 0=NONE,1=MD2,2=MD4,3=MD5,4=SHA1,5=SHA224,6=SHA256,7=SHA384,8=SHA512,9=RIPEMD160
* @return 返回签名后的数据
*
*
* @async
*/
sign(data: Class_Buffer, alg?: number/** = 0*/): Class_Buffer;
/**
*
* @brief 使用当前算法密码公钥验证数据
* @param data 指定要验证的数据
* @param sign 指定要验证的签名
* @param alg 指定要签名的算法, 默认0. 支持算法: 0=NONE,1=MD2,2=MD4,3=MD5,4=SHA1,5=SHA224,6=SHA256,7=SHA384,8=SHA512,9=RIPEMD160
* @return 返回验证后的结果
*
*
* @async
*/
verify(data: Class_Buffer, sign: Class_Buffer, alg?: number/** = 0*/): boolean;
} /** endof class */
/** } /** endof `module Or Internal Object` */
+576
View File
@@ -0,0 +1,576 @@
/***************************************************************************
* *
* This file was automatically generated with idlc.js *
* build info: *
* - fibjs : 0.25.0 *
* - date : Jun 11 2018 14:17:22 *
* *
***************************************************************************/
/**
* @author Richard <richardo2016@gmail.com>
*
*/
/// <reference path="object.d.ts" />
/** module Or Internal Object */
/**
* @brief Redis 数据库客户端对象
* @detail 用以创建和管理 Redis 数据库,创建方法:,```JavaScript,var db = require("db");,var test = new db.openRedis("redis-server");,```
*/
declare class Class_Redis extends Class__object {
/**
* class prop
*
*
* @brief 查询和设置错误处理函数,当 sub 出现错误或者网络中断时回调,当回调发生后,本对象的一切 sub 都将中止
*
*
*
* @type Function
*/
onsuberror: Function
/**
*
* @brief redis 基础命令方法
* @param cmd 指定发送的命令
* @param args 指定发送的参数
* @return 返回服务器返回的结果
*
*
*/
command(cmd: string, ...args: any[]): any;
/**
*
* @brief 将字符串值 value 关联到 key,如果 key 已经持有其他值, SET 就覆写旧值,无视类型
* @param key 指定要关联的 key
* @param value 指定要关联的数据
* @param ttl 以毫秒为单位为 key 设置生存时间;如果 ttl 为 0 ,那么不设置生存时间
*
*
*/
set(key: Class_Buffer, value: Class_Buffer, ttl?: number/** = 0*/): void;
/**
*
* @brief 将 key 的值设为 value ,当且仅当 key 不存在。若给定的 key 已经存在,则 SETNX 不做任何动作。
* @param key 指定要关联的 key
* @param value 指定要关联的数据
* @param ttl 以毫秒为单位为 key 设置生存时间;如果 ttl 为 0 ,那么不设置生存时间
*
*
*/
setNX(key: Class_Buffer, value: Class_Buffer, ttl?: number/** = 0*/): void;
/**
*
* @brief 将 key 的值设为 value,只在键已经存在时,才对键进行设置操作。
* @param key 指定要关联的 key
* @param value 指定要关联的数据
* @param ttl 以毫秒为单位为 key 设置生存时间;如果 ttl 为 0 ,那么不设置生存时间
*
*
*/
setXX(key: Class_Buffer, value: Class_Buffer, ttl?: number/** = 0*/): void;
/**
*
* @brief 同时设置一个或多个 key-value 对。如果某个给定 key 已经存在,那么 MSET 会用新值覆盖原来的旧值
* @param kvs 指定要设置的 key/value 对象
*
*
*/
mset(kvs: Object): void;
/**
*
* @brief 同时设置一个或多个 key-value 对。如果某个给定 key 已经存在,那么 MSET 会用新值覆盖原来的旧值
* @param kvs 指定要设置的 key/value 列表
*
*
*/
mset(...kvs: any[]): void;
/**
*
* @brief 同时设置一个或多个 key-value 对,当且仅当所有给定 key 都不存在
* @param kvs 指定要设置的 key/value 对象
*
*
*/
msetNX(kvs: Object): void;
/**
*
* @brief 同时设置一个或多个 key-value 对,当且仅当所有给定 key 都不存在
* @param kvs 指定要设置的 key/value 列表
*
*
*/
msetNX(...kvs: any[]): void;
/**
*
* @brief 如果 key 已经存在并且是一个字符串,append 命令将 value 追加到 key 原来的值的末尾。如果 key 不存在,append 就简单地将给定 key 设为 value
* @param key 指定要追加的 key
* @param value 指定要追加的数据
* @return 追加 value 之后, key 中字符串的长度
*
*
*/
append(key: Class_Buffer, value: Class_Buffer): number;
/**
*
* @brief 用 value 参数覆写给定 key 所储存的字符串值,从偏移量 offset 开始
* @param key 指定要修改的 key
* @param offset 指定修改的字节偏移
* @param value 指定要覆盖的数据
* @return 被修改之后,字符串的长度
*
*
*/
setRange(key: Class_Buffer, offset: number, value: Class_Buffer): number;
/**
*
* @brief 返回 key 中字符串值的子字符串,字符串的截取范围由 start 和 end 两个偏移量决定(包括 start 和 end 在内)
* @param key 指定要查询的 key
* @param start 指定查询的起始字节偏移
* @param end 指定查询的结束字节偏移
* @return 截取得出的子字符串
*
*
*/
getRange(key: Class_Buffer, start: number, end: number): Class_Buffer;
/**
*
* @brief 返回 key 所储存的字符串值的长度。当 key 储存的不是字符串值时,返回一个错误
* @param key 指定要计算的 key
* @return 字符串值的长度。当 key 不存在时,返回 0
*
*
*/
strlen(key: Class_Buffer): number;
/**
*
* @brief 计算给定字符串中,被设置为 1 的比特位的数量
* @param key 指定要计算的 key
* @param start 指定要计算的起始字节,可以使用负数值,-1 表示最后一个字节,而 -2 表示倒数第二个字节,以此类推
* @param end 指定要计算的结束字节,可以使用负数值,-1 表示最后一个字节,而 -2 表示倒数第二个字节,以此类推
* @return 被设置为 1 的位的数量
*
*
*/
bitcount(key: Class_Buffer, start?: number/** = 0*/, end?: number/** = -1*/): number;
/**
*
* @brief 返回 key 所关联的字符串值,如果 key 不存在那么返回特殊值 Null
* @param key 指定要关联的 key
* @return 当 key 不存在时,返回 Null ,否则,返回 key 的值
*
*
*/
get(key: Class_Buffer): Class_Buffer;
/**
*
* @brief 返回所有(一个或多个)给定 key 的值。如果给定的 key 里面,有某个 key 不存在,那么这个 key 返回特殊值 nil 。
* @param keys 指定要查询的 key 数组
* @return 一个包含所有给定 key 的值的列表
*
*
*/
mget(keys: any[]): any[];
/**
*
* @brief 返回所有(一个或多个)给定 key 的值。如果给定的 key 里面,有某个 key 不存在,那么这个 key 返回特殊值 nil 。
* @param keys 指定要查询的 key 列表
* @return 一个包含所有给定 key 的值的列表
*
*
*/
mget(...keys: any[]): any[];
/**
*
* @brief 将给定 key 的值设为 value ,并返回 key 的旧值(old value)
* @param key 指定要查询修改的 key
* @param value 指定修改的数值
* @return 返回给定 key 的旧值
*
*
*/
getset(key: Class_Buffer, value: Class_Buffer): Class_Buffer;
/**
*
* @brief 将 key 所储存的值减去减量
* @param key 指定要修改的 key
* @param num 指定要减去的数值
* @return 减去 num 之后,key 的值
*
*
*/
decr(key: Class_Buffer, num?: number/** = 1*/): number;
/**
*
* @brief 将 key 所储存的值加上增量
* @param key 指定要修改的 key
* @param num 指定要加上的数值
* @return 加上 num 之后,key 的值
*
*
*/
incr(key: Class_Buffer, num?: number/** = 1*/): number;
/**
*
* @brief 对 key 所储存的字符串值,设置或清除指定偏移量上的位(bit)
* @param key 指定要修改的 key
* @param offset 指定修改的位偏移
* @param value 指定设置或清除的参数,可以是 0 也可以是 1
* @return 指定偏移量原来储存的位
*
*
*/
setBit(key: Class_Buffer, offset: number, value: number): number;
/**
*
* @brief 对 key 所储存的字符串值,获取指定偏移量上的位(bit)
* @param key 指定要查询的 key
* @param offset 指定查询的位偏移
* @return 字符串值指定偏移量上的位(bit)
*
*
*/
getBit(key: Class_Buffer, offset: number): number;
/**
*
* @brief 检查给定 key 是否存在
* @param key 指定要关联的 key
* @return 若 key 存在,返回 True,否则返回 False
*
*
*/
exists(key: Class_Buffer): boolean;
/**
*
* @brief 返回 key 所储存的值的类型
* @param key 指定要查询的 key
* @return 返回 key 所储存的值的类型,可能的值为 none(key不存在) string(字符串) list(列表) set(集合) zset(有序集) hash(哈希表)
*
*
*/
type(key: Class_Buffer): string;
/**
*
* @brief 查找所有符合给定模式 pattern 的 key
* @param pattern 指定查询模式
* @return 符合给定模式的 key 列表
*
*
*/
keys(pattern: string): any[];
/**
*
* @brief 删除给定的一个或多个 key,不存在的 key 会被忽略
* @param keys 指定要删除的 key 数组
* @return 被删除 key 的数量
*
*
*/
del(keys: any[]): number;
/**
*
* @brief 删除给定的一个或多个 key,不存在的 key 会被忽略
* @param keys 指定要删除的 key 列表
* @return 被删除 key 的数量
*
*
*/
del(...keys: any[]): number;
/**
*
* @brief 为给定 key 设置生存时间,当 key 过期时,它会被自动删除
* @param key 指定要设定的 key
* @param ttl 以毫秒为单位为 key 设置生存时间
* @return 若 key 存在,返回 True,否则返回 False
*
*
*/
expire(key: Class_Buffer, ttl: number): boolean;
/**
*
* @brief 返回给定 key 的剩余生存时间
* @param key 指定要查询的 key
* @return 以毫秒为单位,返回 key 的剩余生存时间,当 key 不存在时,返回 -2,当 key 存在但没有设置剩余生存时间时,返回 -1
*
*
*/
ttl(key: Class_Buffer): number;
/**
*
* @brief 移除给定 key 的生存时间,将这个 key 从『易失的』(带生存时间 key )转换成『持久的』(一个不带生存时间、永不过期的 key)
* @param key 指定要设定的 key
* @return 若 key 存在,返回 True,否则返回 False
*
*
*/
persist(key: Class_Buffer): boolean;
/**
*
* @brief 将 key 改名为 newkey,当 key 和 newkey 相同,或者 key 不存在时,返回一个错误
* @param key 指定要改名的 key
* @param newkey 指定要改名的目的 key
*
*
*/
rename(key: Class_Buffer, newkey: Class_Buffer): void;
/**
*
* @brief 当且仅当 newkey 不存在时,将 key 改名为 newkey,当 key 不存在时,返回一个错误
* @param key 指定要改名的 key
* @param newkey 指定要改名的目的 key
* @return 修改成功时,返回 True,如果 newkey 已经存在,返回 False
*
*
*/
renameNX(key: Class_Buffer, newkey: Class_Buffer): boolean;
/**
*
* @brief 订阅给定的一个频道的信息,当消息发生时自动调用 func,func 包含两个参数,依次为 channel 和 message,同一频道同一函数只会回调一次
* @param channel 指定订阅的频道名称
* @param func 指定回调函数
*
*
*
*/
sub(channel: Class_Buffer, func: Function): void;
/**
*
* @brief 订阅给定的一组频道的信息,当消息发生时自动调用相应的回调函数,同一频道同一函数只会回调一次
* @param map 指定频道映射关系,对象属性名称将作为频道名称,属性的值将作为回调函数
*
*
*
*/
sub(map: Object): void;
/**
*
* @brief 退订给定的频道的全部回调
* @param channel 指定退订的频道名称
*
*
*
*/
unsub(channel: Class_Buffer): void;
/**
*
* @brief 退订给定的频道的指定回调函数
* @param channel 指定退订的频道名称
* @param func 指定退订的回调函数
*
*
*
*/
unsub(channel: Class_Buffer, func: Function): void;
/**
*
* @brief 退订一组给定的频道的全部回调
* @param channels 指定退订的频道数组
*
*
*
*/
unsub(channels: any[]): void;
/**
*
* @brief 退订给定的一组频道的指定回调函数
* @param map 指定频道映射关系,对象属性名称将作为频道名称,属性的值将作为回调函数
*
*
*
*/
unsub(map: Object): void;
/**
*
* @brief 按照模板订阅一组频道的信息,当消息发生时自动调用 func,func 包含三个参数,依次为 channel,message 和 pattern,同一模板同一函数只会回调一次
* @param pattern 指定订阅的频道模板
* @param func 指定回调函数
*
*
*
*/
psub(pattern: string, func: Function): void;
/**
*
* @brief 订阅给定的一组频道模板的信息,当消息发生时自动调用相应的 func,同一频道同一函数只会回调一次
* @param map 指定频道映射关系,对象属性名称将作为频道模板,属性的值将作为回调函数
*
*
*
*/
psub(map: Object): void;
/**
*
* @brief 退订给定模板的频道的全部回调
* @param pattern 指定退订的频道模板
*
*
*
*/
unpsub(pattern: string): void;
/**
*
* @brief 退订给定模板的频道的指定回调函数
* @param pattern 指定退订的频道模板
* @param func 指定退订的回调函数
*
*
*
*/
unpsub(pattern: string, func: Function): void;
/**
*
* @brief 退订一组给定模板的频道的全部回调
* @param patterns 指定发布的频道模板数组
*
*
*
*/
unpsub(patterns: any[]): void;
/**
*
* @brief 退订一组模板的频道的指定回调函数
* @param map 指定频道映射关系,对象属性名称将作为频道模板,属性的值将作为回调函数
*
*
*
*/
unpsub(map: Object): void;
/**
*
* @brief 将信息 message 发送到指定的频道 channel
* @param channel 指定发布的频道
* @param message 指定发布的消息
* @return 接收此消息的客户端数量
*
*
*
*/
pub(channel: Class_Buffer, message: Class_Buffer): number;
/**
*
* @brief 获取指定 key 的 Hash 对象,此对象为包含指定 key 的客户端,只有调用其方法才会操作数据库
* @param key 指定要获取的 key
* @return 返回包含指定 key 的 Hash 对象
*
*
*/
getHash(key: Class_Buffer): Class_RedisHash;
/**
*
* @brief 获取指定 key 的 List 对象,此对象为包含指定 key 的客户端,只有调用其方法才会操作数据库
* @param key 指定要获取的 key
* @return 返回包含指定 key 的 List 对象
*
*
*/
getList(key: Class_Buffer): Class_RedisList;
/**
*
* @brief 获取指定 key 的 Set 对象,此对象为包含指定 key 的客户端,只有调用其方法才会操作数据库
* @param key 指定要获取的 key
* @return 返回包含指定 key 的 Set 对象
*
*
*/
getSet(key: Class_Buffer): Class_RedisSet;
/**
*
* @brief 获取指定 key 的 SortedSet 对象,此对象为包含指定 key 的客户端,只有调用其方法才会操作数据库
* @param key 指定要获取的 key
* @return 返回包含指定 key 的 SortedSet 对象
*
*
*/
getSortedSet(key: Class_Buffer): Class_RedisSortedSet;
/**
*
* @brief 序列化给定 key ,并返回被序列化的值,使用 restore 命令可以将这个值反序列化为 Redis 键
* @param key 指定要序列化的 key
* @return 返回序列化之后的值,如果 key 不存在,那么返回 null
*
*
*/
dump(key: Class_Buffer): Class_Buffer;
/**
*
* @brief 反序列化给定的序列化值,并将它和给定的 key 关联
* @param key 指定要反序列化的 key
* @param data 指定要反序列化的数据
* @param ttl 以毫秒为单位为 key 设置生存时间;如果 ttl 为 0 ,那么不设置生存时间
*
*
*/
restore(key: Class_Buffer, data: Class_Buffer, ttl?: number/** = 0*/): void;
/**
*
* @brief 关闭当前数据库连接或事务
*
*
*/
close(): void;
} /** endof class */
/** } /** endof `module Or Internal Object` */
+169
View File
@@ -0,0 +1,169 @@
/***************************************************************************
* *
* This file was automatically generated with idlc.js *
* build info: *
* - fibjs : 0.25.0 *
* - date : Jun 11 2018 14:17:22 *
* *
***************************************************************************/
/**
* @author Richard <richardo2016@gmail.com>
*
*/
/// <reference path="object.d.ts" />
/** module Or Internal Object */
/**
* @brief Redis 数据库客户端 Hash 对象,此对象为包含指定 key 的客户端,只有调用其方法才会操作数据库
* @detail 用以操作 Redis 的 Hash 对象,创建方法:,```JavaScript,var db = require("db");,var rdb = new db.openRedis("redis-server");,var hash = rdb.getHash("test");,```
*/
declare class Class_RedisHash extends Class__object {
/**
*
* @brief 将哈希表中的域 field 的值设为 value,如果域 field 已经存在于哈希表中,旧值将被覆盖
* @param field 指定要修改的 field
* @param value 指定要修改的数据
*
*
*/
set(field: Class_Buffer, value: Class_Buffer): void;
/**
*
* @brief 将哈希表中的域 field 的值设置为 value ,当且仅当域 field 不存在。若域 field 已经存在,该操作无效
* @param field 指定要修改的 field
* @param value 指定要修改的数据
*
*
*/
setNX(field: Class_Buffer, value: Class_Buffer): void;
/**
*
* @brief 同时将多个 field-value (域-值)对设置到哈希表中,此命令会覆盖哈希表中已存在的域
* @param kvs 指定要设置的 field/value 对象
*
*
*/
mset(kvs: Object): void;
/**
*
* @brief 同时将多个 field-value (域-值)对设置到哈希表中,此命令会覆盖哈希表中已存在的域
* @param kvs 指定要设置的 field/value 列表
*
*
*/
mset(...kvs: any[]): void;
/**
*
* @brief 返回哈希表中给定域 field 的值
* @param field 指定要查询的 field
* @return 给定域的值,当给定域不存在或是给定 key 不存在时,返回 null
*
*
*/
get(field: Class_Buffer): Class_Buffer;
/**
*
* @brief 返回哈希表中,一个或多个给定域的值
* @param fields 指定要查询的域数组
* @return 一个包含所有给定域的值的列表
*
*
*/
mget(fields: any[]): any[];
/**
*
* @brief 返回哈希表中,一个或多个给定域的值
* @param fields 指定要查询的域列表
* @return 一个包含所有给定域的值的列表
*
*
*/
mget(...fields: any[]): any[];
/**
*
* @brief 将域所储存的值加上增量
* @param field 指定要修改的域
* @param num 指定要加上的数值
* @return 加上 num 之后,域的值
*
*
*/
incr(field: Class_Buffer, num?: number/** = 1*/): number;
/**
*
* @brief 返回哈希表中,所有的域和值
* @return 返回一个包含哈希表中所有域的列表
*
*
*/
getAll(): any[];
/**
*
* @brief 返回哈希表中的所有域
* @return 返回值里,紧跟每个域名(field name)之后是域的值(value),所以返回值的长度是哈希表大小的两倍
*
*
*/
keys(): any[];
/**
*
* @brief 返回哈希表中域的数量
* @return 返回哈希表中域的数量
*
*
*/
len(): number;
/**
*
* @brief 查看哈希表中,给定域 field 是否存在
* @param field 指定要查询的 field
* @return 如果哈希表含有给定域,返回 true,如果哈希表不含有给定域,或 key 不存在,返回 false
*
*
*/
exists(field: Class_Buffer): boolean;
/**
*
* @brief 删除哈希表中的一个或多个指定域,不存在的域将被忽略
* @param fields 指定要删除的域数组
* @return 被删除域的数量
*
*
*/
del(fields: any[]): number;
/**
*
* @brief 删除哈希表中的一个或多个指定域,不存在的域将被忽略
* @param fields 指定要删除的域列表
* @return 被删除域的数量
*
*
*/
del(...fields: any[]): number;
} /** endof class */
/** } /** endof `module Or Internal Object` */
+174
View File
@@ -0,0 +1,174 @@
/***************************************************************************
* *
* This file was automatically generated with idlc.js *
* build info: *
* - fibjs : 0.25.0 *
* - date : Jun 11 2018 14:17:22 *
* *
***************************************************************************/
/**
* @author Richard <richardo2016@gmail.com>
*
*/
/// <reference path="object.d.ts" />
/** module Or Internal Object */
/**
* @brief Redis 数据库客户端 List 对象,此对象为包含指定 key 的客户端,只有调用其方法才会操作数据库
* @detail 用以操作 Redis 的 List 对象,创建方法:,```JavaScript,var db = require("db");,var rdb = new db.openRedis("redis-server");,var list = rdb.getList("test");,```
*/
declare class Class_RedisList extends Class__object {
/**
*
* @brief 将一个或多个值 value 插入到列表的表头
* @param values 指定要插入的数据
* @return 插入后,列表的长度
*
*
*/
push(values: any[]): number;
/**
*
* @brief 将一个或多个值 value 插入到列表的表头
* @param values 指定要插入的数据
* @return 插入后,列表的长度
*
*
*/
push(...values: any[]): number;
/**
*
* @brief 移除并返回列表 key 的头元素
* @return 列表的头元素,如果列表为空则返回 null
*
*
*/
pop(): Class_Buffer;
/**
*
* @brief 将一个或多个值 value 插入到列表的表尾(最右边)
* @param values 指定要插入的数据
* @return 插入后,列表的长度
*
*
*/
rpush(values: any[]): number;
/**
*
* @brief 将一个或多个值 value 插入到列表的表尾(最右边)
* @param values 指定要插入的数据
* @return 插入后,列表的长度
*
*
*/
rpush(...values: any[]): number;
/**
*
* @brief 移除并返回列表 key 的表尾(最右边)元素
* @return 列表的头元素,如果列表为空则返回 null
*
*
*/
rpop(): Class_Buffer;
/**
*
* @brief 将列表下标为 index 的元素的值设置为 value
* @param index 指定要修改的下标
* @param value 指定要修改的数据
*
*
*/
set(index: number, value: Class_Buffer): void;
/**
*
* @brief 返回列表中,下标为 index 的元素
* @param index 指定要查询的下标
* @return 列表中下标为 index 的元素
*
*
*/
get(index: number): Class_Buffer;
/**
*
* @brief 将值 value 插入到列表当中,位于值 pivot 之前
* @param pivot 指定插入时查找的数据
* @param value 指定要插入的数据
* @return 插入后,列表的长度
*
*
*/
insertBefore(pivot: Class_Buffer, value: Class_Buffer): number;
/**
*
* @brief 将值 value 插入到列表当中,位于值 pivot 之后
* @param pivot 指定插入时查找的数据
* @param value 指定要插入的数据
* @return 插入后,列表的长度
*
*
*/
insertAfter(pivot: Class_Buffer, value: Class_Buffer): number;
/**
*
* @brief 根据参数 count 的值,移除列表中与参数 value 相等的元素
* @param count 指定删除的元素数量
* @param value 指定要删除的数值
* @return 被移除元素的数量
*
*
*/
remove(count: number, value: Class_Buffer): number;
/**
*
* @brief 对一个列表进行修剪(trim),就是说,让列表只保留指定区间内的元素,不在指定区间之内的元素都将被删除
* @param start 指定修剪的起始下标,0 表示第一个元素,-1 表示最后一个元素
* @param stop 指定修剪的结束下标,0 表示第一个元素,-1 表示最后一个元素
*
*
*/
trim(start: number, stop: number): void;
/**
*
* @brief 返回列表的长度
* @return 返回列表的长度
*
*
*/
len(): number;
/**
*
* @brief 返回列表中指定区间内的元素,区间以偏移量 start 和 stop 指定,包含 start 和 stop 的元素
* @param start 指定查询的起始下标,0 表示第一个元素,-1 表示最后一个元素
* @param stop 指定查询的结束下标,0 表示第一个元素,-1 表示最后一个元素
* @return 包含指定区间内的元素的数组
*
*
*/
range(start: number, stop: number): any[];
} /** endof class */
/** } /** endof `module Or Internal Object` */
+129
View File
@@ -0,0 +1,129 @@
/***************************************************************************
* *
* This file was automatically generated with idlc.js *
* build info: *
* - fibjs : 0.25.0 *
* - date : Jun 11 2018 14:17:22 *
* *
***************************************************************************/
/**
* @author Richard <richardo2016@gmail.com>
*
*/
/// <reference path="object.d.ts" />
/** module Or Internal Object */
/**
* @brief Redis 数据库客户端 Set 对象,此对象为包含指定 key 的客户端,只有调用其方法才会操作数据库
* @detail 用以操作 Redis 的 Set 对象,创建方法:,```JavaScript,var db = require("db");,var rdb = new db.openRedis("redis-server");,var set = rdb.getSet("test");,```
*/
declare class Class_RedisSet extends Class__object {
/**
*
* @brief 将一个或多个 member 元素加入到集合 key 当中,已经存在于集合的 member 元素将被忽略
* @param members 指定要添加的元素数组
* @return 被添加到集合中的新元素的数量,不包括被忽略的元素
*
*
*/
add(members: any[]): number;
/**
*
* @brief 同时将多个 field-value (域-值)对设置到哈希表中,此命令会覆盖哈希表中已存在的域
* @param members 指定要添加的元素列表
* @return 被添加到集合中的新元素的数量,不包括被忽略的元素
*
*
*/
add(...members: any[]): number;
/**
*
* @brief 移除集合中的一个或多个 member 元素
* @param members 指定要移除的元素数组
* @return 被成功移除的元素的数量,不包括被忽略的元素
*
*
*/
remove(members: any[]): number;
/**
*
* @brief 移除集合中的一个或多个 member 元素
* @param members 指定要移除的元素列表
* @return 被成功移除的元素的数量,不包括被忽略的元素
*
*
*/
remove(...members: any[]): number;
/**
*
* @brief 返回集合中元素的数量
* @return 返回集合的长度
*
*
*/
len(): number;
/**
*
* @brief 判断 member 元素是否集合的成员
* @param member 指定检查的 member
* @return 如果 member 元素是集合的成员,返回 true
*
*
*/
exists(member: Class_Buffer): boolean;
/**
*
* @brief 返回集合中的所有成员
* @return 集合中所有成员的列表
*
*
*/
members(): any[];
/**
*
* @brief 移除并返回集合中的一个随机元素
* @return 被移除的随机元素。当集合是空集时,返回 null
*
*
*/
pop(): Class_Buffer;
/**
*
* @brief 从集合中获取随机的一个元素
* @return 返回一个元素;如果集合为空,返回 null
*
*
*/
randMember(): any;
/**
*
* @brief 从集合中获取随机的若干元素
* @param count 指定返回的元素个数。正数,返回一个包含 count 个元素的数组;负数,返回一个数组,数组中的元素可能会重复出现多次,而数组的长度为 count 的绝对值
* @return 返回一个列表;如果集合为空,返回空列表
*
*
*/
randMember(count: number): any;
} /** endof class */
/** } /** endof `module Or Internal Object` */
+158
View File
@@ -0,0 +1,158 @@
/***************************************************************************
* *
* This file was automatically generated with idlc.js *
* build info: *
* - fibjs : 0.25.0 *
* - date : Jun 11 2018 14:17:22 *
* *
***************************************************************************/
/**
* @author Richard <richardo2016@gmail.com>
*
*/
/// <reference path="object.d.ts" />
/** module Or Internal Object */
/**
* @brief Redis 数据库客户端 SortedSet 对象,此对象为包含指定 key 的客户端,只有调用其方法才会操作数据库
* @detail 用以操作 Redis 的 SortedSet 对象,创建方法:,```JavaScript,var db = require("db");,var rdb = new db.openRedis("redis-server");,var set = rdb.getSortedSet("test");,```
*/
declare class Class_RedisSortedSet extends Class__object {
/**
*
* @brief 将一个或多个 member 元素及其 score 值加入到有序集当中
* @param sms 指定要添加的 member/score 对象
* @return 被成功添加的新成员的数量,不包括那些被更新的、已经存在的成员
*
*
*/
add(sms: Object): number;
/**
*
* @brief 将一个或多个 member 元素及其 score 值加入到有序集当中
* @param sms 指定要添加的 member/score 列表
* @return 被成功添加的新成员的数量,不包括那些被更新的、已经存在的成员
*
*
*/
add(...sms: any[]): number;
/**
*
* @brief 返回有序集中,成员 member 的 score 值
* @param member 指定要查询的 member
* @return member 成员的 score 值,以字符串形式表示
*
*
*/
score(member: Class_Buffer): Class_Buffer;
/**
*
* @brief 为有序集的成员 member 的 score 值加上增量 num
* @param member 指定要修改的 member
* @param num 指定要加上的数值
* @return member 成员的新 score 值,以字符串形式表示
*
*
*/
incr(member: Class_Buffer, num?: number/** = 1*/): Class_Buffer;
/**
*
* @brief 移除有序集中的一个或多个 member 元素
* @param members 指定要移除的元素数组
* @return 被成功移除的元素的数量,不包括被忽略的元素
*
*
*/
remove(members: any[]): number;
/**
*
* @brief 移除有序集中的一个或多个 member 元素
* @param members 指定要移除的元素列表
* @return 被成功移除的元素的数量,不包括被忽略的元素
*
*
*/
remove(...members: any[]): number;
/**
*
* @brief 返回有序集中元素的数量
* @return 返回有序集的长度
*
*
*/
len(): number;
/**
*
* @brief 返回有序集中, score 值在 min 和 max 之间(默认包括 score 值等于 min 或 max )的成员的数量
* @param min 指定统计的最小 score
* @param max 指定统计的最大 score
* @return score 值在 min 和 max 之间的成员的数量
*
*
*/
count(min: number, max: number): number;
/**
*
* @brief 返回有序集中,指定区间内的成员,成员的位置按 score 值递增(从小到大)来排序
* @param start 指定查询的起始下标,0 表示第一个元素,-1 表示最后一个元素
* @param stop 指定查询的结束下标,0 表示第一个元素,-1 表示最后一个元素
* @param withScores 指定是否在结果中包含 score
* @return 指定区间内,带有 score 值(可选)的有序集成员的列表
*
*
*/
range(start: number, stop: number, withScores?: boolean/** = false*/): any[];
/**
*
* @brief 返回有序集中,指定区间内的成员,成员的位置按 score 值递减(从大到小)来排序
* @param start 指定查询的起始下标,0 表示第一个元素,-1 表示最后一个元素
* @param stop 指定查询的结束下标,0 表示第一个元素,-1 表示最后一个元素
* @param withScores 指定是否在结果中包含 score
* @return 指定区间内,带有 score 值(可选)的有序集成员的列表
*
*
*/
rangeRev(start: number, stop: number, withScores?: boolean/** = false*/): any[];
/**
*
* @brief 有序集中成员 member 的排名。其中有序集成员按 score 值递增(从小到大)顺序排列
* @param member 指定要查询的 member
* @return member 如果 member 是有序集 key 的成员,返回 member 的排名。如果 member 不是有序集 key 的成员,返回 nil
*
*
*/
rank(member: Class_Buffer): number;
/**
*
* @brief 有序集中成员 member 的排名。其中有序集成员按 score 值递减(从大到小)顺序排列
* @param member 指定要查询的 member
* @return member 如果 member 是有序集 key 的成员,返回 member 的排名。如果 member 不是有序集 key 的成员,返回 nil
*
*
*/
rankRev(member: Class_Buffer): number;
} /** endof class */
/** } /** endof `module Or Internal Object` */
+262
View File
@@ -0,0 +1,262 @@
/***************************************************************************
* *
* This file was automatically generated with idlc.js *
* build info: *
* - fibjs : 0.25.0 *
* - date : Jun 11 2018 14:17:22 *
* *
***************************************************************************/
/**
* @author Richard <richardo2016@gmail.com>
*
*/
/// <reference path="object.d.ts" />
/** module Or Internal Object */
/**
* @brief 消息处理器路由对象
* @detail 路由对象是 http 消息处理的核心对象,服务器根据路由的设定,匹配 url 和 method,并将 http 消息转发到相应的处理器,以完成不同的事务。,,一个简单的路由,可以直接以 JSON 对象的形式提供,比如:,```JavaScript,var http = require('http');,,var svr = new http.Server(8080, {, '/': r => r.response.write('home'),, '/help': r => r.response.write('help'),});,,svr.run();,```,如果需要更复杂的路由定制,可以自行创建 Routing 对象并根据需要处理路由策略:,```JavaScript,var http = require('http');,var mq = require('mq');,,var app = new mq.Routing();,,app.get('/', r => r.response.write('home'));,app.get('/help', r => r.response.write('help'));,,app.post('/help', r => r.response.write('post a help.'));,,app.get('/home/:user', (r, user) => r.response.write('hello ' + user));,,app.get('/user/:id(\\d+)', (r, id) => r.response.write('get ' + id));,,app.get('/actions', {, '/run': r => r.response.write('running'),, '/sleep': r => r.response.write('sleeping'),, '(.*)': r => r.response.write('........'),});,,var svr = new http.Server(8080, app);,svr.run();,```,路由对象根据设定的规则匹配消息,将消息传递给符合规则的第一个处理器。后加入的路由规则优先匹配。创建方法:,```JavaScript,var routing = new mq.Routing({, "^/func1(/.*)$": func1,, "^/func2(/.*)$": func2,});,```,正则表达式匹配的项目修改消息的 value 属性,子项目存入消息的 params 属性。例如:,```JavaScript,var routing = new mq.Routing({, "^/func1(/([0-9]+)/([0-9]+)\.html)$": func1,,});,```,匹配消息 "/func1/123/456.html" 后,value == "/123/456.html",params == ["123", "456"];,,如果匹配的结果没有子项,则 value 为空,params 为空。例如:,```JavaScript,var routing = new mq.Routing({, "^/func1/[0-9]+/[0-9]+\.html$": func1,,});,```,匹配消息 "/func1/123/456.html" 后,value == "",params == [];,,如果匹配的结果第一级有多个子项,则 value 为空,params 为第一级子项。例如:,```JavaScript,var routing = new mq.Routing({, "^/func1/([0-9]+)/([0-9]+)\.html$": func1,,});,```,匹配消息 "/func1/123/456.html" 后,value == "",params == ["123", "456"];,,如果匹配的结果只有一个子项,并且无下级子项,则 value 和 params 均为此子项。例如:,```JavaScript,var routing = new mq.Routing({, "^/func1/([0-9]+)/[0-9]+\.html$": func1,,});,```,匹配消息 "/func1/123/456.html" 后,value == "123",params == ["123"];
*/
/// <reference path="Handler.d.ts" />
declare class Class_Routing extends Class_Handler {
/**
*
* @brief 创建一个消息处理器路由对象
* @param map 初始化路由参数
*
*
*
*/
constructor(map?: Object/** = v8::Object::New(isolate)*/);
/**
*
* @brief 创建一个消息处理器路由对象
* @param method 指定 http 请求方法,"*" 接受所有方法
* @param map 初始化路由参数
*
*
*
*/
constructor(method: string, map: Object);
/**
*
* @brief 从已有路由对象中添加规则,添加后原路由将被清空
* @param route 已经初始化的路由对象
* @return 返回路由对象本身
*
*
*
*/
append(route: Class_Routing): Class_Routing;
/**
*
* @brief 添加一组路由规则
* @param map 路由参数
* @return 返回路由对象本身
*
*
*
*/
append(map: Object): Class_Routing;
/**
*
* @brief 添加一条路由规则
* @param pattern 消息匹配格式
* @param hdlr 内置消息处理器,处理函数,链式处理数组,路由对象,详见 mq.Handler
* @return 返回路由对象本身
*
*
*
*/
append(pattern: string, hdlr: Class_Handler): Class_Routing;
/**
*
* @brief 添加一条路由规则
* @param method 指定 http 请求方法,"*" 接受所有方法
* @param pattern 消息匹配格式
* @param hdlr 内置消息处理器,处理函数,链式处理数组,路由对象,详见 mq.Handler
* @return 返回路由对象本身
*
*
*
*/
append(method: string, pattern: string, hdlr: Class_Handler): Class_Routing;
/**
*
* @brief 添加一组接受所有 http 方法路由规则
* @param map 路由参数
* @return 返回路由对象本身
*
*
*
*/
all(map: Object): Class_Routing;
/**
*
* @brief 添加一条接受所有 http 方法路由规则
* @param pattern 消息匹配格式
* @param hdlr 内置消息处理器,处理函数,链式处理数组,路由对象,详见 mq.Handler
* @return 返回路由对象本身
*
*
*
*/
all(pattern: string, hdlr: Class_Handler): Class_Routing;
/**
*
* @brief 添加一组 GET 方法路由规则
* @param map 路由参数
* @return 返回路由对象本身
*
*
*
*/
get(map: Object): Class_Routing;
/**
*
* @brief 添加一条接受 http GET 方法路由规则
* @param pattern 消息匹配格式
* @param hdlr 内置消息处理器,处理函数,链式处理数组,路由对象,详见 mq.Handler
* @return 返回路由对象本身
*
*
*
*/
get(pattern: string, hdlr: Class_Handler): Class_Routing;
/**
*
* @brief 添加一组接受 http POST 方法路由规则
* @param map 路由参数
* @return 返回路由对象本身
*
*
*
*/
post(map: Object): Class_Routing;
/**
*
* @brief 添加一条接受 http POST 方法路由规则
* @param pattern 消息匹配格式
* @param hdlr 内置消息处理器,处理函数,链式处理数组,路由对象,详见 mq.Handler
* @return 返回路由对象本身
*
*
*
*/
post(pattern: string, hdlr: Class_Handler): Class_Routing;
/**
*
* @brief 添加一组接受 http DELETE 方法路由规则
* @param map 路由参数
* @return 返回路由对象本身
*
*
*
*/
del(map: Object): Class_Routing;
/**
*
* @brief 添加一条接受 http DELETE 方法路由规则
* @param pattern 消息匹配格式
* @param hdlr 内置消息处理器,处理函数,链式处理数组,路由对象,详见 mq.Handler
* @return 返回路由对象本身
*
*
*
*/
del(pattern: string, hdlr: Class_Handler): Class_Routing;
/**
*
* @brief 添加一组 PUT 方法路由规则
* @param map 路由参数
* @return 返回路由对象本身
*
*
*
*/
put(map: Object): Class_Routing;
/**
*
* @brief 添加一条接受 http PUT 方法路由规则
* @param pattern 消息匹配格式
* @param hdlr 内置消息处理器,处理函数,链式处理数组,路由对象,详见 mq.Handler
* @return 返回路由对象本身
*
*
*
*/
put(pattern: string, hdlr: Class_Handler): Class_Routing;
/**
*
* @brief 添加一组 PATCH 方法路由规则
* @param map 路由参数
* @return 返回路由对象本身
*
*
*
*/
patch(map: Object): Class_Routing;
/**
*
* @brief 添加一条接受 http PATCH 方法路由规则
* @param pattern 消息匹配格式
* @param hdlr 内置消息处理器,处理函数,链式处理数组,路由对象,详见 mq.Handler
* @return 返回路由对象本身
*
*
*
*/
patch(pattern: string, hdlr: Class_Handler): Class_Routing;
/**
*
* @brief 添加一组 FIND 方法路由规则
* @param map 路由参数
* @return 返回路由对象本身
*
*
*
*/
find(map: Object): Class_Routing;
/**
*
* @brief 添加一条接受 http FIND 方法路由规则
* @param pattern 消息匹配格式
* @param hdlr 内置消息处理器,处理函数,链式处理数组,路由对象,详见 mq.Handler
* @return 返回路由对象本身
*
*
*
*/
find(pattern: string, hdlr: Class_Handler): Class_Routing;
} /** endof class */
/** } /** endof `module Or Internal Object` */
+66
View File
@@ -0,0 +1,66 @@
/***************************************************************************
* *
* This file was automatically generated with idlc.js *
* build info: *
* - fibjs : 0.25.0 *
* - date : Jun 11 2018 14:17:22 *
* *
***************************************************************************/
/**
* @author Richard <richardo2016@gmail.com>
*
*/
/// <reference path="object.d.ts" />
/** module Or Internal Object */
/**
* @brief sqlite 数据库连接对象
* @detail 使用 db.open 或 db.openSQLite 创建,创建方式:,```JavaScript,var slite = db.openSQLite("sqlite:/path/to/db");,```
*/
/// <reference path="DbConnection.d.ts" />
declare class Class_SQLite extends Class_DbConnection {
/**
* class prop
*
*
* @brief 当前数据库文件名
*
* @readonly
* @type String
*/
fileName: string
/**
* class prop
*
*
* @brief 查询和设置数据库超时时间,以毫秒为单位
*
*
* @type Integer
*/
timeout: number
/**
*
* @brief 备份当前数据库到新文件
* @param fileName 指定备份的数据库文件名
*
* @async
*/
backup(fileName: string): void;
} /** endof class */
/** } /** endof `module Or Internal Object` */
+177
View File
@@ -0,0 +1,177 @@
/***************************************************************************
* *
* This file was automatically generated with idlc.js *
* build info: *
* - fibjs : 0.25.0 *
* - date : Jun 11 2018 14:17:22 *
* *
***************************************************************************/
/**
* @author Richard <richardo2016@gmail.com>
*
*/
/// <reference path="object.d.ts" />
/** module Or Internal Object */
/**
* @brief 安全沙箱对象,用于管理一个独立的运行空间
* @detail 所有的代码都运行在自己的沙箱中,全局的 require 会调用当前沙箱加载模块,沙箱会通过 require 传递给加载的沙箱。下面的示例创建一个沙箱,限制只允许访问全局基础模块中的 assert 模块,并添加 a 和 b 两个定制模块:,```JavaScript,var vm = require('vm');,var sbox = new vm.SandBox({, a: 100,, b: 200,, assert: require('assert'),});,,var mod_in_sbox = sbox.require('./path/to/mod');,```
*/
declare class Class_SandBox extends Class__object {
/**
* class prop
*
*
* @brief 查询沙箱的 global 对象
*
* @readonly
* @type Object
*/
global: Object
/**
*
* @brief 构造一个新的安全沙箱对象,并初始化基础模块
* @param mods 指定要添加的模块对象字典
*
*
*
*/
constructor(mods: Object);
/**
*
* @brief 构造一个新的安全沙箱对象,并初始化基础模块
* @param mods 指定要添加的模块对象字典
* @param require 自定义 require 函数,当模块不存在时,先调用自定义函数,无返回再从文件中加载
*
*
*
*/
constructor(mods: Object, require: Function);
/**
*
* @brief 构造一个独立 Global 新的安全沙箱对象,并初始化基础模块
* @param mods 指定要添加的模块对象字典
* @param global 指定初始化的 Global 属性
*
*
*
*/
constructor(mods: Object, global: Object);
/**
*
* @brief 构造一个独立 Global 新的安全沙箱对象,并初始化基础模块
* @param mods 指定要添加的模块对象字典
* @param require 自定义 require 函数,当模块不存在时,先调用自定义函数,无返回再从文件中加载
* @param global 指定初始化的 Global 属性
*
*
*
*/
constructor(mods: Object, require: Function, global: Object);
/**
*
* @brief 向沙箱中添加一个基础模块
* @param id 指定要添加的模块名称,此路径与当前运行脚本无关,必须为绝对路径或者模块名
* @param mod 指定要添加的模块对象
*
*
*
*/
add(id: string, mod: any): void;
/**
*
* @brief 向沙箱中添加一组基础模块
* @param mods 指定要添加的模块对象字典,添加的 javascript 模块将会生成一份复制,以避免沙箱修改对象产生互相干扰
*
*
*
*/
add(mods: Object): void;
/**
*
* @brief 向沙箱中添加一个脚本模块
* @param srcname 指定要添加的脚本名称,srcname 必须包含扩展名,比如 json 或者 js, jsc
* @param script 指定要添加的二进制代码
* @return 返回加载的模块对象
*
*
*
*/
addScript(srcname: string, script: Class_Buffer): any;
/**
*
* @brief 从沙箱中删除指定的基础模块
* @param id 指定要删除的模块名称,此路径与当前运行脚本无关,必须为绝对路径或者模块名
*
*
*
*/
remove(id: string): void;
/**
*
* @brief 复制当前沙箱,新沙箱包含当前沙箱的模块,以及相同的名称和 require 函数
* @return 复制的新沙箱
*
*
*
*/
clone(): Class_SandBox;
/**
*
* @brief 运行一个脚本
* @param fname 指定要运行的脚本路径,此路径与当前运行脚本无关,必须为绝对路径
* @param argv 指定要运行的参数,此参数可在脚本内使用 argv 获取
*
*
*
*/
run(fname: string, argv?: any[]/** = v8::Array::New(isolate)*/): void;
/**
*
* @brief 查询一个模块并返回模块完整文件名
* @param id 指定要加载的模块名称
* @param base 指定查找路径
* @return 返回加载的模块完整文件名
*
*
*
*/
resolve(id: string, base: string): string;
/**
*
* @brief 加载一个模块并返回模块对象
* @param id 指定要加载的模块名称
* @param base 指定查找路径
* @return 返回加载的模块对象
*
*
*
*/
require(id: string, base: string): any;
} /** endof class */
/** } /** endof `module Or Internal Object` */
+112
View File
@@ -0,0 +1,112 @@
/***************************************************************************
* *
* This file was automatically generated with idlc.js *
* build info: *
* - fibjs : 0.25.0 *
* - date : Jun 11 2018 14:17:22 *
* *
***************************************************************************/
/**
* @author Richard <richardo2016@gmail.com>
*
*/
/// <reference path="object.d.ts" />
/** module Or Internal Object */
/**
* @brief 可移动当前指针的流对象接口
* @detail
*/
/// <reference path="Stream.d.ts" />
declare class Class_SeekableStream extends Class_Stream {
/**
*
* @brief 移动文件当前操作位置
* @param offset 指定新的位置
* @param whence 指定位置基准,允许的值为:SEEK_SET, SEEK_CUR, SEEK_END
*
*
*
*/
seek(offset: number, whence: number): void;
/**
*
* @brief 查询流当前位置
* @return 返回流当前位置
*
*
*
*/
tell(): number;
/**
*
* @brief 移动当前位置到流开头
*
*
*/
rewind(): void;
/**
*
* @brief 查询流尺寸
* @return 返回流尺寸
*
*
*
*/
size(): number;
/**
*
* @brief 从流内读取剩余的全部数据
* @return 返回从流内读取的数据,若无数据可读,或者连接中断,则返回 null
*
*
* @async
*/
readAll(): Class_Buffer;
/**
*
* @brief 修改文件尺寸,如果新尺寸小于原尺寸,则文件被截断
* @param bytes 新的文件尺寸
*
*
* @async
*/
truncate(bytes: number): void;
/**
*
* @brief 查询文件是否到结尾
* @return 返回 True 表示结尾
*
*
*
*/
eof(): boolean;
/**
*
* @brief 查询当前文件的基础信息
* @return 返回 Stat 对象描述文件信息
*
*
* @async
*/
stat(): Class_Stat;
} /** endof class */
/** } /** endof `module Or Internal Object` */
+69
View File
@@ -0,0 +1,69 @@
/***************************************************************************
* *
* This file was automatically generated with idlc.js *
* build info: *
* - fibjs : 0.25.0 *
* - date : Jun 11 2018 14:17:22 *
* *
***************************************************************************/
/**
* @author Richard <richardo2016@gmail.com>
*
*/
/// <reference path="object.d.ts" />
/** module Or Internal Object */
/**
* @brief 纤程信号量对象
* @detail 信号量对象管理一个内部计数器,此计数器调用 acquire 或者 wait 后减一,调用 release 或者 post 后加一。,计数器不会减至负数,因为 acquire 和 wait 在发现数值为 0 的时候,会休眠当前纤程,直至其它纤程通过 release 或 post 增加计数器的值。,,信号量常用的场合是限制资源并发使用,以及生产者/消费者模式的应用。,,以数据库请求为例,限制资源并发使用的情形:,```JavaScript,var maxconnections = 5;,var l = new coroutine.Semaphore(maxconnections);,,......,,l.acquire();,var conn = connectdb(),.....,conn.close();,l.release();,```,,生产者/消费者模式通常则将信号量与队列配合使用。生产者向队列中加入数据,并 post 一个信号,消费者则先 wait 信号,获取信号后去队查询取数据。
*/
/// <reference path="Lock.d.ts" />
declare class Class_Semaphore extends Class_Lock {
/**
*
* @brief 信号量构造函数
* @param value 计数器初始数值
*
*
*
*/
constructor(value?: number/** = 1*/);
/**
*
* @brief 等待一个信号量,等同于 acquire(true)
*
*
*/
wait(): void;
/**
*
* @brief 释放一个信号量,等同于 release()
*
*
*/
post(): void;
/**
*
* @brief 尝试获取一个信号,如不能获取,则立即返回并返回 false,等同于 acquire(false)
* @return 获取成功则返回 true
*
*
*
*/
trywait(): boolean;
} /** endof class */
/** } /** endof `module Or Internal Object` */
+176
View File
@@ -0,0 +1,176 @@
/***************************************************************************
* *
* This file was automatically generated with idlc.js *
* build info: *
* - fibjs : 0.25.0 *
* - date : Jun 11 2018 14:17:22 *
* *
***************************************************************************/
/**
* @author Richard <richardo2016@gmail.com>
*
*/
/// <reference path="object.d.ts" />
/** module Or Internal Object */
/**
* @brief 系统服务管理对象
* @detail
*/
/// <reference path="EventEmitter.d.ts" />
declare class Class_Service extends Class_EventEmitter {
/**
* class prop
*
*
* @brief 查询和设置服务名称
*
*
* @type String
*/
name: string
/**
* class prop
*
*
* @brief 查询和绑定服务停止事件,相当于 on("stop", func);
*
*
* @type Function
*/
onstop: Function
/**
* class prop
*
*
* @brief 查询和绑定服务暂停事件,相当于 on("pause", func);
*
*
* @type Function
*/
onpause: Function
/**
* class prop
*
*
* @brief 查询和绑定服务恢复事件,相当于 on("continue", func);
*
*
* @type Function
*/
oncontinue: Function
/**
*
* @brief 系统服务管理对象构造函数
* @param name 服务名称
* @param worker 服务运行函数
* @param event 服务事件处理
*
*
*
*/
constructor(name: string, worker: Function, event?: Object/** = v8::Object::New(isolate)*/);
/**
*
* @brief 开始运行服务实体
*
* @async
*/
run(): void;
/**
*
* @brief 安装服务到系统
* @param name 服务名称
* @param cmd 服务命令行
* @param displayName 服务显示名称
* @param description 服务描述信息
*
*
*
*/
static install(name: string, cmd: string, displayName?: string/** = ""*/, description?: string/** = ""*/): void;
/**
*
* @brief 从系统中卸载服务
* @param name 服务名称
*
*
*
*/
static remove(name: string): void;
/**
*
* @brief 启动服务
* @param name 服务名称
*
*
*
*/
static start(name: string): void;
/**
*
* @brief 停止服务
* @param name 服务名称
*
*
*
*/
static stop(name: string): void;
/**
*
* @brief 重启服务
* @param name 服务名称
*
*
*
*/
static restart(name: string): void;
/**
*
* @brief 检测服务是否安装
* @param name 服务名称
* @return 服务安装返回 True
*
*
*
*/
static isInstalled(name: string): boolean;
/**
*
* @brief 检测服务是否运行
* @param name 服务名称
* @return 服务运行返回 True
*
*
*
*/
static isRunning(name: string): boolean;
} /** endof class */
/** } /** endof `module Or Internal Object` */
+146
View File
@@ -0,0 +1,146 @@
/***************************************************************************
* *
* This file was automatically generated with idlc.js *
* build info: *
* - fibjs : 0.25.0 *
* - date : Jun 11 2018 14:17:22 *
* *
***************************************************************************/
/**
* @author Richard <richardo2016@gmail.com>
*
*/
/// <reference path="object.d.ts" />
/** module Or Internal Object */
/**
* @brief Smtp对象
* @detail
*/
declare class Class_Smtp extends Class__object {
/**
* class prop
*
*
* @brief 查询和设置超时时间 单位毫秒
*
*
* @type Integer
*/
timeout: number
/**
* class prop
*
*
* @brief 查询 Smtp 对象当前连接的 Socket
*
* @readonly
* @type Stream
*/
socket: Class_Stream
/**
*
* @brief Smtp 对象构造函数
*
*
*/
constructor();
/**
*
* @brief 建立到指定的服务器
* @param url 指定连接的协议,可以是:tcp://host:port 或者 ssl://host:port
*
*
* @async
*/
connect(url: string): void;
/**
*
* @brief 发送指定命令,并返回响应,服务器报错则抛出错误
* @param cmd 命令名
* @param arg 参数
* @return 如果成功,返回服务器响应
*
*
* @async
*/
command(cmd: string, arg: string): string;
/**
*
* @brief 发送 HELO 命令,服务器报错则抛出错误
* @param hostname 主机名,缺省为“localhost”
*
*
* @async
*/
hello(hostname?: string/** = "localhost"*/): void;
/**
*
* @brief 用指定的用户及密码登录服务器,服务器报错则抛出错误
* @param username 用户名
* @param password 密码
*
*
* @async
*/
login(username: string, password: string): void;
/**
*
* @brief 指定发件人信箱,服务器报错则抛出错误
* @param address 发件人信箱
*
*
* @async
*/
from(address: string): void;
/**
*
* @brief 指定收件人信箱,服务器报错则抛出错误
* @param address 收件人信箱
*
*
* @async
*/
to(address: string): void;
/**
*
* @brief 发送文本到收件人,服务器报错则抛出错误
* @param txt 要发送的文本
*
*
* @async
*/
data(txt: string): void;
/**
*
* @brief 退出并关闭连接,服务器报错则抛出错误
*
* @async
*/
quit(): void;
} /** endof class */
/** } /** endof `module Or Internal Object` */
+232
View File
@@ -0,0 +1,232 @@
/***************************************************************************
* *
* This file was automatically generated with idlc.js *
* build info: *
* - fibjs : 0.25.0 *
* - date : Jun 11 2018 14:17:22 *
* *
***************************************************************************/
/**
* @author Richard <richardo2016@gmail.com>
*
*/
/// <reference path="object.d.ts" />
/** module Or Internal Object */
/**
* @brief 网络套接口对象
* @detail Socket 属于 net 模块,创建方法,```JavaScript,var s = new net.Socket();,```
*/
/// <reference path="Stream.d.ts" />
declare class Class_Socket extends Class_Stream {
/**
* class prop
*
*
* @brief 查询当前 Socket 对象的地址集
*
* @readonly
* @type Integer
*/
family: number
/**
* class prop
*
*
* @brief 查询当前 Socket 对象的协议族
*
* @readonly
* @type Integer
*/
type: number
/**
* class prop
*
*
* @brief 查询当前连接的对方地址
*
* @readonly
* @type String
*/
remoteAddress: string
/**
* class prop
*
*
* @brief 查询当前连接的对方端口
*
* @readonly
* @type Integer
*/
remotePort: number
/**
* class prop
*
*
* @brief 查询当前连接的本地地址
*
* @readonly
* @type String
*/
localAddress: string
/**
* class prop
*
*
* @brief 查询当前连接的本地端口
*
* @readonly
* @type Integer
*/
localPort: number
/**
* class prop
*
*
* @brief 查询和设置超时时间 单位毫秒
*
*
* @type Integer
*/
timeout: number
/**
*
* @brief Socket 构造函数,创建一个新的 Socket 对象
* @param family 指定地址集,缺省为 AF_INET,ipv4
* @param type 指定协议族,缺省为 SOCK_STREAM,tcp
*
*
*
*/
constructor(family?: number/** = undefined*/, type?: number/** = undefined*/);
/**
*
* @brief 建立一个 tcp 连接
* @param host 指定对方地址或主机名
* @param port 指定对方端口
*
*
* @async
*/
connect(host: string, port: number): void;
/**
*
* @brief 将当前 Socket 绑定至本地所有地址的指定端口
* @param port 指定绑定的端口
* @param allowIPv4 指定是否接受 ipv4 连接,缺省为 true。本参数在 ipv6 时有效,并依赖于操作系统
*
*
*
*/
bind(port: number, allowIPv4?: boolean/** = true*/): void;
/**
*
* @brief 将当前 Socket 绑定至指定地址的指定端口
* @param addr 指定绑定的地址
* @param port 指定绑定的端口
* @param allowIPv4 指定是否接受 ipv4 连接,缺省为 true。本参数在 ipv6 时有效,并依赖于操作系统
*
*
*
*/
bind(addr: string, port: number, allowIPv4?: boolean/** = true*/): void;
/**
*
* @brief 开始监听连接请求
* @param backlog 指定请求队列长度,超出的请求将被拒绝,缺省为 120
*
*
*
*/
listen(backlog?: number/** = 120*/): void;
/**
*
* @brief 等待并接受一个连接
* @return 返回接收到得连接对象
*
*
* @async
*/
accept(): Class_Socket;
/**
*
* @brief 从连接读取指定大小的数据,不同于 read 方法,recv 并不保证读完要求的数据,而是在读取到数据后立即返回
* @param bytes 指定要读取的数据量,缺省读取任意尺寸的数据
* @return 返回从连接读取的数据
*
*
* @async
*/
recv(bytes?: number/** = -1*/): Class_Buffer;
/**
*
* @brief 读取一个 UDP 包
* recvfrom 返回结果中包含以下内容:
* - data: 接收到的二进制数据块
* - address: 发送方的地址
* - port: 发送方的端口
* @param bytes 指定要读取的数据量,缺省读取任意尺寸的数据
* @return 返回从连接读取的数据包
*
*
* @async
*/
recvfrom(bytes?: number/** = -1*/): any;
/**
*
* @brief 将给定的数据写入连接,此方法等效于 write 方法
* @param data 给定要写入的数据
*
*
* @async
*/
send(data: Class_Buffer): void;
/**
*
* @brief 向给定 ip:port 发送一个 UDP 包
* @param data 给定要写入的数据
* @param host 指定目标 ip 或主机名
* @param port 指定目标端口
*
*
* @async
*/
sendto(data: Class_Buffer, host: string, port: number): void;
} /** endof class */
/** } /** endof `module Or Internal Object` */
+106
View File
@@ -0,0 +1,106 @@
/***************************************************************************
* *
* This file was automatically generated with idlc.js *
* build info: *
* - fibjs : 0.25.0 *
* - date : Jun 11 2018 14:17:22 *
* *
***************************************************************************/
/**
* @author Richard <richardo2016@gmail.com>
*
*/
/// <reference path="object.d.ts" />
/** module Or Internal Object */
/**
* @brief ssl 协议转换处理器
* @detail 用以将数据流转换为 ssl 流协议。SslHandler 是对 SslSocket 的封装,用于构建服务器,逻辑上相当于:,```JavaScript,var ss = new ssl.Socket(crt, key);,,function(s){, var s1 = ss.accept(s);, hdlr.invoke(s1);, s1.close();,},```
*/
/// <reference path="Handler.d.ts" />
declare class Class_SslHandler extends Class_Handler {
/**
* class prop
*
*
* @brief 设定证书验证模式,缺省为 VERIFY_NONE
*
*
* @type Integer
*/
verification: number
/**
* class prop
*
*
* @brief 客户端证书验证证书链
*
* @readonly
* @type X509Cert
*/
ca: Class_X509Cert
/**
* class prop
*
*
* @brief ssl 协议转换处理器当前事件处理接口对象
*
*
* @type Handler
*/
handler: Class_Handler
/**
*
* @brief SslHandler 构造函数,创建一个新的 SslHandler 对象
*
* certs 格式为:
* ```JavaScript
* [
* {
* crt: [X509Cert object],
* key: [PKey object]
* },
* {
* crt: [X509Cert object],
* key: [PKey object]
* }
* ]
* ```
* @param certs 服务器证书列表
* @param hdlr 内置消息处理器,处理函数,链式处理数组,路由对象,详见 mq.Handler
*
*
*
*/
constructor(certs: any[], hdlr: Class_Handler);
/**
*
* @brief SslHandler 构造函数,创建一个新的 SslHandler 对象
* @param crt X509Cert 证书,用于客户端验证服务器
* @param key PKey 私钥,用于与客户端会话
* @param hdlr 内置消息处理器,处理函数,链式处理数组,路由对象,详见 mq.Handler
*
*
*
*/
constructor(crt: Class_X509Cert, key: Class_PKey, hdlr: Class_Handler);
} /** endof class */
/** } /** endof `module Or Internal Object` */
+137
View File
@@ -0,0 +1,137 @@
/***************************************************************************
* *
* This file was automatically generated with idlc.js *
* build info: *
* - fibjs : 0.25.0 *
* - date : Jun 11 2018 14:17:22 *
* *
***************************************************************************/
/**
* @author Richard <richardo2016@gmail.com>
*
*/
/// <reference path="object.d.ts" />
/** module Or Internal Object */
/**
* @brief ssl 服务器对象,可方便创建一个标准多纤程 ssl 服务器
* @detail SslServer 对象是将 TcpServer 和 SslHandler 组合封装的对象,方便快速搭建服务器,逻辑上相当于:,```JavaScript,var svr = new net.SslServer(addr, port, new ssl.Handler(crt, key, function(req){, ...,}));,```,,创建方法:,```JavaScript,var ssl = require("ssl");,var svr = new http.Server(crt, key, function(req){, ...,});,```
*/
/// <reference path="TcpServer.d.ts" />
declare class Class_SslServer extends Class_TcpServer {
/**
* class prop
*
*
* @brief 设定证书验证模式,缺省为 VERIFY_NONE
*
*
* @type Integer
*/
verification: number
/**
* class prop
*
*
* @brief 客户端证书验证证书链
*
* @readonly
* @type X509Cert
*/
ca: Class_X509Cert
/**
*
* @brief SslServer 构造函数,在所有本机地址侦听
*
* certs 格式为:
* ```JavaScript
* [
* {
* crt: [X509Cert object],
* key: [PKey object]
* },
* {
* crt: [X509Cert object],
* key: [PKey object]
* }
* ]
* ```
* @param certs 服务器证书列表
* @param port 指定 ssl 服务器侦听端口
* @param listener 指定 ssl 接收到的内置消息处理器,处理函数,链式处理数组,路由对象,详见 mq.Handler
*
*
*
*/
constructor(certs: any[], port: number, listener: Class_Handler);
/**
*
* @brief SslServer 构造函数
*
* certs 格式为:
* ```JavaScript
* [
* {
* crt: [X509Cert object],
* key: [PKey object]
* },
* {
* crt: [X509Cert object],
* key: [PKey object]
* }
* ]
* ```
* @param certs 服务器证书列表
* @param addr 指定 ssl 服务器侦听地址,为 "" 则在本机所有地址侦听
* @param port 指定 ssl 服务器侦听端口
* @param listener 指定 ssl 接收到的连接的内置消息处理器,处理函数,链式处理数组,路由对象,详见 mq.Handler
*
*
*
*/
constructor(certs: any[], addr: string, port: number, listener: Class_Handler);
/**
*
* @brief SslServer 构造函数,在所有本机地址侦听
* @param crt X509Cert 证书,用于客户端验证服务器
* @param key PKey 私钥,用于与客户端会话
* @param port 指定 ssl 服务器侦听端口
* @param listener 指定 ssl 接收到的内置消息处理器,处理函数,链式处理数组,路由对象,详见 mq.Handler
*
*
*
*/
constructor(crt: Class_X509Cert, key: Class_PKey, port: number, listener: Class_Handler);
/**
*
* @brief SslServer 构造函数
* @param crt X509Cert 证书,用于客户端验证服务器
* @param key PKey 私钥,用于与客户端会话
* @param addr 指定 ssl 服务器侦听地址,为 "" 则在本机所有地址侦听
* @param port 指定 ssl 服务器侦听端口
* @param listener 指定 ssl 接收到的连接的内置消息处理器,处理函数,链式处理数组,路由对象,详见 mq.Handler
*
*
*
*/
constructor(crt: Class_X509Cert, key: Class_PKey, addr: string, port: number, listener: Class_Handler);
} /** endof class */
/** } /** endof `module Or Internal Object` */
+139
View File
@@ -0,0 +1,139 @@
/***************************************************************************
* *
* This file was automatically generated with idlc.js *
* build info: *
* - fibjs : 0.25.0 *
* - date : Jun 11 2018 14:17:22 *
* *
***************************************************************************/
/**
* @author Richard <richardo2016@gmail.com>
*
*/
/// <reference path="object.d.ts" />
/** module Or Internal Object */
/**
* @brief ssl 网络套接口对象
* @detail SslSocket 属于 ssl 模块,创建方法,```JavaScript,var s = new ssl.Socket();,```
*/
/// <reference path="Stream.d.ts" />
declare class Class_SslSocket extends Class_Stream {
/**
* class prop
*
*
* @brief 设定证书验证模式,缺省为 VERIFY_REQUIRED
*
*
* @type Integer
*/
verification: number
/**
* class prop
*
*
* @brief 证书链,客户端模式 connect 时自动引用 ssl.ca,服务器模式 accept 生成 SslSocket 自动引用当前 SslSocket 的 ca
*
* @readonly
* @type X509Cert
*/
ca: Class_X509Cert
/**
* class prop
*
*
* @brief 连接对方的证书
*
* @readonly
* @type X509Cert
*/
peerCert: Class_X509Cert
/**
* class prop
*
*
* @brief 查询消息 ssl 建立时的下层流对象
*
* @readonly
* @type Stream
*/
stream: Class_Stream
/**
*
* @brief SslSocket 构造函数,创建一个新的 SslSocket 对象
*
* certs 格式为:
* ```JavaScript
* [
* {
* crt: [X509Cert object],
* key: [PKey object]
* },
* {
* crt: [X509Cert object],
* key: [PKey object]
* }
* ]
* ```
* @param certs 服务器证书列表
*
*
*
*/
constructor(certs?: any[]/** = v8::Array::New(isolate)*/);
/**
*
* @brief SslSocket 构造函数,创建一个新的 SslSocket 对象
* @param crt X509Cert 证书,用于客户端验证服务器
* @param key PKey 私钥,用于与客户端会话
*
*
*
*/
constructor(crt: Class_X509Cert, key: Class_PKey);
/**
*
* @brief 在给定的连接上连接 ssl 连接,客户端模式
* @param s 给定的底层连接
* @param server_name 指定服务器名称,可缺省
* @return 连接成功返回 0,证书可选验证时,验证不成功则返回非 0,详细错误见 ssl 模块
*
*
* @async
*/
connect(s: Class_Stream, server_name?: string/** = ""*/): number;
/**
*
* @brief 在给定的连接上接收一个 ssl 连接,并生成一个新的 SslSocket
* @param s 给定的底层连接
* @return 返回新建立的 SslSocket 对象
*
*
* @async
*/
accept(s: Class_Stream): Class_SslSocket;
} /** endof class */
/** } /** endof `module Or Internal Object` */
+219
View File
@@ -0,0 +1,219 @@
/***************************************************************************
* *
* This file was automatically generated with idlc.js *
* build info: *
* - fibjs : 0.25.0 *
* - date : Jun 11 2018 14:17:22 *
* *
***************************************************************************/
/**
* @author Richard <richardo2016@gmail.com>
*
*/
/// <reference path="object.d.ts" />
/** module Or Internal Object */
/**
* @brief 文件的基础信息对象
* @detail Stat 对象通过 fs.stat, File.stat, fs.readdir 查询,不可独立创建
*/
declare class Class_Stat extends Class__object {
/**
* class prop
*
*
* @brief 文件名称
*
* @readonly
* @type String
*/
name: string
/**
* class prop
*
*
* @brief 文件尺寸
*
* @readonly
* @type Long
*/
size: number
/**
* class prop
*
*
* @brief 文件权限,Windows 不支持此属性
*
* @readonly
* @type Integer
*/
mode: number
/**
* class prop
*
*
* @brief 文件最后修改时间
*
* @readonly
* @type Date
*/
mtime: Date
/**
* class prop
*
*
* @brief 文件最后访问时间
*
* @readonly
* @type Date
*/
atime: Date
/**
* class prop
*
*
* @brief 文件创建时间
*
* @readonly
* @type Date
*/
ctime: Date
/**
* class prop
*
*
* @brief 文件拥有者的id
*
* @readonly
* @type Integer
*/
uid: number
/**
* class prop
*
*
* @brief 文件所属的组id
*
* @readonly
* @type Integer
*/
gid: number
/**
*
* @brief 查询文件是否有写入权限
* @return 为 true 则有写入权限
*
*
*
*/
isWritable(): boolean;
/**
*
* @brief 查询文件是否有读权限
* @return 为 true 则有读权限
*
*
*
*/
isReadable(): boolean;
/**
*
* @brief 查询文件是否有执行权限
* @return 为 true 则有执行权限
*
*
*
*/
isExecutable(): boolean;
/**
*
* @brief 查询文件是否隐藏
* @return 为 true 则隐藏
*
*
*
*/
isHidden(): boolean;
/**
*
* @brief 查询文件是否是目录
* @return 为 true 则是目录
*
*
*
*/
isDirectory(): boolean;
/**
*
* @brief 查询文件是否是文件
* @return 为 true 则是文件
*
*
*
*/
isFile(): boolean;
/**
*
* @brief 查询文件是否是符号链接
* @return 为 true 则是符号链接
*
*
*
*/
isSymbolicLink(): boolean;
/**
*
* @brief 查询文件是否是内存文件
* @return 为 true 则是内存文件
*
*
*
*/
isMemory(): boolean;
/**
*
* @brief 查询文件是否是 Socket
* @return 为 true 则是 Socket
*
*
*
*/
isSocket(): boolean;
} /** endof class */
/** } /** endof `module Or Internal Object` */
+103
View File
@@ -0,0 +1,103 @@
/***************************************************************************
* *
* This file was automatically generated with idlc.js *
* build info: *
* - fibjs : 0.25.0 *
* - date : Jun 11 2018 14:17:22 *
* *
***************************************************************************/
/**
* @author Richard <richardo2016@gmail.com>
*
*/
/// <reference path="object.d.ts" />
/** module Or Internal Object */
/**
* @brief 数据统计对象,用以构建应用运行时数据收集
* @detail 创建方法:,```JavaScript,var util = require("util");,var stats = new util.Stats(["begin", "end", "error"]);,```,一些内部对象会提供预先定义的的统计对象
*/
declare class Class_Stats extends Class__object {
/**
*
* @brief 数据统计对象构造方法
* @param keys 指定计数器的名称
*
*
*
*/
constructor(keys: any[]);
/**
*
* @brief 数据统计对象构造方法
* @param staticKeys 指定静态计数器的名称,静态计数器不会被 reset
* @param keys 指定计数器的名称
*
*
*
*/
constructor(staticKeys: any[], keys: any[]);
/**
*
* @brief 指定的计数器增一
* @param key 指定计数器名称
*
*
*
*/
inc(key: string): void;
/**
*
* @brief 指定的计数器减一
* @param key 指定计数器名称
*
*
*
*/
dec(key: string): void;
/**
*
* @brief 指定的计数器加指定值
* @param key 指定计数器名称
* @param value 指定数值
*
*
*
*/
add(key: string, value: number): void;
/**
*
* @brief 初始化计数器,除 staticKeys 指定的计数器全部清零
*
*
*/
reset(): void;
/**
*
* @brief 查询上次 reset 到现在的运行时间
* @return 返回上次 reset 到现在的运行时间
*
*
*
*/
uptime(): number;
} /** endof class */
/** } /** endof `module Or Internal Object` */
+82
View File
@@ -0,0 +1,82 @@
/***************************************************************************
* *
* This file was automatically generated with idlc.js *
* build info: *
* - fibjs : 0.25.0 *
* - date : Jun 11 2018 14:17:22 *
* *
***************************************************************************/
/**
* @author Richard <richardo2016@gmail.com>
*
*/
/// <reference path="object.d.ts" />
/** module Or Internal Object */
/**
* @brief 流操作对象,用于二进制数据流读写
* @detail Stream 为基础对象,用于为流处理定义标准借口,不能独立创建
*/
declare class Class_Stream extends Class__object {
/**
*
* @brief 从流内读取指定大小的数据
* @param bytes 指定要读取的数据量,缺省为读取随机大小的数据块,读出的数据尺寸取决于设备
* @return 返回从流内读取的数据,若无数据可读,或者连接中断,则返回 null
*
*
* @async
*/
read(bytes?: number/** = -1*/): Class_Buffer;
/**
*
* @brief 将给定的数据写入流
* @param data 给定要写入的数据
*
*
* @async
*/
write(data: Class_Buffer): void;
/**
*
* @brief 将文件缓冲区内容写入物理设备
*
* @async
*/
flush(): void;
/**
*
* @brief 关闭当前流对象
*
* @async
*/
close(): void;
/**
*
* @brief 复制流数据到目标流中
* @param stm 目标流对象
* @param bytes 复制的字节数
* @return 返回复制的字节数
*
*
* @async
*/
copyTo(stm: Class_Stream, bytes?: number/** = -1*/): number;
} /** endof class */
/** } /** endof `module Or Internal Object` */
+146
View File
@@ -0,0 +1,146 @@
/***************************************************************************
* *
* This file was automatically generated with idlc.js *
* build info: *
* - fibjs : 0.25.0 *
* - date : Jun 11 2018 14:17:22 *
* *
***************************************************************************/
/**
* @author Richard <richardo2016@gmail.com>
*
*/
/// <reference path="object.d.ts" />
/** module Or Internal Object */
/**
* @brief 流解码对象
* @detail
*/
declare class Class_StringDecoder extends Class__object {
/**
* class prop
*
*
* @brief 内部使用。
*
*
* @type Integer
*/
lastNeed: number
/**
* class prop
*
*
* @brief 内部使用。
*
*
* @type Integer
*/
lastTotal: number
/**
* class prop
*
*
* @brief 内部使用。
*
*
* @type Buffer
*/
lastChar: Class_Buffer
/**
* class prop
*
*
* @brief 解码编码.内部使用。
*
*
* @type String
*/
encoding: string
/**
*
* @brief 解码器构造函数
* @param encoding 解码编码. 默认 'utf8'.
*
*
*
*/
constructor(encoding?: string/** = "utf8"*/);
/**
*
* @brief 将内部存留的 buffer 作为字符返回。不完整的 UTF-8 和 UTF-16 字节会尝试补全。
* @return 解码后的字符串.
*
*
*
*/
end(): string;
/**
*
* @brief 将内部存留的 buffer 作为字符返回。不完整的 UTF-8 和 UTF-16 字节会尝试补全。
* @param buf 需要解码的 Buffer. 在执行 end 之前,会先调用 write 将 buffer 写入。
* @return 解码后的字符串.
*
*
*
*/
end(buf: Class_Buffer): string;
/**
*
* @brief 返回一个解码后的字符串, 确保任何非完整的末尾字符被省略此次不返回,并被存储在内部供下一次的 write 或者 end 方法使用。
* @param buf 需要解码的 Buffer。
* @return 解码后的字符串.
*
*
*
*/
write(buf: Class_Buffer): string;
/**
*
* @brief 内部使用。.
* @param buf 需要解码的 Buffer。
* @param offset 解码偏移量
* @return 解码后的字符串.
*
*
*
*/
text(buf: Class_Buffer, offset: number): string;
/**
*
* @brief 内部使用。.
* @param buf A Buffer containing the bytes to decode.
* @return 解码后的字符串.
*
*
*
*/
fillLast(buf: Class_Buffer): string;
} /** endof class */
/** } /** endof `module Or Internal Object` */
+103
View File
@@ -0,0 +1,103 @@
/***************************************************************************
* *
* This file was automatically generated with idlc.js *
* build info: *
* - fibjs : 0.25.0 *
* - date : Jun 11 2018 14:17:22 *
* *
***************************************************************************/
/**
* @author Richard <richardo2016@gmail.com>
*
*/
/// <reference path="object.d.ts" />
/** module Or Internal Object */
/**
* @brief 子进程对象
* @detail ```JavaScript,var process = require("process");,var sub = process.open("ls");,```
*/
/// <reference path="BufferedStream.d.ts" />
declare class Class_SubProcess extends Class_BufferedStream {
/**
* class prop
*
*
* @brief 读取当前对象指向的进程的 id
*
*
* @readonly
* @type Integer
*/
pid: number
/**
* class prop
*
*
* @brief 读取当前对象指向的进程的标准输入对象
*
*
* @readonly
* @type BufferedStream
*/
stdin: Class_BufferedStream
/**
* class prop
*
*
* @brief 读取当前对象指向的进程的标准输出对象
*
*
* @readonly
* @type BufferedStream
*/
stdout: Class_BufferedStream
/**
*
* @brief 杀掉当前对象指向的进程,并传递信号
* @param signal 传递的信号
*
*
*
*/
kill(signal: number): void;
/**
*
* @brief 等待当前对象指向的进程结束,并返回进程结束代码
* @return 进程的结束代码
*
*
* @async
*/
wait(): number;
/**
*
* @brief 查询当前对象所指向的进程是否存在指定名称的窗口,仅限 windows
* @param name 窗口名称
* @return 窗口存在则返回窗口的 rect,否则返回 undefined
*
*
*
*/
findWindow(name: string): any;
} /** endof class */
/** } /** endof `module Or Internal Object` */
+127
View File
@@ -0,0 +1,127 @@
/***************************************************************************
* *
* This file was automatically generated with idlc.js *
* build info: *
* - fibjs : 0.25.0 *
* - date : Jun 11 2018 14:17:22 *
* *
***************************************************************************/
/**
* @author Richard <richardo2016@gmail.com>
*
*/
/// <reference path="object.d.ts" />
/** module Or Internal Object */
/**
* @brief tcp 服务器对象,可方便创建一个标准多纤程 tcp 服务器
* @detail 使用 TcpServer 对象可以迅速创建一个多纤程并发处理的 tcp 服务器。,```JavaScript,function func(conn),{, var data;,, while(data = conn.read()), conn.write(data);,, conn.close();,},,new net.TcpServer(8080, func).run();,```
*/
declare class Class_TcpServer extends Class__object {
/**
* class prop
*
*
* @brief 服务器当前侦听的 Socket 对象
*
* @readonly
* @type Socket
*/
socket: Class_Socket
/**
* class prop
*
*
* @brief 服务器当前事件处理接口对象
*
*
* @type Handler
*/
handler: Class_Handler
/**
* class prop
*
*
* @brief 查询当前服务器运行状态
*
* 返回的结果为一个 Stats 对象,初始化计数器如下:
* ```JavaScript
* {
* total : 1000, // 总计处理的连接
* connections : 100, // 当前正在处理的连接
* accept : 10, // 上次查询后新建的连接
* close : 10 // 上次查询后关闭的连接
* }
* ```
*
*
* @readonly
* @type Stats
*/
stats: Class_Stats
/**
*
* @brief TcpServer 构造函数,在所有本机地址侦听
* @param port 指定 tcp 服务器侦听端口
* @param listener 指定 tcp 接收到的内置消息处理器,处理函数,链式处理数组,路由对象,详见 mq.Handler
*
*
*
*/
constructor(port: number, listener: Class_Handler);
/**
*
* @brief TcpServer 构造函数
* @param addr 指定 tcp 服务器侦听地址,为 "" 则在本机所有地址侦听
* @param port 指定 tcp 服务器侦听端口
* @param listener 指定 tcp 接收到的连接的内置消息处理器,处理函数,链式处理数组,路由对象,详见 mq.Handler
*
*
*
*/
constructor(addr: string, port: number, listener: Class_Handler);
/**
*
* @brief 运行服务器并开始接收和分发连接,此函数不会返回
*
* @async
*/
run(): void;
/**
*
* @brief 异步运行服务器并开始接收和分发连接,调用后立即返回,服务器在后台运行
*
*
*/
asyncRun(): void;
/**
*
* @brief 关闭 socket中止正在运行的服务器
*
* @async
*/
stop(): void;
} /** endof class */
/** } /** endof `module Or Internal Object` */
+73
View File
@@ -0,0 +1,73 @@
/***************************************************************************
* *
* This file was automatically generated with idlc.js *
* build info: *
* - fibjs : 0.25.0 *
* - date : Jun 11 2018 14:17:22 *
* *
***************************************************************************/
/**
* @author Richard <richardo2016@gmail.com>
*
*/
/// <reference path="object.d.ts" />
/** module Or Internal Object */
/**
* @brief 定时器处理器对象
* @detail
*/
declare class Class_Timer extends Class__object {
/**
* class prop
*
*
* @brief 查询当前定时器是否已经终止
*
* @readonly
* @type Boolean
*/
stopped: boolean
/**
*
* @brief 维持 fibjs 进程不退出,在定时器等待期间阻止 fibjs 进程退出
* @return 返回定时器对象
*
*
*
*/
ref(): Class_Timer;
/**
*
* @brief 允许 fibjs 进程退出,在定时器等待期间允许 fibjs 进程退出
* @return 返回定时器对象
*
*
*
*/
unref(): Class_Timer;
/**
*
* @brief 取消当前定时器
*
*
*/
clear(): void;
} /** endof class */
/** } /** endof `module Or Internal Object` */
+279
View File
@@ -0,0 +1,279 @@
/***************************************************************************
* *
* This file was automatically generated with idlc.js *
* build info: *
* - fibjs : 0.25.0 *
* - date : Jun 11 2018 14:17:22 *
* *
***************************************************************************/
/**
* @author Richard <richardo2016@gmail.com>
*
*/
/// <reference path="object.d.ts" />
/** module Or Internal Object */
/**
* @brief Url 处理对象
* @detail 基础模块。提供 url 的格式化,解析与拼装,```JavaScript,var url = new net.Url('http://www.xici.net/');,var url = new net.Url({protocol: 'http:', hostname:'www.xici.net', pathname:'/'});,```
*/
declare class Class_UrlObject extends Class__object {
/**
* class prop
*
*
* @brief 查询和设置当前 UrlObject 对象中的完整 url 地址描述,此描述由其他所有属性组装而成
*
*
*
* @type String
*/
href: string
/**
* class prop
*
*
* @brief 查询和设置当前 UrlObject 对象中的协议名称
*
*
*
* @type String
*/
protocol: string
/**
* class prop
*
*
* @brief 查询和设置当前 UrlObject 对象是否包含双斜杠
*
*
*
* @type Boolean
*/
slashes: boolean
/**
* class prop
*
*
* @brief 查询和设置当前 UrlObject 对象中的完整验证字符串,由 username 和 password 属性组装而成
*
*
*
* @type String
*/
auth: string
/**
* class prop
*
*
* @brief 查询和设置当前 UrlObject 对象中的验证用户
*
*
*
* @type String
*/
username: string
/**
* class prop
*
*
* @brief 查询和设置当前 UrlObject 对象中的验证密码
*
*
*
* @type String
*/
password: string
/**
* class prop
*
*
* @brief 查询和设置当前 UrlObject 对象中的完整主机描述,由 hastname 和 port 组装而成
*
*
*
* @type String
*/
host: string
/**
* class prop
*
*
* @brief 查询和设置当前 UrlObject 对象中的主机名
*
*
*
* @type String
*/
hostname: string
/**
* class prop
*
*
* @brief 查询和设置当前 UrlObject 对象中的端口号
*
*
*
* @type String
*/
port: string
/**
* class prop
*
*
* @brief 查询和设置当前 UrlObject 对象中的请求完整路径(含请求),由 pathname 和 query 组装而成
*
*
*
* @type String
*/
path: string
/**
* class prop
*
*
* @brief 查询和设置当前 UrlObject 对象中的路径
*
*
*
* @type String
*/
pathname: string
/**
* class prop
*
*
* @brief 查询和设置当前 UrlObject 对象中的请求字符串(含“?”),等效于“?”+query
*
*
*
* @type String
*/
search: string
/**
* class prop
*
*
* @brief 查询和设置当前 UrlObject 对象中的请求字符串( 不含“?”)
*
*
*
* @type Value
*/
query: any
/**
* class prop
*
*
* @brief 查询和设置当前 UrlObject 对象中的请求锚点(含“\#”)
*
*
*
* @type String
*/
hash: string
/**
*
* @brief UrlObject 对象构造函数,使用参数构造
* @param args 指定构造参数的字典对象,支持的字段有:protocol, slashes, username, password, hostname, port, pathname, query, hash
*
*
*
*/
constructor(args: Object);
/**
*
* @brief UrlObject 对象构造函数,使用 url 字符串构造
* @param url 指定构造 url 字符串
* @param parseQueryString 指定是否解析 query
* @param slashesDenoteHost 默认为false, 如果设置为true,则从字符串'//'之后到下一个'/'之前的字符串会被解析为host,例如'//foo/bar', 结果应该是{host: 'foo', pathname: '/bar'}而不是{pathname: '//foo/bar'}
*
*
*
*/
constructor(url?: string/** = ""*/, parseQueryString?: boolean/** = false*/, slashesDenoteHost?: boolean/** = false*/);
/**
*
* @brief 解析一个 url 字符串
* @param url 指定需要解析的 url 字符串
* @param parseQueryString 指定是否解析 query
* @param slashesDenoteHost 默认为false, 如果设置为true,则从字符串'//'之后到下一个'/'之前的字符串会被解析为host,例如'//foo/bar', 结果应该是{host: 'foo', pathname: '/bar'}而不是{pathname: '//foo/bar'}
*
*
*
*/
parse(url: string, parseQueryString?: boolean/** = false*/, slashesDenoteHost?: boolean/** = false*/): void;
/**
*
* @brief 使用指定的参数构造 UrlObject
* @param args 指定构造参数的字典对象,支持的字段有:protocol, slashes, username, password, hostname, port, pathname, query, hash
*
*
*
*/
format(args: Object): void;
/**
*
* @brief 重定位 url 路径,自动识别新路径为相对路径还是绝对路径
* @param url 指定新的路径
* @return 返回包含重定位数据的对象
*
*
*
*/
resolve(url: string): Class_UrlObject;
/**
*
* @brief 标准化路径
*
*
*
*/
normalize(): void;
} /** endof class */
/** } /** endof `module Or Internal Object` */
+192
View File
@@ -0,0 +1,192 @@
/***************************************************************************
* *
* This file was automatically generated with idlc.js *
* build info: *
* - fibjs : 0.25.0 *
* - date : Jun 11 2018 14:17:22 *
* *
***************************************************************************/
/**
* @author Richard <richardo2016@gmail.com>
*
*/
/// <reference path="object.d.ts" />
/** module Or Internal Object */
/**
* @brief WebSocket 包协议转换处理器
* @detail 用以将 Http 协议转换为 WebSocket 包协议消息。创建方式:,```JavaScript,var ws = require('ws');,var http = require('http');,,var serv = new http.Server(8811, ws.upgrade((conn) => {,conn.onmessage = msg => {, conn.send(new Date());,};,}));,,serv.run(r => 0);,,var sock = new ws.Socket('ws://127.0.0.1:8811');,sock.on('open', () => {, setInterval(() => {, sock.send('get date');, }, 1000);,});,,sock.onmessage = evt => {, console.log(evt.data);,},```
*/
/// <reference path="EventEmitter.d.ts" />
declare class Class_WebSocket extends Class_EventEmitter {
/**
* class prop
*
*
* @brief 查询当前对象连接的服务器
*
* @readonly
* @type String
*/
url: string
/**
* class prop
*
*
* @brief 查询当前对象连接时的协议
*
* @readonly
* @type String
*/
protocol: string
/**
* class prop
*
*
* @brief 查询当前对象连接的源
*
* @readonly
* @type String
*/
origin: string
/**
* class prop
*
*
* @brief 查询当前对象的连接状态,参见 ws
*
* @readonly
* @type Integer
*/
readyState: number
/**
* class prop
*
*
* @brief 查询和绑定连接成功事件,相当于 on("open", func);
*
*
* @type Function
*/
onopen: Function
/**
* class prop
*
*
* @brief 查询和绑定接受到对方消息的事件,相当于 on("message", func);
*
*
* @type Function
*/
onmessage: Function
/**
* class prop
*
*
* @brief 查询和绑定连接关闭的事件,相当于 on("close", func);
*
*
* @type Function
*/
onclose: Function
/**
* class prop
*
*
* @brief 查询和绑定错误发生的事件,相当于 on("error", func);
*
*
* @type Function
*/
onerror: Function
/**
*
* @brief WebSocket 构造函数
* @param url 指定连接的服务器
* @param protocol 指定握手协议,缺省为 ""
* @param origin 指定握手时模拟的源
*
*
*
*/
constructor(url: string, protocol?: string/** = ""*/, origin?: string/** = ""*/);
/**
*
* @brief 关闭当前连接,此操作会向对方发送 CLOSE 数据包,并等待对方响应
* @param code 指定关闭的代码,允许值为 3000-4999 或者 1000,缺省为 1000
* @param reason 指定关闭的原因,缺省为 ""
*
*
*
*/
close(code?: number/** = 1000*/, reason?: string/** = ""*/): void;
/**
*
* @brief 向对方发送一段文本
* @param data 指定发送的文本
*
*
*
*/
send(data: string): void;
/**
*
* @brief 向对方发送一段二进制数据
* @param data 指定发送的二进制数据
*
*
*
*/
send(data: Class_Buffer): void;
/**
*
* @brief 维持 fibjs 进程不退出,在对象绑定期间阻止 fibjs 进程退出
* @return 返回当前对象
*
*
*
*/
ref(): Class_WebSocket;
/**
*
* @brief 允许 fibjs 进程退出,在对象绑定期间允许 fibjs 进程退出
* @return 返回当前对象
*
*
*
*/
unref(): Class_WebSocket;
} /** endof class */
/** } /** endof `module Or Internal Object` */

Some files were not shown because too many files have changed in this diff Show More