Skip to content

Commit

Permalink
chore: update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
zdm committed Oct 29, 2024
1 parent 13143c2 commit 5a1b5cc
Show file tree
Hide file tree
Showing 11 changed files with 55 additions and 53 deletions.
6 changes: 3 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9146,7 +9146,7 @@ Changed:
- stream readLine fixed;
- cli refactored;
- rpc methods permissions not required;
- threads RPC* prefix changed to API*;
- threads RPC\* prefix changed to API\*;
- api rpc added;
- app rpc default port 8080;
- cli special argument --;
Expand Down Expand Up @@ -9380,7 +9380,7 @@ Changed:
Changed:

- result moved to own package;
- #index imports added;
- \#index imports added;

### 2.17.0 (2021-04-21)

Expand Down Expand Up @@ -9769,7 +9769,7 @@ Changed:
- proxy rotation refactored;
- api token refactored;
- luminati session;
- sql where condition [!=, null] converted to IS NOT NULL;
- sql where condition \[!=, null] converted to IS NOT NULL;
- ajv api keywords;
- require global index;
- max threads replaced with semaphore;
Expand Down
4 changes: 2 additions & 2 deletions docs/api-client.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
```javascript
import Api from "@softvisio/core/api";

const api = new Api("wss://devel:8080/api?maxConnections=1", { cacheMax: 1000 });
const api = new Api( "wss://devel:8080/api?maxConnections=1", { "cacheMax": 1000 } );
```

### new Api( url, options )
Expand Down Expand Up @@ -154,7 +154,7 @@ Unref websockets connectiona.
## Class: ApiClientUpload

```javascript
const upload = api.upload("/v1/test/upload", File).on("progress", upload => console.log(upload.progressText));
const upload = api.upload( "/v1/test/upload", File ).on( "progress", upload => console.log( upload.progressText ) );

const res = await upload.start();
```
Expand Down
28 changes: 15 additions & 13 deletions docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ npm install @softvisio/core
```javascript
import Api from "@softvisio/core/api";

const api = new Api({
url: "/api/",
token: null,
version: "v1",
});
const api = new Api( {
"url": "/api/",
"token": null,
"version": "v1",
} );

Vue.prototype.$api = api;
```
Expand Down Expand Up @@ -47,12 +47,13 @@ Can be used in synchronous or asynchronous mode:

```javascript
// synchronous call
var res = await api.call("path/to/method", arg1, arg2);
var res = await api.call( "path/to/method", arg1, arg2 );

// async call with callback
api.call("path/to/method", arg1, function (res) {
api.call( "path/to/method", arg1, function ( res ) {

// do something with the results
});
} );
```

Params:
Expand All @@ -68,12 +69,13 @@ Result:
Each api call returns single result class instance. Usage example:

```javascript
var res = api.call("/v1/session/signin", [username, password]);
var res = api.call( "/v1/session/signin", [ username, password ] );

if (res.ok) {
console.log(res.data);
} else {
console.log(res.toString());
if ( res.ok ) {
console.log( res.data );
}
else {
console.log( res.toString() );
}
```

Expand Down
22 changes: 11 additions & 11 deletions docs/app/application.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,40 +8,40 @@ Application has three events type:

```javascript
// listen
app.on("/global-event-name", callback);
app.on( "/global-event-name", callback );

// publish
app.publish("/global-event-name");
app.publish( "/global-event-name" );
```

To send events to the other cluster namespace you need to use `"//"` prefix. You are unable to listen for events from the other namespace. For example:

```javascript
// ERROR
app.on("//namespace/global-event-name", callback);
app.on( "//namespace/global-event-name", callback );
// OK
app.publish("//namespace/global-event-name");
app.publish( "//namespace/global-event-name" );
```

- **local** - Local events are delivered to the local application and local threads.

```javascript
// listen
app.on("local-event-name", callback);
app.on( "local-event-name", callback );
// publish
app.publish("local-event-name");
app.publish( "local-event-name" );
```

- **application** - Application events are delivered to the local application only.

```javascript
// listen
app.on("app-event-name", callback);
app.on( "app-event-name", callback );
// publish
app.emit("all-event-name");
app.emit( "all-event-name" );
```

### API events
Expand All @@ -68,7 +68,7 @@ Events from the externally connected API users. All such events names are prefix
To send events to the connected API users you need to publish them to the `api` endpoint.

```javascript
app.publish("api", users, name, ...args);
app.publish( "api", users, name, ...args );
```

- `users` {string|Array} Target user identificators. Each identificator can be the one of:
Expand Down Expand Up @@ -99,7 +99,7 @@ Events from the externally connected RPC clients. All such events names are pref
To send events to the connected RPC users you need to publish them to the `rpc` endpoint.

```javascript
app.publish("rpc", clients, name, ...args);
app.publish( "rpc", clients, name, ...args );
```

- `clients` {string|Array} RPC client identificators. Each identificator can be the one of:
Expand Down Expand Up @@ -169,7 +169,7 @@ Events from the connected serivce.
To send events to the connected service you need to publish them to the `service` endpoint.

