mirror of
https://github.com/dbeaver/cloudbeaver.git
synced 2026-10-16 14:50:15 +08:00
dbeaver/pro#9436 feat: add isNumber and replaceMiddle utility functions (#4377)
* dbeaver/pro#9436 feat: add isNumber and replaceMiddle utility functions * dbeaver/pro#9436 refactor: move uuid helper into @dbeaver/js-helpers Move uuid() from @cloudbeaver/core-utils into the portable @dbeaver/js-helpers so chart widget code can depend on it without pulling in CloudBeaver. core-utils re-exports uuid/V4Options/V1Options from js-helpers, so existing importers are unaffected; the uuid npm dependency moves to js-helpers. * dbeaver/pro#9436 style: update copyright year in uuid_ file * dbeaver/pro#9436 refactor: reexport isNumber and replaceMiddle functions from @dbeaver/js-helpers * dbeaver/pro#9436 refactor: rename uuid file to uuid_ and update exports --------- Co-authored-by: Daria Marutkina <125263541+dariamarutkina@users.noreply.github.com> Co-authored-by: sergeyteleshev <iamsergeyteleshev@gmail.com> Co-authored-by: Evgenia <139753579+EvgeniaBzzz@users.noreply.github.com>
This commit is contained in:
co-authored by
Daria Marutkina
sergeyteleshev
Evgenia
parent
4d62ddb5fc
commit
dc1e865545
@@ -36,6 +36,7 @@
|
||||
"color": "^5.0.2",
|
||||
"p-debounce": "^5",
|
||||
"p-memoize": "^8.0.0",
|
||||
"quick-lru": "^7.1.0"
|
||||
"quick-lru": "^7.1.0",
|
||||
"uuid": "^14"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,3 +17,6 @@ export * from './mutex.js';
|
||||
export * from './reorderArray.js';
|
||||
export * from './getLocalizedDisplayName.js';
|
||||
export * from './formatNumber.js';
|
||||
export * from './isNumber.js';
|
||||
export * from './replaceMiddle.js';
|
||||
export * from './uuid_.js';
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
/*
|
||||
* CloudBeaver - Cloud Database Manager
|
||||
* Copyright (C) 2020-2026 DBeaver Corp and others
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0.
|
||||
* you may not use this file except in compliance with the License.
|
||||
*/
|
||||
export function isNumber(value: unknown): value is number {
|
||||
return !isNaN(parseFloat(value as string)) && isFinite(value as number);
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
/*
|
||||
* CloudBeaver - Cloud Database Manager
|
||||
* Copyright (C) 2020-2026 DBeaver Corp and others
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0.
|
||||
* you may not use this file except in compliance with the License.
|
||||
*/
|
||||
|
||||
export function replaceMiddle(value: string, newMiddle: string, sideLength: number, limiter: number): string {
|
||||
if (value.length < limiter) {
|
||||
return value;
|
||||
}
|
||||
|
||||
return value.substring(0, sideLength) + newMiddle + value.substring(value.length - sideLength);
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
/*
|
||||
* CloudBeaver - Cloud Database Manager
|
||||
* Copyright (C) 2020-2026 DBeaver Corp and others
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0.
|
||||
* you may not use this file except in compliance with the License.
|
||||
*/
|
||||
import { v4 as uuidv4, type Version1Options, type Version4Options } from 'uuid';
|
||||
|
||||
export type V4Options = Version4Options;
|
||||
export type V1Options = Version1Options;
|
||||
|
||||
export function uuid(options?: Version4Options): string {
|
||||
return uuidv4(options);
|
||||
}
|
||||
@@ -30,7 +30,6 @@
|
||||
"modern-screenshot": "4.6.8",
|
||||
"tslib": "^2",
|
||||
"underscore": "^1",
|
||||
"uuid": "^14",
|
||||
"vitest": "^4",
|
||||
"whatwg-mimetype": "^5",
|
||||
"zod": "^4",
|
||||
|
||||
@@ -5,6 +5,4 @@
|
||||
* Licensed under the Apache License, Version 2.0.
|
||||
* you may not use this file except in compliance with the License.
|
||||
*/
|
||||
export function isNumber(value: any): value is number {
|
||||
return !isNaN(parseFloat(value)) && isFinite(value);
|
||||
}
|
||||
export { isNumber } from '@dbeaver/js-helpers';
|
||||
|
||||
@@ -1,15 +1,8 @@
|
||||
/*
|
||||
* CloudBeaver - Cloud Database Manager
|
||||
* Copyright (C) 2020-2024 DBeaver Corp and others
|
||||
* Copyright (C) 2020-2026 DBeaver Corp and others
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0.
|
||||
* you may not use this file except in compliance with the License.
|
||||
*/
|
||||
|
||||
export function replaceMiddle(value: string, newMiddle: string, sideLength: number, limiter: number): string {
|
||||
if (value.length < limiter) {
|
||||
return value;
|
||||
}
|
||||
|
||||
return value.substr(0, sideLength) + newMiddle + value.substr(value.length - sideLength);
|
||||
}
|
||||
export { replaceMiddle } from '@dbeaver/js-helpers';
|
||||
|
||||
@@ -1,15 +1,8 @@
|
||||
/*
|
||||
* CloudBeaver - Cloud Database Manager
|
||||
* Copyright (C) 2020-2024 DBeaver Corp and others
|
||||
* Copyright (C) 2020-2026 DBeaver Corp and others
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0.
|
||||
* you may not use this file except in compliance with the License.
|
||||
*/
|
||||
import { v4 as uuidv4, type Version1Options, type Version4Options } from 'uuid';
|
||||
|
||||
export type V4Options = Version4Options;
|
||||
export type V1Options = Version1Options;
|
||||
|
||||
export function uuid(options?: Version4Options): string {
|
||||
return uuidv4(options);
|
||||
}
|
||||
export { uuid, type V4Options, type V1Options } from '@dbeaver/js-helpers';
|
||||
|
||||
+1
-1
@@ -2317,7 +2317,6 @@ __metadata:
|
||||
tslib: "npm:^2"
|
||||
typescript: "npm:^5"
|
||||
underscore: "npm:^1"
|
||||
uuid: "npm:^14"
|
||||
vitest: "npm:^4"
|
||||
whatwg-mimetype: "npm:^5"
|
||||
zod: "npm:^4"
|
||||
@@ -5082,6 +5081,7 @@ __metadata:
|
||||
quick-lru: "npm:^7.1.0"
|
||||
rimraf: "npm:^6"
|
||||
typescript: "npm:^5"
|
||||
uuid: "npm:^14"
|
||||
vitest: "npm:^4"
|
||||
languageName: unknown
|
||||
linkType: soft
|
||||
|
||||
Reference in New Issue
Block a user