@promptbook/documents 0.88.0-9 → 0.89.0-1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +35 -14
- package/esm/index.es.js +62 -26
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/_packages/core.index.d.ts +2 -2
- package/esm/typings/src/_packages/types.index.d.ts +10 -0
- package/esm/typings/src/config.d.ts +1 -1
- package/esm/typings/src/errors/PipelineExecutionError.d.ts +5 -0
- package/esm/typings/src/errors/utils/ErrorJson.d.ts +5 -0
- package/esm/typings/src/llm-providers/_common/utils/count-total-usage/LlmExecutionToolsWithTotalUsage.d.ts +7 -0
- package/esm/typings/src/llm-providers/_common/utils/count-total-usage/{countTotalUsage.d.ts → countUsage.d.ts} +1 -1
- package/esm/typings/src/playground/BrjappConnector.d.ts +64 -0
- package/esm/typings/src/playground/brjapp-api-schema.d.ts +12879 -0
- package/esm/typings/src/playground/playground.d.ts +5 -0
- package/esm/typings/src/remote-server/socket-types/_subtypes/PromptbookServer_Identification.d.ts +2 -1
- package/esm/typings/src/remote-server/types/RemoteServerOptions.d.ts +15 -3
- package/esm/typings/src/types/typeAliases.d.ts +2 -2
- package/esm/typings/src/utils/expectation-counters/countCharacters.d.ts +3 -0
- package/esm/typings/src/utils/expectation-counters/countLines.d.ts +3 -0
- package/esm/typings/src/utils/expectation-counters/countPages.d.ts +3 -0
- package/esm/typings/src/utils/expectation-counters/countParagraphs.d.ts +3 -0
- package/esm/typings/src/utils/expectation-counters/countSentences.d.ts +3 -0
- package/esm/typings/src/utils/expectation-counters/countWords.d.ts +3 -0
- package/package.json +2 -2
- package/umd/index.umd.js +65 -29
- package/umd/index.umd.js.map +1 -1
package/esm/typings/src/remote-server/socket-types/_subtypes/PromptbookServer_Identification.d.ts
CHANGED
|
@@ -37,7 +37,8 @@ export type PromptbookServer_AnonymousIdentification = {
|
|
|
37
37
|
/**
|
|
38
38
|
* Identifier of the end user
|
|
39
39
|
*
|
|
40
|
-
* Note:
|
|
40
|
+
* Note: This can be either some id or email or any other identifier
|
|
41
|
+
* Note: In anonymous mode, this is passed to the certain model providers to identify misuse
|
|
41
42
|
* Note: In anonymous mode, there is no need to identify yourself, nor does it change the actual configuration of LLM Tools (unlike in application mode)
|
|
42
43
|
*/
|
|
43
44
|
readonly userId?: string_user_id;
|
|
@@ -58,15 +58,27 @@ export type ApplicationRemoteServerOptions<TCustomOptions> = {
|
|
|
58
58
|
};
|
|
59
59
|
export type ApplicationRemoteServerClientOptions<TCustomOptions> = {
|
|
60
60
|
/**
|
|
61
|
-
*
|
|
61
|
+
* Identifier of the application
|
|
62
|
+
*
|
|
63
|
+
* Note: This is usefull when you use Promptbook remote server for multiple apps/frontends, if its used just for single app, use here just "app" or "your-app-name"
|
|
64
|
+
* Note: This can be some id or some semantic name like "email-agent"
|
|
62
65
|
*/
|
|
63
66
|
readonly appId: string_app_id | null;
|
|
64
67
|
/**
|
|
65
|
-
*
|
|
68
|
+
* Identifier of the end user
|
|
69
|
+
*
|
|
70
|
+
* Note: This can be either some id or email or any other identifier
|
|
71
|
+
* Note: This is also passed to the certain model providers to identify misuse
|
|
66
72
|
*/
|
|
67
73
|
readonly userId?: string_user_id;
|
|
68
74
|
/**
|
|
69
|
-
*
|
|
75
|
+
* Token of the user to verify its identity
|
|
76
|
+
*
|
|
77
|
+
* Note: This is passed for example to `createLlmExecutionTools`
|
|
78
|
+
*/
|
|
79
|
+
readonly userToken?: string_user_id;
|
|
80
|
+
/**
|
|
81
|
+
* Additional arbitrary options to identify the client or to pass custom metadata
|
|
70
82
|
*/
|
|
71
83
|
readonly customOptions?: TCustomOptions;
|
|
72
84
|
};
|
|
@@ -433,13 +433,13 @@ export type string_uuid = string & {
|
|
|
433
433
|
*
|
|
434
434
|
* @@@
|
|
435
435
|
*/
|
|
436
|
-
export type string_app_id = id;
|
|
436
|
+
export type string_app_id = id | 'app';
|
|
437
437
|
/**
|
|
438
438
|
* End user identifier
|
|
439
439
|
*
|
|
440
440
|
* @@@
|
|
441
441
|
*/
|
|
442
|
-
export type string_user_id = id;
|
|
442
|
+
export type string_user_id = id | string_email;
|
|
443
443
|
/**
|
|
444
444
|
* Semantic helper
|
|
445
445
|
*
|
|
@@ -5,3 +5,6 @@ import type { ExpectationAmount } from '../../pipeline/PipelineJson/Expectations
|
|
|
5
5
|
* @public exported from `@promptbook/utils`
|
|
6
6
|
*/
|
|
7
7
|
export declare function countCharacters(text: string): ExpectationAmount;
|
|
8
|
+
/**
|
|
9
|
+
* TODO: [🥴] Implement counting in formats - like JSON, CSV, XML,...
|
|
10
|
+
*/
|
|
@@ -7,3 +7,6 @@ import type { ExpectationAmount } from '../../pipeline/PipelineJson/Expectations
|
|
|
7
7
|
* @public exported from `@promptbook/utils`
|
|
8
8
|
*/
|
|
9
9
|
export declare function countLines(text: string): ExpectationAmount;
|
|
10
|
+
/**
|
|
11
|
+
* TODO: [🥴] Implement counting in formats - like JSON, CSV, XML,...
|
|
12
|
+
*/
|
|
@@ -7,3 +7,6 @@ import type { ExpectationAmount } from '../../pipeline/PipelineJson/Expectations
|
|
|
7
7
|
* @public exported from `@promptbook/utils`
|
|
8
8
|
*/
|
|
9
9
|
export declare function countPages(text: string): ExpectationAmount;
|
|
10
|
+
/**
|
|
11
|
+
* TODO: [🥴] Implement counting in formats - like JSON, CSV, XML,...
|
|
12
|
+
*/
|
|
@@ -5,3 +5,6 @@ import type { ExpectationAmount } from '../../pipeline/PipelineJson/Expectations
|
|
|
5
5
|
* @public exported from `@promptbook/utils`
|
|
6
6
|
*/
|
|
7
7
|
export declare function countParagraphs(text: string): ExpectationAmount;
|
|
8
|
+
/**
|
|
9
|
+
* TODO: [🥴] Implement counting in formats - like JSON, CSV, XML,...
|
|
10
|
+
*/
|
|
@@ -11,3 +11,6 @@ export declare function splitIntoSentences(text: string): ReadonlyArray<string>;
|
|
|
11
11
|
* @public exported from `@promptbook/utils`
|
|
12
12
|
*/
|
|
13
13
|
export declare function countSentences(text: string): ExpectationAmount;
|
|
14
|
+
/**
|
|
15
|
+
* TODO: [🥴] Implement counting in formats - like JSON, CSV, XML,...
|
|
16
|
+
*/
|
|
@@ -5,3 +5,6 @@ import type { ExpectationAmount } from '../../pipeline/PipelineJson/Expectations
|
|
|
5
5
|
* @public exported from `@promptbook/utils`
|
|
6
6
|
*/
|
|
7
7
|
export declare function countWords(text: string): ExpectationAmount;
|
|
8
|
+
/**
|
|
9
|
+
* TODO: [🥴] Implement counting in formats - like JSON, CSV, XML,...
|
|
10
|
+
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@promptbook/documents",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.89.0-1",
|
|
4
4
|
"description": "It's time for a paradigm shift. The future of software in plain English, French or Latin",
|
|
5
5
|
"private": false,
|
|
6
6
|
"sideEffects": false,
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"module": "./esm/index.es.js",
|
|
48
48
|
"typings": "./esm/typings/src/_packages/documents.index.d.ts",
|
|
49
49
|
"peerDependencies": {
|
|
50
|
-
"@promptbook/core": "0.
|
|
50
|
+
"@promptbook/core": "0.89.0-1"
|
|
51
51
|
},
|
|
52
52
|
"dependencies": {
|
|
53
53
|
"colors": "1.4.0",
|
package/umd/index.umd.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
(function (global, factory) {
|
|
2
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('fs/promises'), require('spacetrim'), require('child_process'), require('colors'), require('waitasecond'), require('crypto-js'), require('crypto-js/enc-hex'), require('path'), require('prettier'), require('prettier/parser-html'), require('
|
|
3
|
-
typeof define === 'function' && define.amd ? define(['exports', 'fs/promises', 'spacetrim', 'child_process', 'colors', 'waitasecond', 'crypto-js', 'crypto-js/enc-hex', 'path', 'prettier', 'prettier/parser-html', '
|
|
4
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["promptbook-documents"] = {}, global.promises, global.spaceTrim, global.child_process, global.colors, global.waitasecond, global.cryptoJs, global.hexEncoder, global.path, global.prettier, global.parserHtml, global.
|
|
5
|
-
})(this, (function (exports, promises, spaceTrim, child_process, colors, waitasecond, cryptoJs, hexEncoder, path, prettier, parserHtml,
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('fs/promises'), require('spacetrim'), require('child_process'), require('colors'), require('waitasecond'), require('crypto-js'), require('crypto-js/enc-hex'), require('path'), require('prettier'), require('prettier/parser-html'), require('crypto'), require('rxjs'), require('crypto-js/sha256'), require('mime-types'), require('papaparse')) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define(['exports', 'fs/promises', 'spacetrim', 'child_process', 'colors', 'waitasecond', 'crypto-js', 'crypto-js/enc-hex', 'path', 'prettier', 'prettier/parser-html', 'crypto', 'rxjs', 'crypto-js/sha256', 'mime-types', 'papaparse'], factory) :
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["promptbook-documents"] = {}, global.promises, global.spaceTrim, global.child_process, global.colors, global.waitasecond, global.cryptoJs, global.hexEncoder, global.path, global.prettier, global.parserHtml, global.crypto, global.rxjs, global.sha256, global.mimeTypes, global.papaparse));
|
|
5
|
+
})(this, (function (exports, promises, spaceTrim, child_process, colors, waitasecond, cryptoJs, hexEncoder, path, prettier, parserHtml, crypto, rxjs, sha256, mimeTypes, papaparse) { 'use strict';
|
|
6
6
|
|
|
7
7
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
8
8
|
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
* @generated
|
|
27
27
|
* @see https://github.com/webgptorg/promptbook
|
|
28
28
|
*/
|
|
29
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.
|
|
29
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.89.0-1';
|
|
30
30
|
/**
|
|
31
31
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
32
32
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -158,7 +158,7 @@
|
|
|
158
158
|
*
|
|
159
159
|
* @public exported from `@promptbook/core`
|
|
160
160
|
*/
|
|
161
|
-
const DEFAULT_MAX_EXECUTION_ATTEMPTS =
|
|
161
|
+
const DEFAULT_MAX_EXECUTION_ATTEMPTS = 10; // <- TODO: [🤹♂️]
|
|
162
162
|
// <- TODO: [🕝] Make also `BOOKS_DIRNAME_ALTERNATIVES`
|
|
163
163
|
/**
|
|
164
164
|
* Where to store the temporary downloads
|
|
@@ -2171,6 +2171,21 @@
|
|
|
2171
2171
|
return new SimplePipelineCollection(...promptbooks);
|
|
2172
2172
|
}
|
|
2173
2173
|
|
|
2174
|
+
/**
|
|
2175
|
+
* Generates random token
|
|
2176
|
+
*
|
|
2177
|
+
* Note: This function is cryptographically secure (it uses crypto.randomBytes internally)
|
|
2178
|
+
*
|
|
2179
|
+
* @private internal helper function
|
|
2180
|
+
* @returns secure random token
|
|
2181
|
+
*/
|
|
2182
|
+
function $randomToken(randomness) {
|
|
2183
|
+
return crypto.randomBytes(randomness).toString('hex');
|
|
2184
|
+
}
|
|
2185
|
+
/**
|
|
2186
|
+
* TODO: Maybe use nanoid instead https://github.com/ai/nanoid
|
|
2187
|
+
*/
|
|
2188
|
+
|
|
2174
2189
|
/**
|
|
2175
2190
|
* This error indicates errors during the execution of the pipeline
|
|
2176
2191
|
*
|
|
@@ -2178,11 +2193,17 @@
|
|
|
2178
2193
|
*/
|
|
2179
2194
|
class PipelineExecutionError extends Error {
|
|
2180
2195
|
constructor(message) {
|
|
2196
|
+
// Added id parameter
|
|
2181
2197
|
super(message);
|
|
2182
2198
|
this.name = 'PipelineExecutionError';
|
|
2199
|
+
// TODO: [🐙] DRY - Maybe $randomId
|
|
2200
|
+
this.id = `error-${$randomToken(8 /* <- TODO: To global config + Use Base58 to avoid simmilar char conflicts */)}`;
|
|
2183
2201
|
Object.setPrototypeOf(this, PipelineExecutionError.prototype);
|
|
2184
2202
|
}
|
|
2185
2203
|
}
|
|
2204
|
+
/**
|
|
2205
|
+
* TODO: !!!!!! Add id to all errors
|
|
2206
|
+
*/
|
|
2186
2207
|
|
|
2187
2208
|
/**
|
|
2188
2209
|
* Determine if the pipeline is fully prepared
|
|
@@ -2221,21 +2242,6 @@
|
|
|
2221
2242
|
* - [♨] Are tasks prepared
|
|
2222
2243
|
*/
|
|
2223
2244
|
|
|
2224
|
-
/**
|
|
2225
|
-
* Generates random token
|
|
2226
|
-
*
|
|
2227
|
-
* Note: This function is cryptographically secure (it uses crypto.randomBytes internally)
|
|
2228
|
-
*
|
|
2229
|
-
* @private internal helper function
|
|
2230
|
-
* @returns secure random token
|
|
2231
|
-
*/
|
|
2232
|
-
function $randomToken(randomness) {
|
|
2233
|
-
return crypto.randomBytes(randomness).toString('hex');
|
|
2234
|
-
}
|
|
2235
|
-
/**
|
|
2236
|
-
* TODO: Maybe use nanoid instead https://github.com/ai/nanoid
|
|
2237
|
-
*/
|
|
2238
|
-
|
|
2239
2245
|
/**
|
|
2240
2246
|
* Recursively converts JSON strings to JSON objects
|
|
2241
2247
|
|
|
@@ -2426,7 +2432,7 @@
|
|
|
2426
2432
|
* @public exported from `@promptbook/utils`
|
|
2427
2433
|
*/
|
|
2428
2434
|
function deserializeError(error) {
|
|
2429
|
-
const { name, stack } = error;
|
|
2435
|
+
const { name, stack, id } = error; // Added id
|
|
2430
2436
|
let { message } = error;
|
|
2431
2437
|
let ErrorClass = ALL_ERRORS[error.name];
|
|
2432
2438
|
if (ErrorClass === undefined) {
|
|
@@ -2441,7 +2447,9 @@
|
|
|
2441
2447
|
${block(stack || '')}
|
|
2442
2448
|
`);
|
|
2443
2449
|
}
|
|
2444
|
-
|
|
2450
|
+
const deserializedError = new ErrorClass(message);
|
|
2451
|
+
deserializedError.id = id; // Assign id to the error object
|
|
2452
|
+
return deserializedError;
|
|
2445
2453
|
}
|
|
2446
2454
|
|
|
2447
2455
|
/**
|
|
@@ -2491,6 +2499,7 @@
|
|
|
2491
2499
|
*/
|
|
2492
2500
|
function createTask(options) {
|
|
2493
2501
|
const { taskType, taskProcessCallback } = options;
|
|
2502
|
+
// TODO: [🐙] DRY
|
|
2494
2503
|
const taskId = `${taskType.toLowerCase().substring(0, 4)}-${$randomToken(8 /* <- TODO: To global config + Use Base58 to avoid simmilar char conflicts */)}`;
|
|
2495
2504
|
let status = 'RUNNING';
|
|
2496
2505
|
const createdAt = new Date();
|
|
@@ -2523,7 +2532,7 @@
|
|
|
2523
2532
|
assertsTaskSuccessful(executionResult);
|
|
2524
2533
|
status = 'FINISHED';
|
|
2525
2534
|
currentValue = jsonStringsToJsons(executionResult);
|
|
2526
|
-
// <- TODO:
|
|
2535
|
+
// <- TODO: [🧠] Is this a good idea to convert JSON strins to JSONs?
|
|
2527
2536
|
partialResultSubject.next(executionResult);
|
|
2528
2537
|
}
|
|
2529
2538
|
catch (error) {
|
|
@@ -2587,19 +2596,21 @@
|
|
|
2587
2596
|
*/
|
|
2588
2597
|
function serializeError(error) {
|
|
2589
2598
|
const { name, message, stack } = error;
|
|
2599
|
+
const { id } = error;
|
|
2590
2600
|
if (!Object.keys(ALL_ERRORS).includes(name)) {
|
|
2591
2601
|
console.error(spaceTrim__default["default"]((block) => `
|
|
2592
|
-
|
|
2602
|
+
|
|
2593
2603
|
Cannot serialize error with name "${name}"
|
|
2594
2604
|
|
|
2595
2605
|
${block(stack || message)}
|
|
2596
|
-
|
|
2606
|
+
|
|
2597
2607
|
`));
|
|
2598
2608
|
}
|
|
2599
2609
|
return {
|
|
2600
2610
|
name: name,
|
|
2601
2611
|
message,
|
|
2602
2612
|
stack,
|
|
2613
|
+
id, // Include id in the serialized object
|
|
2603
2614
|
};
|
|
2604
2615
|
}
|
|
2605
2616
|
|
|
@@ -2742,8 +2753,9 @@
|
|
|
2742
2753
|
* @returns LLM tools with same functionality with added total cost counting
|
|
2743
2754
|
* @public exported from `@promptbook/core`
|
|
2744
2755
|
*/
|
|
2745
|
-
function
|
|
2756
|
+
function countUsage(llmTools) {
|
|
2746
2757
|
let totalUsage = ZERO_USAGE;
|
|
2758
|
+
const spending = new rxjs.Subject();
|
|
2747
2759
|
const proxyTools = {
|
|
2748
2760
|
get title() {
|
|
2749
2761
|
// TODO: [🧠] Maybe put here some suffix
|
|
@@ -2753,12 +2765,15 @@
|
|
|
2753
2765
|
// TODO: [🧠] Maybe put here some suffix
|
|
2754
2766
|
return llmTools.description;
|
|
2755
2767
|
},
|
|
2756
|
-
|
|
2768
|
+
checkConfiguration() {
|
|
2757
2769
|
return /* not await */ llmTools.checkConfiguration();
|
|
2758
2770
|
},
|
|
2759
2771
|
listModels() {
|
|
2760
2772
|
return /* not await */ llmTools.listModels();
|
|
2761
2773
|
},
|
|
2774
|
+
spending() {
|
|
2775
|
+
return spending.asObservable();
|
|
2776
|
+
},
|
|
2762
2777
|
getTotalUsage() {
|
|
2763
2778
|
// <- Note: [🥫] Not using getter `get totalUsage` but `getTotalUsage` to allow this object to be proxied
|
|
2764
2779
|
return totalUsage;
|
|
@@ -2769,6 +2784,7 @@
|
|
|
2769
2784
|
// console.info('[🚕] callChatModel through countTotalUsage');
|
|
2770
2785
|
const promptResult = await llmTools.callChatModel(prompt);
|
|
2771
2786
|
totalUsage = addUsage(totalUsage, promptResult.usage);
|
|
2787
|
+
spending.next(promptResult.usage);
|
|
2772
2788
|
return promptResult;
|
|
2773
2789
|
};
|
|
2774
2790
|
}
|
|
@@ -2777,6 +2793,7 @@
|
|
|
2777
2793
|
// console.info('[🚕] callCompletionModel through countTotalUsage');
|
|
2778
2794
|
const promptResult = await llmTools.callCompletionModel(prompt);
|
|
2779
2795
|
totalUsage = addUsage(totalUsage, promptResult.usage);
|
|
2796
|
+
spending.next(promptResult.usage);
|
|
2780
2797
|
return promptResult;
|
|
2781
2798
|
};
|
|
2782
2799
|
}
|
|
@@ -2785,6 +2802,7 @@
|
|
|
2785
2802
|
// console.info('[🚕] callEmbeddingModel through countTotalUsage');
|
|
2786
2803
|
const promptResult = await llmTools.callEmbeddingModel(prompt);
|
|
2787
2804
|
totalUsage = addUsage(totalUsage, promptResult.usage);
|
|
2805
|
+
spending.next(promptResult.usage);
|
|
2788
2806
|
return promptResult;
|
|
2789
2807
|
};
|
|
2790
2808
|
}
|
|
@@ -3671,7 +3689,7 @@
|
|
|
3671
3689
|
// TODO: [🚐] Make arrayable LLMs -> single LLM DRY
|
|
3672
3690
|
const _llms = arrayableToArray(tools.llm);
|
|
3673
3691
|
const llmTools = _llms.length === 1 ? _llms[0] : joinLlmExecutionTools(..._llms);
|
|
3674
|
-
const llmToolsWithUsage =
|
|
3692
|
+
const llmToolsWithUsage = countUsage(llmTools);
|
|
3675
3693
|
// <- TODO: [🌯]
|
|
3676
3694
|
/*
|
|
3677
3695
|
TODO: [🧠][🪑][🔃] Should this be done or not
|
|
@@ -4501,6 +4519,9 @@
|
|
|
4501
4519
|
text = text.replace(/\p{Extended_Pictographic}(\u{200D}\p{Extended_Pictographic})*/gu, '-');
|
|
4502
4520
|
return text.length;
|
|
4503
4521
|
}
|
|
4522
|
+
/**
|
|
4523
|
+
* TODO: [🥴] Implement counting in formats - like JSON, CSV, XML,...
|
|
4524
|
+
*/
|
|
4504
4525
|
|
|
4505
4526
|
/**
|
|
4506
4527
|
* Number of characters per standard line with 11pt Arial font size.
|
|
@@ -4532,6 +4553,9 @@
|
|
|
4532
4553
|
const lines = text.split('\n');
|
|
4533
4554
|
return lines.reduce((count, line) => count + Math.ceil(line.length / CHARACTERS_PER_STANDARD_LINE), 0);
|
|
4534
4555
|
}
|
|
4556
|
+
/**
|
|
4557
|
+
* TODO: [🥴] Implement counting in formats - like JSON, CSV, XML,...
|
|
4558
|
+
*/
|
|
4535
4559
|
|
|
4536
4560
|
/**
|
|
4537
4561
|
* Counts number of pages in the text
|
|
@@ -4543,6 +4567,9 @@
|
|
|
4543
4567
|
function countPages(text) {
|
|
4544
4568
|
return Math.ceil(countLines(text) / LINES_PER_STANDARD_PAGE);
|
|
4545
4569
|
}
|
|
4570
|
+
/**
|
|
4571
|
+
* TODO: [🥴] Implement counting in formats - like JSON, CSV, XML,...
|
|
4572
|
+
*/
|
|
4546
4573
|
|
|
4547
4574
|
/**
|
|
4548
4575
|
* Counts number of paragraphs in the text
|
|
@@ -4552,6 +4579,9 @@
|
|
|
4552
4579
|
function countParagraphs(text) {
|
|
4553
4580
|
return text.split(/\n\s*\n/).filter((paragraph) => paragraph.trim() !== '').length;
|
|
4554
4581
|
}
|
|
4582
|
+
/**
|
|
4583
|
+
* TODO: [🥴] Implement counting in formats - like JSON, CSV, XML,...
|
|
4584
|
+
*/
|
|
4555
4585
|
|
|
4556
4586
|
/**
|
|
4557
4587
|
* Split text into sentences
|
|
@@ -4569,6 +4599,9 @@
|
|
|
4569
4599
|
function countSentences(text) {
|
|
4570
4600
|
return splitIntoSentences(text).length;
|
|
4571
4601
|
}
|
|
4602
|
+
/**
|
|
4603
|
+
* TODO: [🥴] Implement counting in formats - like JSON, CSV, XML,...
|
|
4604
|
+
*/
|
|
4572
4605
|
|
|
4573
4606
|
/**
|
|
4574
4607
|
* Counts number of words in the text
|
|
@@ -4582,6 +4615,9 @@
|
|
|
4582
4615
|
text = text.replace(/([a-z])([A-Z])/g, '$1 $2');
|
|
4583
4616
|
return text.split(/[^a-zа-я0-9]+/i).filter((word) => word.length > 0).length;
|
|
4584
4617
|
}
|
|
4618
|
+
/**
|
|
4619
|
+
* TODO: [🥴] Implement counting in formats - like JSON, CSV, XML,...
|
|
4620
|
+
*/
|
|
4585
4621
|
|
|
4586
4622
|
/**
|
|
4587
4623
|
* Index of all counter functions
|