```javascript
app.publish("service", services, name, ...args);
app.publish( "service", services, name, ...args );
```

- `services` {string|Array} Target services names. You can use `"*"` to send event to the all connected services.
Expand Down
2 changes: 1 addition & 1 deletion docs/cache-lru.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
```javascript
import CacheLRU from "@softvisio/utils/cache-lru";

const cache = new CacheLRU({ max: 10 });
const cache = new CacheLRU( { "max": 10 } );
```

## Class: CacheLRU
Expand Down
2 changes: 1 addition & 1 deletion docs/doubly-linked-list.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import DoublyLinkedList from "@softvisio/utils/doubly-linked-list";

const list = new DoublyLinkedList();

list.push(1, 2, 3);
list.push( 1, 2, 3 );
```

## Class: DoublyLinkedList
Expand Down
2 changes: 1 addition & 1 deletion docs/env.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Provides set of function to manage project environment.
```javascript
import env from "@softvisio/core/env";

console.log(env.root);
console.log( env.root );
```

### env.mode
Expand Down
2 changes: 1 addition & 1 deletion docs/hostname.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Class, representing hostname.
```javascript
import Hostname from "@softvisio/core/hostname";

const hostname = new Hostname("www.google.com");
const hostname = new Hostname( "www.google.com" );
```

### new Hostname( hostname )
Expand Down
8 changes: 4 additions & 4 deletions docs/sql.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,23 @@ import sql from "@softvisio/core/sql";
```javascript
import sql from "@softvisio/core/sql";

const dbh = sql.new("pgsql://user:password@host");
const dbh = sql.new( "pgsql://user:password@host" );
```

### SQLite

```javascript
import sql from "@softvisio/core/sql";

const dbh = sql.new("sqlite:");
const dbh = sql.new( "sqlite:" );
```

## Class: sql.Query

## Migration

```javascript
await dbh.loadSchema(new URL("db", import.meta.url));
await dbh.loadSchema( new URL( "db", import.meta.url ) );

const res = await dbh.migrate();
```
Expand Down Expand Up @@ -70,7 +70,7 @@ When you merged patch with the main schema, you need to update `version` field i
### Add custom type
```javascript
const res = await dbh.addType(name, { encode, decode });
const res = await dbh.addType( name, { encode, decode } );
```
### Default types encoders
Expand Down
6 changes: 3 additions & 3 deletions docs/stream.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,9 @@ Reads stream and decode as JSON.
Reads chunk of data with the deifned length. Example:

```javascript
const buffer = await stream.readChunk(100); // reads 100 bytes, returns Buffer
const buffer = await stream.readChunk( 100 ); // reads 100 bytes, returns Buffer

const string = await stream.readChunk(100, { encoding: "utf8" }); // reads 100 bytes, returns utf8 string
const string = await stream.readChunk( 100, { "encoding": "utf8" } ); // reads 100 bytes, returns utf8 string
```

### readable.readLine( options? )
Expand All @@ -91,7 +91,7 @@ const string = await stream.readChunk(100, { encoding: "utf8" }); // reads 100 b
Reads line ended with the specified EOL separator and with the defined maximum length. This method is optimized for speed and can be used to read lines from large buffers, for example to parse `multipart/form-data` streams. Example:

```javascript
const string = await stream.readLine({ eol: "\r\n", maxLength: 100, encoding: "utf8" });
const string = await stream.readLine( { "eol": "\r\n", "maxLength": 100, "encoding": "utf8" } );
```

### readable.readHttpHeaders( options? )
Expand Down
26 changes: 13 additions & 13 deletions docs/text.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,11 @@ Disables ANSI codes.
- `name` {string} New color name.
- `color` {string|integer|integer\[]} Color definitions. Examples of the correct `RGB` colors definitions:
```javascript
ansi.defineColor("teal", "008080");
ansi.defineColor("teal", "#008080");
ansi.defineColor("teal", 0x8080);
ansi.defineColor("teal", 32896);
ansi.defineColor("teal", [0, 128, 128]);
ansi.defineColor( "teal", "008080" );
ansi.defineColor( "teal", "#008080" );
ansi.defineColor( "teal", 0x80_80 );
ansi.defineColor( "teal", 32_896 );
ansi.defineColor( "teal", [ 0, 128, 128 ] );
```

Defines named `RGB` color.
Expand Down Expand Up @@ -126,14 +126,14 @@ Define table style. Example of `ascii` style definition:

<!-- prettier-ignore -->
```javascript
Table.defineStyle("ascii", {
topLine: "+-++",
headerRow: "| ||",
headerLine: "|=+|",
dataRow: "| ||",
dataLine: "|-+|",
bottomLine: "+-++",
});
Table.defineStyle( "ascii", {
"topLine": "+-++",
"headerRow": "| ||",
"headerLine": "|=+|",
"dataRow": "| ||",
"dataLine": "|-+|",
"bottomLine": "+-++",
} );
```

### new Table( options )
Expand Down

0 comments on commit 5a1b5cc

Please sign in to comment.