coding-agent-benchmarks 0.5.0 → 0.5.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 +7 -3
- package/dist/evaluator.d.ts +1 -0
- package/dist/evaluator.d.ts.map +1 -1
- package/dist/evaluator.js +1 -1
- package/dist/evaluator.js.map +1 -1
- package/dist/longest-common-subsequence.d.ts +45 -0
- package/dist/longest-common-subsequence.d.ts.map +1 -0
- package/dist/longest-common-subsequence.js +162 -0
- package/dist/longest-common-subsequence.js.map +1 -0
- package/dist/longestCommonSubsequence.d.ts +39 -0
- package/dist/longestCommonSubsequence.d.ts.map +1 -0
- package/dist/longestCommonSubsequence.js +166 -0
- package/dist/longestCommonSubsequence.js.map +1 -0
- package/dist/runner.js +8 -4
- package/dist/runner.js.map +1 -1
- package/dist/types.d.ts +5 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/user-registration/example.d.ts +2 -0
- package/dist/user-registration/example.d.ts.map +1 -0
- package/dist/user-registration/example.js +41 -0
- package/dist/user-registration/example.js.map +1 -0
- package/dist/user-registration/index.d.ts +9 -0
- package/dist/user-registration/index.d.ts.map +1 -0
- package/dist/user-registration/index.js +22 -0
- package/dist/user-registration/index.js.map +1 -0
- package/dist/user-registration/services/email-service.d.ts +13 -0
- package/dist/user-registration/services/email-service.d.ts.map +1 -0
- package/dist/user-registration/services/email-service.js +34 -0
- package/dist/user-registration/services/email-service.js.map +1 -0
- package/dist/user-registration/services/password-service.d.ts +5 -0
- package/dist/user-registration/services/password-service.d.ts.map +1 -0
- package/dist/user-registration/services/password-service.js +23 -0
- package/dist/user-registration/services/password-service.js.map +1 -0
- package/dist/user-registration/services/registration-service.d.ts +19 -0
- package/dist/user-registration/services/registration-service.d.ts.map +1 -0
- package/dist/user-registration/services/registration-service.js +60 -0
- package/dist/user-registration/services/registration-service.js.map +1 -0
- package/dist/user-registration/services/user-repository.d.ts +12 -0
- package/dist/user-registration/services/user-repository.d.ts.map +1 -0
- package/dist/user-registration/services/user-repository.js +24 -0
- package/dist/user-registration/services/user-repository.js.map +1 -0
- package/dist/user-registration/types.d.ts +26 -0
- package/dist/user-registration/types.d.ts.map +1 -0
- package/dist/user-registration/types.js +18 -0
- package/dist/user-registration/types.js.map +1 -0
- package/dist/user-registration/validators/email-validator.d.ts +3 -0
- package/dist/user-registration/validators/email-validator.d.ts.map +1 -0
- package/dist/user-registration/validators/email-validator.js +22 -0
- package/dist/user-registration/validators/email-validator.js.map +1 -0
- package/dist/user-registration/validators/password-validator.d.ts +3 -0
- package/dist/user-registration/validators/password-validator.d.ts.map +1 -0
- package/dist/user-registration/validators/password-validator.js +36 -0
- package/dist/user-registration/validators/password-validator.js.map +1 -0
- package/dist/user-registration/validators/required-fields-validator.d.ts +3 -0
- package/dist/user-registration/validators/required-fields-validator.d.ts.map +1 -0
- package/dist/user-registration/validators/required-fields-validator.js +17 -0
- package/dist/user-registration/validators/required-fields-validator.js.map +1 -0
- package/dist/utils/dataFetcher.d.ts +21 -0
- package/dist/utils/dataFetcher.d.ts.map +1 -0
- package/dist/utils/dataFetcher.js +71 -0
- package/dist/utils/dataFetcher.js.map +1 -0
- package/dist/utils/imageProcessor.d.ts +16 -0
- package/dist/utils/imageProcessor.d.ts.map +1 -0
- package/dist/utils/imageProcessor.js +121 -0
- package/dist/utils/imageProcessor.js.map +1 -0
- package/dist/utils/lcs.d.ts +37 -0
- package/dist/utils/lcs.d.ts.map +1 -0
- package/dist/utils/lcs.js +139 -0
- package/dist/utils/lcs.js.map +1 -0
- package/dist/utils/notifications.d.ts +2 -0
- package/dist/utils/notifications.d.ts.map +1 -0
- package/dist/utils/notifications.js +8 -0
- package/dist/utils/notifications.js.map +1 -0
- package/dist/utils/timeUtils.d.ts +16 -1
- package/dist/utils/timeUtils.d.ts.map +1 -1
- package/dist/utils/timeUtils.js +54 -17
- package/dist/utils/timeUtils.js.map +1 -1
- package/dist/utils/userReport.d.ts +10 -0
- package/dist/utils/userReport.d.ts.map +1 -0
- package/dist/utils/userReport.js +19 -0
- package/dist/utils/userReport.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.fetchUserWithPosts = void 0;
|
|
4
|
+
const fetchWithErrorHandling = async (url) => {
|
|
5
|
+
try {
|
|
6
|
+
const response = await fetch(url);
|
|
7
|
+
if (!response.ok) {
|
|
8
|
+
const error = {
|
|
9
|
+
message: `HTTP error ${response.status}: ${response.statusText}`,
|
|
10
|
+
endpoint: url,
|
|
11
|
+
statusCode: response.status,
|
|
12
|
+
};
|
|
13
|
+
throw new Error(JSON.stringify(error));
|
|
14
|
+
}
|
|
15
|
+
const data = await response.json();
|
|
16
|
+
return data;
|
|
17
|
+
}
|
|
18
|
+
catch (error) {
|
|
19
|
+
if (error instanceof Error && error.message.startsWith('{')) {
|
|
20
|
+
throw error;
|
|
21
|
+
}
|
|
22
|
+
throw new Error(JSON.stringify({
|
|
23
|
+
message: `Network error: ${error}`,
|
|
24
|
+
endpoint: url,
|
|
25
|
+
}));
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
const fetchUserWithPosts = async (userId, baseUrl = 'https://jsonplaceholder.typicode.com') => {
|
|
29
|
+
try {
|
|
30
|
+
// Step 1: Fetch user information
|
|
31
|
+
const user = await fetchWithErrorHandling(`${baseUrl}/users/${userId}`);
|
|
32
|
+
// Step 2: Fetch user's posts
|
|
33
|
+
const posts = await fetchWithErrorHandling(`${baseUrl}/posts?userId=${userId}`);
|
|
34
|
+
// Step 3: Enrich each post with comment counts
|
|
35
|
+
const enrichedPosts = await Promise.all(posts.map(async (post) => {
|
|
36
|
+
try {
|
|
37
|
+
const comments = await fetchWithErrorHandling(`${baseUrl}/comments?postId=${post.id}`);
|
|
38
|
+
return {
|
|
39
|
+
...post,
|
|
40
|
+
commentCount: comments.length,
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
catch (error) {
|
|
44
|
+
// If comment fetching fails, return post with zero comments
|
|
45
|
+
console.warn(`Failed to fetch comments for post ${post.id}:`, error);
|
|
46
|
+
return {
|
|
47
|
+
...post,
|
|
48
|
+
commentCount: 0,
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
}));
|
|
52
|
+
return {
|
|
53
|
+
user,
|
|
54
|
+
posts: enrichedPosts,
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
catch (error) {
|
|
58
|
+
if (error instanceof Error) {
|
|
59
|
+
try {
|
|
60
|
+
const fetchError = JSON.parse(error.message);
|
|
61
|
+
throw new Error(`Failed to fetch user data: ${fetchError.message} (endpoint: ${fetchError.endpoint})`);
|
|
62
|
+
}
|
|
63
|
+
catch {
|
|
64
|
+
throw new Error(`Failed to fetch user data: ${error.message}`);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
throw new Error(`Failed to fetch user data: ${error}`);
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
exports.fetchUserWithPosts = fetchUserWithPosts;
|
|
71
|
+
//# sourceMappingURL=dataFetcher.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dataFetcher.js","sourceRoot":"","sources":["../../src/utils/dataFetcher.ts"],"names":[],"mappings":";;;AAgCA,MAAM,sBAAsB,GAAG,KAAK,EAAK,GAAW,EAAc,EAAE;IAClE,IAAI,CAAC;QACH,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,GAAG,CAAC,CAAC;QAElC,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;YACjB,MAAM,KAAK,GAAe;gBACxB,OAAO,EAAE,cAAc,QAAQ,CAAC,MAAM,KAAK,QAAQ,CAAC,UAAU,EAAE;gBAChE,QAAQ,EAAE,GAAG;gBACb,UAAU,EAAE,QAAQ,CAAC,MAAM;aAC5B,CAAC;YACF,MAAM,IAAI,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,K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C,CAAC;gBACrE,OAAO;oBACL,GAAG,IAAI;oBACP,YAAY,EAAE,CAAC;iBAChB,CAAC;YACJ,CAAC;QACH,CAAC,CAAC,CACH,CAAC;QAEF,OAAO;YACL,IAAI;YACJ,KAAK,EAAE,aAAa;SACrB,CAAC;IACJ,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,KAAK,YAAY,KAAK,EAAE,CAAC;YAC3B,IAAI,CAAC;gBACH,MAAM,UAAU,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,OAAO,CAAe,CAAC;gBAC3D,MAAM,IAAI,KAAK,CAAC,8BAA8B,UAAU,CAAC,OAAO,eAAe,UAAU,CAAC,QAAQ,GAAG,CAAC,CAAC;YACzG,CAAC;YAAC,MAAM,CAAC;gBACP,MAAM,IAAI,KAAK,CAAC,8BAA8B,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;YACjE,CAAC;QACH,CAAC;QACD,MAAM,IAAI,KAAK,CAAC,8BAA8B,KAAK,EAAE,CAAC,CAAC;IACzD,CAAC;AACH,CAAC,CAAC;AAjDW,QAAA,kBAAkB,sBAiD7B"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
interface ImageProcessingOptions {
|
|
2
|
+
readonly width?: number;
|
|
3
|
+
readonly height?: number;
|
|
4
|
+
readonly fit?: 'cover' | 'contain' | 'fill' | 'inside' | 'outside';
|
|
5
|
+
readonly format?: 'jpeg' | 'png' | 'webp';
|
|
6
|
+
readonly quality?: number;
|
|
7
|
+
}
|
|
8
|
+
interface ProcessingResult {
|
|
9
|
+
readonly filePath: string;
|
|
10
|
+
readonly success: boolean;
|
|
11
|
+
readonly outputPath?: string;
|
|
12
|
+
readonly error?: string;
|
|
13
|
+
}
|
|
14
|
+
export declare const processBatchImages: (inputPaths: readonly string[], outputDir: string, options?: ImageProcessingOptions) => Promise<readonly ProcessingResult[]>;
|
|
15
|
+
export type { ImageProcessingOptions, ProcessingResult };
|
|
16
|
+
//# sourceMappingURL=imageProcessor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"imageProcessor.d.ts","sourceRoot":"","sources":["../../src/utils/imageProcessor.ts"],"names":[],"mappings":"AAIA,UAAU,sBAAsB;IAC9B,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,GAAG,CAAC,EAAE,OAAO,GAAG,SAAS,GAAG,MAAM,GAAG,QAAQ,GAAG,SAAS,CAAC;IACnE,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,KAAK,GAAG,MAAM,CAAC;IAC1C,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED,UAAU,gBAAgB;IACxB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;CACzB;AAwFD,eAAO,MAAM,kBAAkB,GAC7B,YAAY,SAAS,MAAM,EAAE,EAC7B,WAAW,MAAM,EACjB,UAAS,sBAA2B,KACnC,OAAO,CAAC,SAAS,gBAAgB,EAAE,CASrC,CAAC;AAEF,YAAY,EAAE,sBAAsB,EAAE,gBAAgB,EAAE,CAAC"}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.processBatchImages = void 0;
|
|
40
|
+
const fs = __importStar(require("fs/promises"));
|
|
41
|
+
const path = __importStar(require("path"));
|
|
42
|
+
const sharp_1 = __importDefault(require("sharp"));
|
|
43
|
+
const SUPPORTED_FORMATS = ['jpg', 'jpeg', 'png', 'webp', 'gif', 'tiff', 'svg'];
|
|
44
|
+
const getFileExtension = (filePath) => {
|
|
45
|
+
return path.extname(filePath).toLowerCase().slice(1);
|
|
46
|
+
};
|
|
47
|
+
const isValidImageFormat = (filePath) => {
|
|
48
|
+
const ext = getFileExtension(filePath);
|
|
49
|
+
return SUPPORTED_FORMATS.includes(ext);
|
|
50
|
+
};
|
|
51
|
+
const ensureDirectoryExists = async (dirPath) => {
|
|
52
|
+
try {
|
|
53
|
+
await fs.access(dirPath);
|
|
54
|
+
}
|
|
55
|
+
catch {
|
|
56
|
+
await fs.mkdir(dirPath, { recursive: true });
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
const processImage = async (inputPath, outputDir, options) => {
|
|
60
|
+
try {
|
|
61
|
+
if (!isValidImageFormat(inputPath)) {
|
|
62
|
+
return {
|
|
63
|
+
filePath: inputPath,
|
|
64
|
+
success: false,
|
|
65
|
+
error: `Unsupported image format. Supported: ${SUPPORTED_FORMATS.join(', ')}`
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
const fileExists = await fs.access(inputPath)
|
|
69
|
+
.then(() => true)
|
|
70
|
+
.catch(() => false);
|
|
71
|
+
if (!fileExists) {
|
|
72
|
+
return {
|
|
73
|
+
filePath: inputPath,
|
|
74
|
+
success: false,
|
|
75
|
+
error: 'File does not exist'
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
await ensureDirectoryExists(outputDir);
|
|
79
|
+
const fileName = path.basename(inputPath);
|
|
80
|
+
const fileNameWithoutExt = path.parse(fileName).name;
|
|
81
|
+
const outputFormat = options.format || getFileExtension(inputPath);
|
|
82
|
+
const outputFileName = `${fileNameWithoutExt}.${outputFormat}`;
|
|
83
|
+
const outputPath = path.join(outputDir, outputFileName);
|
|
84
|
+
let transform = (0, sharp_1.default)(inputPath);
|
|
85
|
+
if (options.width || options.height) {
|
|
86
|
+
transform = transform.resize({
|
|
87
|
+
width: options.width,
|
|
88
|
+
height: options.height,
|
|
89
|
+
fit: options.fit || 'cover'
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
if (options.format) {
|
|
93
|
+
transform = transform.toFormat(options.format, {
|
|
94
|
+
quality: options.quality || 80
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
await transform.toFile(outputPath);
|
|
98
|
+
return {
|
|
99
|
+
filePath: inputPath,
|
|
100
|
+
success: true,
|
|
101
|
+
outputPath
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
catch (error) {
|
|
105
|
+
return {
|
|
106
|
+
filePath: inputPath,
|
|
107
|
+
success: false,
|
|
108
|
+
error: error instanceof Error ? error.message : String(error)
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
};
|
|
112
|
+
const processBatchImages = async (inputPaths, outputDir, options = {}) => {
|
|
113
|
+
const results = [];
|
|
114
|
+
for (const inputPath of inputPaths) {
|
|
115
|
+
const result = await processImage(inputPath, outputDir, options);
|
|
116
|
+
results.push(result);
|
|
117
|
+
}
|
|
118
|
+
return results;
|
|
119
|
+
};
|
|
120
|
+
exports.processBatchImages = processBatchImages;
|
|
121
|
+
//# sourceMappingURL=imageProcessor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"imageProcessor.js","sourceRoot":"","sources":["../../src/utils/imageProcessor.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,gDAAkC;AAClC,2CAA6B;AAC7B,kDAA0B;AAiB1B,MAAM,iBAAiB,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,CAAU,CAAC;AAExF,MAAM,gBAAgB,GAAG,CAAC,QAAgB,EAAU,EAAE;IACpD,OAAO,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,WAAW,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AACvD,CAAC,CAAC;AAEF,MAAM,kBAAkB,GAAG,CAAC,QAAgB,EAAW,EAAE;IACvD,MAAM,GAAG,GAAG,gBAAgB,CAAC,QAAQ,CAAC,CAAC;IACvC,OAAO,iBAAiB,C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AE,CAAC;QACnC,MAAM,MAAM,GAAG,MAAM,YAAY,CAAC,SAAS,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC;QACjE,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACvB,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC;AAbW,QAAA,kBAAkB,sBAa7B"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Result of the longest common subsequence computation
|
|
3
|
+
*/
|
|
4
|
+
export interface LCSResult {
|
|
5
|
+
readonly subsequence: string;
|
|
6
|
+
readonly length: number;
|
|
7
|
+
readonly matrix: readonly (readonly number[])[];
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Finds the longest common subsequence (LCS) between two strings using dynamic programming.
|
|
11
|
+
*
|
|
12
|
+
* Uses a 2D matrix where dp[i][j] represents the length of LCS of str1[0...i-1] and str2[0...j-1].
|
|
13
|
+
* Time complexity: O(m * n) where m and n are the lengths of the input strings.
|
|
14
|
+
* Space complexity: O(m * n) for the DP matrix.
|
|
15
|
+
*
|
|
16
|
+
* @param str1 - First input string
|
|
17
|
+
* @param str2 - Second input string
|
|
18
|
+
* @returns Object containing the LCS string, its length, and the DP matrix
|
|
19
|
+
*/
|
|
20
|
+
export declare const findLongestCommonSubsequence: (str1: string, str2: string) => LCSResult;
|
|
21
|
+
/**
|
|
22
|
+
* Optimized space-complexity version using only two rows instead of full matrix.
|
|
23
|
+
* Time complexity: O(m * n)
|
|
24
|
+
* Space complexity: O(min(m, n))
|
|
25
|
+
*
|
|
26
|
+
* Note: This version only returns the length, not the actual subsequence,
|
|
27
|
+
* since we don't retain the full matrix needed for backtracking.
|
|
28
|
+
*/
|
|
29
|
+
export declare const findLCSLengthOptimized: (str1: string, str2: string) => number;
|
|
30
|
+
/**
|
|
31
|
+
* Finds all possible longest common subsequences between two strings.
|
|
32
|
+
* There can be multiple LCS with the same maximum length.
|
|
33
|
+
*
|
|
34
|
+
* @returns Array of all LCS strings with maximum length
|
|
35
|
+
*/
|
|
36
|
+
export declare const findAllLCS: (str1: string, str2: string) => readonly string[];
|
|
37
|
+
//# sourceMappingURL=lcs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lcs.d.ts","sourceRoot":"","sources":["../../src/utils/lcs.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,MAAM,EAAE,SAAS,CAAC,SAAS,MAAM,EAAE,CAAC,EAAE,CAAC;CACjD;AAED;;;;;;;;;;GAUG;AACH,eAAO,MAAM,4BAA4B,GACvC,MAAM,MAAM,EACZ,MAAM,MAAM,KACX,SA8BF,CAAC;AA+BF;;;;;;;GAOG;AACH,eAAO,MAAM,sBAAsB,GAAI,MAAM,MAAM,EAAE,MAAM,MAAM,KAAG,MAwBnE,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,UAAU,GAAI,MAAM,MAAM,EAAE,MAAM,MAAM,KAAG,SAAS,MAAM,EAyCtE,CAAC"}
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.findAllLCS = exports.findLCSLengthOptimized = exports.findLongestCommonSubsequence = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Finds the longest common subsequence (LCS) between two strings using dynamic programming.
|
|
6
|
+
*
|
|
7
|
+
* Uses a 2D matrix where dp[i][j] represents the length of LCS of str1[0...i-1] and str2[0...j-1].
|
|
8
|
+
* Time complexity: O(m * n) where m and n are the lengths of the input strings.
|
|
9
|
+
* Space complexity: O(m * n) for the DP matrix.
|
|
10
|
+
*
|
|
11
|
+
* @param str1 - First input string
|
|
12
|
+
* @param str2 - Second input string
|
|
13
|
+
* @returns Object containing the LCS string, its length, and the DP matrix
|
|
14
|
+
*/
|
|
15
|
+
const findLongestCommonSubsequence = (str1, str2) => {
|
|
16
|
+
const m = str1.length;
|
|
17
|
+
const n = str2.length;
|
|
18
|
+
// Initialize DP matrix with zeros
|
|
19
|
+
const dp = Array.from({ length: m + 1 }, () => Array(n + 1).fill(0));
|
|
20
|
+
// Build the DP matrix using bottom-up approach
|
|
21
|
+
for (let i = 1; i <= m; i++) {
|
|
22
|
+
for (let j = 1; j <= n; j++) {
|
|
23
|
+
if (str1[i - 1] === str2[j - 1]) {
|
|
24
|
+
// Characters match: extend the LCS from diagonal
|
|
25
|
+
dp[i][j] = dp[i - 1][j - 1] + 1;
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
// Characters don't match: take max from left or top
|
|
29
|
+
dp[i][j] = Math.max(dp[i - 1][j], dp[i][j - 1]);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
// Backtrack through the matrix to reconstruct the actual subsequence
|
|
34
|
+
const subsequence = backtrackLCS(str1, str2, dp, m, n);
|
|
35
|
+
return {
|
|
36
|
+
subsequence,
|
|
37
|
+
length: dp[m][n],
|
|
38
|
+
matrix: dp,
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
exports.findLongestCommonSubsequence = findLongestCommonSubsequence;
|
|
42
|
+
/**
|
|
43
|
+
* Reconstructs the LCS string by backtracking through the DP matrix.
|
|
44
|
+
* Starts from bottom-right corner and moves towards top-left based on how values were computed.
|
|
45
|
+
*/
|
|
46
|
+
const backtrackLCS = (str1, str2, dp, i, j) => {
|
|
47
|
+
// Base case: reached the edge of the matrix
|
|
48
|
+
if (i === 0 || j === 0) {
|
|
49
|
+
return "";
|
|
50
|
+
}
|
|
51
|
+
// If characters match, this character is part of LCS
|
|
52
|
+
if (str1[i - 1] === str2[j - 1]) {
|
|
53
|
+
return backtrackLCS(str1, str2, dp, i - 1, j - 1) + str1[i - 1];
|
|
54
|
+
}
|
|
55
|
+
// Move in the direction of larger value (how we computed dp[i][j])
|
|
56
|
+
if (dp[i - 1][j] > dp[i][j - 1]) {
|
|
57
|
+
return backtrackLCS(str1, str2, dp, i - 1, j);
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
return backtrackLCS(str1, str2, dp, i, j - 1);
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
/**
|
|
64
|
+
* Optimized space-complexity version using only two rows instead of full matrix.
|
|
65
|
+
* Time complexity: O(m * n)
|
|
66
|
+
* Space complexity: O(min(m, n))
|
|
67
|
+
*
|
|
68
|
+
* Note: This version only returns the length, not the actual subsequence,
|
|
69
|
+
* since we don't retain the full matrix needed for backtracking.
|
|
70
|
+
*/
|
|
71
|
+
const findLCSLengthOptimized = (str1, str2) => {
|
|
72
|
+
// Ensure str2 is the shorter string to minimize space usage
|
|
73
|
+
if (str1.length < str2.length) {
|
|
74
|
+
[str1, str2] = [str2, str1];
|
|
75
|
+
}
|
|
76
|
+
const n = str2.length;
|
|
77
|
+
let prev = Array(n + 1).fill(0);
|
|
78
|
+
let curr = Array(n + 1).fill(0);
|
|
79
|
+
str1.split("").forEach((char1) => {
|
|
80
|
+
for (let j = 1; j <= n; j++) {
|
|
81
|
+
if (char1 === str2[j - 1]) {
|
|
82
|
+
curr[j] = prev[j - 1] + 1;
|
|
83
|
+
}
|
|
84
|
+
else {
|
|
85
|
+
curr[j] = Math.max(prev[j], curr[j - 1]);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
// Swap rows for next iteration
|
|
89
|
+
[prev, curr] = [curr, prev];
|
|
90
|
+
curr.fill(0);
|
|
91
|
+
});
|
|
92
|
+
return prev[n];
|
|
93
|
+
};
|
|
94
|
+
exports.findLCSLengthOptimized = findLCSLengthOptimized;
|
|
95
|
+
/**
|
|
96
|
+
* Finds all possible longest common subsequences between two strings.
|
|
97
|
+
* There can be multiple LCS with the same maximum length.
|
|
98
|
+
*
|
|
99
|
+
* @returns Array of all LCS strings with maximum length
|
|
100
|
+
*/
|
|
101
|
+
const findAllLCS = (str1, str2) => {
|
|
102
|
+
const m = str1.length;
|
|
103
|
+
const n = str2.length;
|
|
104
|
+
const dp = Array.from({ length: m + 1 }, () => Array(n + 1).fill(0));
|
|
105
|
+
// Build DP matrix
|
|
106
|
+
for (let i = 1; i <= m; i++) {
|
|
107
|
+
for (let j = 1; j <= n; j++) {
|
|
108
|
+
if (str1[i - 1] === str2[j - 1]) {
|
|
109
|
+
dp[i][j] = dp[i - 1][j - 1] + 1;
|
|
110
|
+
}
|
|
111
|
+
else {
|
|
112
|
+
dp[i][j] = Math.max(dp[i - 1][j], dp[i][j - 1]);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
// Collect all LCS using DFS with memoization to avoid duplicates
|
|
117
|
+
const allLCS = new Set();
|
|
118
|
+
const collectAllLCS = (i, j, current) => {
|
|
119
|
+
if (i === 0 || j === 0) {
|
|
120
|
+
allLCS.add(current);
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
if (str1[i - 1] === str2[j - 1]) {
|
|
124
|
+
collectAllLCS(i - 1, j - 1, str1[i - 1] + current);
|
|
125
|
+
}
|
|
126
|
+
else {
|
|
127
|
+
if (dp[i - 1][j] >= dp[i][j - 1]) {
|
|
128
|
+
collectAllLCS(i - 1, j, current);
|
|
129
|
+
}
|
|
130
|
+
if (dp[i][j - 1] >= dp[i - 1][j]) {
|
|
131
|
+
collectAllLCS(i, j - 1, current);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
};
|
|
135
|
+
collectAllLCS(m, n, "");
|
|
136
|
+
return Array.from(allLCS);
|
|
137
|
+
};
|
|
138
|
+
exports.findAllLCS = findAllLCS;
|
|
139
|
+
//# sourceMappingURL=lcs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lcs.js","sourceRoot":"","sources":["../../src/utils/lcs.ts"],"names":[],"mappings":";;;AASA;;;;;;;;;;GA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C;QAED,IAAI,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC;YAChC,aAAa,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC;QACrD,CAAC;aAAM,CAAC;YACN,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC;gBACjC,aAAa,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,OAAO,CAAC,CAAC;YACnC,CAAC;YACD,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;gBACjC,aAAa,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,OAAO,CAAC,CAAC;YACnC,CAAC;QACH,CAAC;IACH,CAAC,CAAC;IAEF,aAAa,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC;IACxB,OAAO,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;AAC5B,CAAC,CAAC;AAzCW,QAAA,UAAU,cAyCrB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"notifications.d.ts","sourceRoot":"","sources":["../../src/utils/notifications.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,uBAAuB,GAClC,SAAS,SAAS,MAAM,EAAE,EAC1B,kBAAkB,CAAC,MAAM,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,KAClD,OAAO,CAAC,IAAI,CAEd,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.sendNotificationToUsers = void 0;
|
|
4
|
+
const sendNotificationToUsers = async (userIds, sendNotification) => {
|
|
5
|
+
await Promise.all(userIds.map((userId) => sendNotification(userId)));
|
|
6
|
+
};
|
|
7
|
+
exports.sendNotificationToUsers = sendNotificationToUsers;
|
|
8
|
+
//# sourceMappingURL=notifications.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"notifications.js","sourceRoot":"","sources":["../../src/utils/notifications.ts"],"names":[],"mappings":";;;AAAO,MAAM,uBAAuB,GAAG,KAAK,EAC1C,OAA0B,EAC1B,gBAAmD,EACpC,EAAE;IACjB,MAAM,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,gBAAgB,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;AACvE,CAAC,CAAC;AALW,QAAA,uBAAuB,2BAKlC"}
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Time difference units
|
|
3
|
+
*/
|
|
1
4
|
export interface TimeDifference {
|
|
2
5
|
milliseconds: number;
|
|
3
6
|
seconds: number;
|
|
@@ -5,5 +8,17 @@ export interface TimeDifference {
|
|
|
5
8
|
hours: number;
|
|
6
9
|
days: number;
|
|
7
10
|
}
|
|
8
|
-
|
|
11
|
+
/**
|
|
12
|
+
* Calculate the absolute time difference between two dates
|
|
13
|
+
*/
|
|
14
|
+
export declare const getTimeDifference: (date1: Date, date2: Date) => TimeDifference;
|
|
15
|
+
/**
|
|
16
|
+
* Calculate the signed time difference between two dates (date2 - date1)
|
|
17
|
+
* Positive if date2 is after date1, negative if before
|
|
18
|
+
*/
|
|
19
|
+
export declare const getSignedTimeDifference: (date1: Date, date2: Date) => TimeDifference;
|
|
20
|
+
/**
|
|
21
|
+
* Format time difference as human-readable string
|
|
22
|
+
*/
|
|
23
|
+
export declare const formatTimeDifference: (diff: TimeDifference) => string;
|
|
9
24
|
//# sourceMappingURL=timeUtils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"timeUtils.d.ts","sourceRoot":"","sources":["../../src/utils/timeUtils.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,cAAc;IAC7B,YAAY,EAAE,MAAM,CAAC;IACrB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;CACd;
|
|
1
|
+
{"version":3,"file":"timeUtils.d.ts","sourceRoot":"","sources":["../../src/utils/timeUtils.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,YAAY,EAAE,MAAM,CAAC;IACrB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;CACd;AAoBD;;GAEG;AACH,eAAO,MAAM,iBAAiB,GAC5B,OAAO,IAAI,EACX,OAAO,IAAI,KACV,cAGF,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,uBAAuB,GAClC,OAAO,IAAI,EACX,OAAO,IAAI,KACV,cAGF,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,oBAAoB,GAAI,MAAM,cAAc,KAAG,MAmB3D,CAAC"}
|
package/dist/utils/timeUtils.js
CHANGED
|
@@ -1,23 +1,60 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
const calculateTimeDifference = (startDate, endDate) => {
|
|
13
|
-
const milliseconds = Math.abs(endDate.getTime() - startDate.getTime());
|
|
3
|
+
exports.formatTimeDifference = exports.getSignedTimeDifference = exports.getTimeDifference = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Convert milliseconds to other time units
|
|
6
|
+
*/
|
|
7
|
+
const convertMilliseconds = (ms) => {
|
|
8
|
+
const seconds = ms / 1000;
|
|
9
|
+
const minutes = seconds / 60;
|
|
10
|
+
const hours = minutes / 60;
|
|
11
|
+
const days = hours / 24;
|
|
14
12
|
return {
|
|
15
|
-
milliseconds,
|
|
16
|
-
seconds
|
|
17
|
-
minutes
|
|
18
|
-
hours
|
|
19
|
-
days
|
|
13
|
+
milliseconds: ms,
|
|
14
|
+
seconds,
|
|
15
|
+
minutes,
|
|
16
|
+
hours,
|
|
17
|
+
days,
|
|
20
18
|
};
|
|
21
19
|
};
|
|
22
|
-
|
|
20
|
+
/**
|
|
21
|
+
* Calculate the absolute time difference between two dates
|
|
22
|
+
*/
|
|
23
|
+
const getTimeDifference = (date1, date2) => {
|
|
24
|
+
const ms = Math.abs(date1.getTime() - date2.getTime());
|
|
25
|
+
return convertMilliseconds(ms);
|
|
26
|
+
};
|
|
27
|
+
exports.getTimeDifference = getTimeDifference;
|
|
28
|
+
/**
|
|
29
|
+
* Calculate the signed time difference between two dates (date2 - date1)
|
|
30
|
+
* Positive if date2 is after date1, negative if before
|
|
31
|
+
*/
|
|
32
|
+
const getSignedTimeDifference = (date1, date2) => {
|
|
33
|
+
const ms = date2.getTime() - date1.getTime();
|
|
34
|
+
return convertMilliseconds(ms);
|
|
35
|
+
};
|
|
36
|
+
exports.getSignedTimeDifference = getSignedTimeDifference;
|
|
37
|
+
/**
|
|
38
|
+
* Format time difference as human-readable string
|
|
39
|
+
*/
|
|
40
|
+
const formatTimeDifference = (diff) => {
|
|
41
|
+
const absDays = Math.abs(diff.days);
|
|
42
|
+
const absHours = Math.abs(diff.hours);
|
|
43
|
+
const absMinutes = Math.abs(diff.minutes);
|
|
44
|
+
const absSeconds = Math.abs(diff.seconds);
|
|
45
|
+
if (absDays >= 1) {
|
|
46
|
+
return `${diff.days.toFixed(2)} days`;
|
|
47
|
+
}
|
|
48
|
+
if (absHours >= 1) {
|
|
49
|
+
return `${diff.hours.toFixed(2)} hours`;
|
|
50
|
+
}
|
|
51
|
+
if (absMinutes >= 1) {
|
|
52
|
+
return `${diff.minutes.toFixed(2)} minutes`;
|
|
53
|
+
}
|
|
54
|
+
if (absSeconds >= 1) {
|
|
55
|
+
return `${diff.seconds.toFixed(2)} seconds`;
|
|
56
|
+
}
|
|
57
|
+
return `${diff.milliseconds} milliseconds`;
|
|
58
|
+
};
|
|
59
|
+
exports.formatTimeDifference = formatTimeDifference;
|
|
23
60
|
//# sourceMappingURL=timeUtils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"timeUtils.js","sourceRoot":"","sources":["../../src/utils/timeUtils.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"timeUtils.js","sourceRoot":"","sources":["../../src/utils/timeUtils.ts"],"names":[],"mappings":";;;AAWA;;GAEG;AACH,MAAM,mBAAmB,GAAG,CAAC,EAAU,EAAkB,EAAE;IACzD,MAAM,OAAO,GAAG,EAAE,GAAG,IAAI,CAAC;IAC1B,MAAM,OAAO,GAAG,OAAO,GAAG,EAAE,CAAC;IAC7B,MAAM,KAAK,GAAG,OAAO,GAAG,EAAE,CAAC;IAC3B,MAAM,IAAI,GAAG,KAAK,GAAG,EAAE,CAAC;IAExB,OAAO;QACL,YAAY,EAAE,EAAE;QAChB,OAAO;QACP,OAAO;QACP,KAAK;QACL,IAAI;KACL,CAAC;AACJ,CAAC,CAAC;AAEF;;GAEG;AACI,MAAM,iBAAiB,GAAG,CAC/B,KAAW,EACX,KAAW,EACK,EAAE;IAClB,MAAM,EAAE,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,OAAO,EAAE,GAAG,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;IACvD,OAAO,mBAAmB,CAAC,EAAE,CAAC,CAAC;AACjC,CAAC,CAAC;AANW,QAAA,iBAAiB,qB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;AAnBW,QAAA,oBAAoB,wBAmB/B"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* User report printing utilities
|
|
3
|
+
*/
|
|
4
|
+
export interface UserWithStatus {
|
|
5
|
+
name: string;
|
|
6
|
+
email: string;
|
|
7
|
+
accountStatus: string;
|
|
8
|
+
}
|
|
9
|
+
export declare const printUserReport: (users: readonly UserWithStatus[]) => void;
|
|
10
|
+
//# sourceMappingURL=userReport.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"userReport.d.ts","sourceRoot":"","sources":["../../src/utils/userReport.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,aAAa,EAAE,MAAM,CAAC;CACvB;AAED,eAAO,MAAM,eAAe,GAAI,OAAO,SAAS,cAAc,EAAE,KAAG,IAYlE,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* User report printing utilities
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.printUserReport = void 0;
|
|
7
|
+
const printUserReport = (users) => {
|
|
8
|
+
console.log('\n=== User Report ===\n');
|
|
9
|
+
users.forEach((user, index) => {
|
|
10
|
+
console.log(`User #${index + 1}:`);
|
|
11
|
+
console.log(` Name: ${user.name}`);
|
|
12
|
+
console.log(` Email: ${user.email}`);
|
|
13
|
+
console.log(` Account Status: ${user.accountStatus}`);
|
|
14
|
+
console.log('');
|
|
15
|
+
});
|
|
16
|
+
console.log(`Total Users: ${users.length}\n`);
|
|
17
|
+
};
|
|
18
|
+
exports.printUserReport = printUserReport;
|
|
19
|
+
//# sourceMappingURL=userReport.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"userReport.js","sourceRoot":"","sources":["../../src/utils/userReport.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAQI,MAAM,eAAe,GAAG,CAAC,KAAgC,EAAQ,EAAE;IACxE,OAAO,CAAC,GAAG,CAAC,yBAAyB,CAAC,CAAC;IAEvC,KAAK,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE;QAC5B,OAAO,CAAC,GAAG,CAAC,SAAS,KAAK,GAAG,CAAC,GAAG,CAAC,CAAC;QACnC,OAAO,CAAC,GAAG,CAAC,qBAAqB,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC;QAC9C,OAAO,CAAC,GAAG,CAAC,qBAAqB,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC;QAC/C,OAAO,CAAC,GAAG,CAAC,qBAAqB,IAAI,CAAC,aAAa,EAAE,CAAC,CAAC;QACvD,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IAClB,CAAC,CAAC,CAAC;IAEH,OAAO,CAAC,GAAG,CAAC,gBAAgB,KAAK,CAAC,MAAM,IAAI,CAAC,CAAC;AAChD,CAAC,CAAC;AAZW,QAAA,eAAe,mBAY1B"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "coding-agent-benchmarks",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.1",
|
|
4
4
|
"description": "Testing coding agents (GitHub Copilot CLI, Claude Code, etc.) with your repo's context to evaluate their code generation quality.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|