@athree/helpers 2.0.1 → 2.1.0
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/out/main/index.d.ts +5 -0
- package/out/main/index.js +5 -0
- package/out/main/index.js.map +1 -1
- package/out/main/json.d.ts +1 -0
- package/out/main/json.js +9 -0
- package/out/main/json.js.map +1 -0
- package/out/main/llm.d.ts +6 -0
- package/out/main/llm.js +27 -0
- package/out/main/llm.js.map +1 -0
- package/out/main/math.d.ts +1 -0
- package/out/main/math.js +4 -0
- package/out/main/math.js.map +1 -0
- package/out/main/throttle.d.ts +1 -0
- package/out/main/throttle.js +16 -0
- package/out/main/throttle.js.map +1 -0
- package/out/main/time.d.ts +1 -0
- package/out/main/time.js +11 -0
- package/out/main/time.js.map +1 -0
- package/package.json +6 -1
package/out/main/index.d.ts
CHANGED
|
@@ -3,5 +3,10 @@ export * from './compare.js';
|
|
|
3
3
|
export * from './error.js';
|
|
4
4
|
export * from './extract.js';
|
|
5
5
|
export * from './id.js';
|
|
6
|
+
export * from './json.js';
|
|
7
|
+
export * from './llm.js';
|
|
6
8
|
export * from './markdown.js';
|
|
9
|
+
export * from './math.js';
|
|
10
|
+
export * from './throttle.js';
|
|
11
|
+
export * from './time.js';
|
|
7
12
|
export * from './workflow.js';
|
package/out/main/index.js
CHANGED
|
@@ -3,6 +3,11 @@ export * from './compare.js';
|
|
|
3
3
|
export * from './error.js';
|
|
4
4
|
export * from './extract.js';
|
|
5
5
|
export * from './id.js';
|
|
6
|
+
export * from './json.js';
|
|
7
|
+
export * from './llm.js';
|
|
6
8
|
export * from './markdown.js';
|
|
9
|
+
export * from './math.js';
|
|
10
|
+
export * from './throttle.js';
|
|
11
|
+
export * from './time.js';
|
|
7
12
|
export * from './workflow.js';
|
|
8
13
|
//# sourceMappingURL=index.js.map
|
package/out/main/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/main/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,SAAS,CAAC;AACxB,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/main/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC;AACzB,cAAc,eAAe,CAAC;AAC9B,cAAc,WAAW,CAAC;AAC1B,cAAc,eAAe,CAAC;AAC9B,cAAc,WAAW,CAAC;AAC1B,cAAc,eAAe,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function tryParseJson<T>(text: string, defaultValue: T): T;
|
package/out/main/json.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"json.js","sourceRoot":"","sources":["../../src/main/json.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,YAAY,CAAI,IAAY,EAAE,YAAe;IACzD,IAAI,CAAC;QACD,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAC5B,CAAC;IAAC,MAAM,CAAC;QACL,OAAO,YAAY,CAAC;IACxB,CAAC;AACL,CAAC"}
|
package/out/main/llm.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export function parseTextContent(input) {
|
|
2
|
+
const result = [];
|
|
3
|
+
const chunks = input.split(/(<\/?thinking>)/);
|
|
4
|
+
let currentPart = { type: 'text', text: '' };
|
|
5
|
+
for (const chunk of chunks) {
|
|
6
|
+
if (chunk === '<thinking>') {
|
|
7
|
+
flushPart(result, currentPart);
|
|
8
|
+
currentPart = { type: 'thinking', text: '', finished: false };
|
|
9
|
+
}
|
|
10
|
+
else if (chunk === '</thinking>') {
|
|
11
|
+
currentPart.finished = true;
|
|
12
|
+
flushPart(result, currentPart);
|
|
13
|
+
currentPart = { type: 'text', text: '' };
|
|
14
|
+
}
|
|
15
|
+
else if (chunk) {
|
|
16
|
+
currentPart.text += chunk;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
flushPart(result, currentPart);
|
|
20
|
+
return result;
|
|
21
|
+
}
|
|
22
|
+
function flushPart(result, part) {
|
|
23
|
+
if (part.text) {
|
|
24
|
+
result.push(part);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=llm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"llm.js","sourceRoot":"","sources":["../../src/main/llm.ts"],"names":[],"mappings":"AAMA,MAAM,UAAU,gBAAgB,CAAC,KAAa;IAC1C,MAAM,MAAM,GAAkB,EAAE,CAAC;IACjC,MAAM,MAAM,GAAG,KAAK,CAAC,KAAK,CAAC,iBAAiB,CAAC,CAAC;IAC9C,IAAI,WAAW,GAAgB,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC;IAC1D,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;QACzB,IAAI,KAAK,KAAK,YAAY,EAAE,CAAC;YACzB,SAAS,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;YAC/B,WAAW,GAAG,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,EAAE,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC;QAClE,CAAC;aAAM,IAAI,KAAK,KAAK,aAAa,EAAE,CAAC;YACjC,WAAW,CAAC,QAAQ,GAAG,IAAI,CAAC;YAC5B,SAAS,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;YAC/B,WAAW,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC;QAC7C,CAAC;aAAM,IAAI,KAAK,EAAE,CAAC;YACf,WAAW,CAAC,IAAI,IAAI,KAAK,CAAC;QAC9B,CAAC;IACL,CAAC;IACD,SAAS,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;IAC/B,OAAO,MAAM,CAAC;AAClB,CAAC;AAED,SAAS,SAAS,CAAC,MAAqB,EAAE,IAAiB;IACvD,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC;QACZ,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACtB,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function clamp(value: number, min: number, max: number): number;
|
package/out/main/math.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"math.js","sourceRoot":"","sources":["../../src/main/math.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,KAAK,CAAC,KAAa,EAAE,GAAW,EAAE,GAAW;IACzD,OAAO,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC,CAAC;AAC/C,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function throttle(delay: number): (_target: any, _propertyKey: string, descriptor: PropertyDescriptor) => void;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export function throttle(delay) {
|
|
2
|
+
return (_target, _propertyKey, descriptor) => {
|
|
3
|
+
let timer = null;
|
|
4
|
+
const originalMethod = descriptor.value;
|
|
5
|
+
descriptor.value = function throttled(...args) {
|
|
6
|
+
if (timer != null) {
|
|
7
|
+
return;
|
|
8
|
+
}
|
|
9
|
+
timer = setTimeout(() => {
|
|
10
|
+
timer = null;
|
|
11
|
+
originalMethod.apply(this, args);
|
|
12
|
+
}, delay);
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=throttle.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"throttle.js","sourceRoot":"","sources":["../../src/main/throttle.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,QAAQ,CAAC,KAAa;IAClC,OAAO,CAAC,OAAY,EAAE,YAAoB,EAAE,UAA8B,EAAE,EAAE;QAC1E,IAAI,KAAK,GAAQ,IAAI,CAAC;QACtB,MAAM,cAAc,GAAG,UAAU,CAAC,KAAK,CAAC;QACxC,UAAU,CAAC,KAAK,GAAG,SAAS,SAAS,CAAC,GAAG,IAAW;YAChD,IAAI,KAAK,IAAI,IAAI,EAAE,CAAC;gBAChB,OAAO;YACX,CAAC;YACD,KAAK,GAAG,UAAU,CAAC,GAAG,EAAE;gBACpB,KAAK,GAAG,IAAI,CAAC;gBACb,cAAc,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;YACrC,CAAC,EAAE,KAAK,CAAC,CAAC;QACd,CAAC,CAAC;IACN,CAAC,CAAC;AACN,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function formatDuration(ms: number): string;
|
package/out/main/time.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export function formatDuration(ms) {
|
|
2
|
+
const hours = Math.floor(ms / 3_600_000);
|
|
3
|
+
const minutes = Math.floor((ms % 3_600_000) / 60_000);
|
|
4
|
+
const seconds = (ms % 60_000) / 1000;
|
|
5
|
+
return [
|
|
6
|
+
hours > 0 ? `${hours}h` : null,
|
|
7
|
+
minutes > 0 ? `${minutes}m` : null,
|
|
8
|
+
seconds > 0 ? `${seconds.toFixed(1)}s` : null,
|
|
9
|
+
].filter(Boolean).join(' ');
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=time.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"time.js","sourceRoot":"","sources":["../../src/main/time.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,cAAc,CAAC,EAAU;IACrC,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,EAAE,GAAG,SAAS,CAAC,CAAC;IACzC,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,SAAS,CAAC,GAAG,MAAM,CAAC,CAAC;IACtD,MAAM,OAAO,GAAG,CAAC,EAAE,GAAG,MAAM,CAAC,GAAG,IAAI,CAAC;IACrC,OAAO;QACH,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,KAAK,GAAG,CAAC,CAAC,CAAC,IAAI;QAC9B,OAAO,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,OAAO,GAAG,CAAC,CAAC,CAAC,IAAI;QAClC,OAAO,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI;KAChD,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAChC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@athree/helpers",
|
|
3
|
-
"version": "2.0
|
|
3
|
+
"version": "2.1.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"exports": {
|
|
@@ -11,5 +11,10 @@
|
|
|
11
11
|
],
|
|
12
12
|
"scripts": {
|
|
13
13
|
"clean": "rm -rf out/ *.tsbuildinfo"
|
|
14
|
+
},
|
|
15
|
+
"dependencies": {
|
|
16
|
+
"@types/markdown-it": "^14.1.2",
|
|
17
|
+
"markdown-it": "^14.1.0",
|
|
18
|
+
"nanoid": "^5.1.3"
|
|
14
19
|
}
|
|
15
20
|
}
|