From 5a1b5cccd1d97ef28a33c9b88f0db971d111876c Mon Sep 17 00:00:00 2001 From: zdm Date: Tue, 29 Oct 2024 15:41:36 +0200 Subject: [PATCH] chore: update docs --- CHANGELOG.md | 6 +++--- docs/api-client.md | 4 ++-- docs/api.md | 28 +++++++++++++++------------- docs/app/application.md | 22 +++++++++++----------- docs/cache-lru.md | 2 +- docs/doubly-linked-list.md | 2 +- docs/env.md | 2 +- docs/hostname.md | 2 +- docs/sql.md | 8 ++++---- docs/stream.md | 6 +++--- docs/text.md | 26 +++++++++++++------------- 11 files changed, 55 insertions(+), 53 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 11fbc7504..3b08268ab 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 --; @@ -9380,7 +9380,7 @@ Changed: Changed: - result moved to own package; -- #index imports added; +- \#index imports added; ### 2.17.0 (2021-04-21) @@ -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; diff --git a/docs/api-client.md b/docs/api-client.md index 7d732684a..1276cbcf3 100644 --- a/docs/api-client.md +++ b/docs/api-client.md @@ -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 ) @@ -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(); ``` diff --git a/docs/api.md b/docs/api.md index 7d34c33ca..86e09956b 100644 --- a/docs/api.md +++ b/docs/api.md @@ -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; ``` @@ -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: @@ -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() ); } ``` diff --git a/docs/app/application.md b/docs/app/application.md index fb2990927..64f94345a 100644 --- a/docs/app/application.md +++ b/docs/app/application.md @@ -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 @@ -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: @@ -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: @@ -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. diff --git a/docs/cache-lru.md b/docs/cache-lru.md index 1724c56b4..52154f46a 100644 --- a/docs/cache-lru.md +++ b/docs/cache-lru.md @@ -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 diff --git a/docs/doubly-linked-list.md b/docs/doubly-linked-list.md index 25209870b..f0e16f289 100644 --- a/docs/doubly-linked-list.md +++ b/docs/doubly-linked-list.md @@ -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 diff --git a/docs/env.md b/docs/env.md index 242916449..21bd175ba 100644 --- a/docs/env.md +++ b/docs/env.md @@ -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 diff --git a/docs/hostname.md b/docs/hostname.md index 12ede2e15..6d900253c 100644 --- a/docs/hostname.md +++ b/docs/hostname.md @@ -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 ) diff --git a/docs/sql.md b/docs/sql.md index 8871206bb..c2c1e7c22 100644 --- a/docs/sql.md +++ b/docs/sql.md @@ -11,7 +11,7 @@ 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 @@ -19,7 +19,7 @@ const dbh = sql.new("pgsql://user:password@host"); ```javascript import sql from "@softvisio/core/sql"; -const dbh = sql.new("sqlite:"); +const dbh = sql.new( "sqlite:" ); ``` ## Class: sql.Query @@ -27,7 +27,7 @@ const dbh = sql.new("sqlite:"); ## 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(); ``` @@ -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 diff --git a/docs/stream.md b/docs/stream.md index 4776f0678..e8d0c83ea 100644 --- a/docs/stream.md +++ b/docs/stream.md @@ -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? ) @@ -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? ) diff --git a/docs/text.md b/docs/text.md index 5a5e98f56..e71e3435d 100644 --- a/docs/text.md +++ b/docs/text.md @@ -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. @@ -126,14 +126,14 @@ Define table style. Example of `ascii` style definition: ```javascript -Table.defineStyle("ascii", { - topLine: "+-++", - headerRow: "| ||", - headerLine: "|=+|", - dataRow: "| ||", - dataLine: "|-+|", - bottomLine: "+-++", -}); +Table.defineStyle( "ascii", { + "topLine": "+-++", + "headerRow": "| ||", + "headerLine": "|=+|", + "dataRow": "| ||", + "dataLine": "|-+|", + "bottomLine": "+-++", +} ); ``` ### new Table( options )