@etsoo/shared 1.2.7 → 1.2.8
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 +3 -0
- package/lib/cjs/NumberUtils.js +1 -1
- package/lib/cjs/index.d.ts +1 -0
- package/lib/cjs/index.js +1 -0
- package/lib/cjs/types/DataError.d.ts +17 -0
- package/lib/cjs/types/DataError.js +22 -0
- package/lib/mjs/NumberUtils.js +1 -1
- package/lib/mjs/index.d.ts +1 -0
- package/lib/mjs/index.js +1 -0
- package/lib/mjs/types/DataError.d.ts +17 -0
- package/lib/mjs/types/DataError.js +18 -0
- package/package.json +6 -6
- package/src/NumberUtils.ts +1 -1
- package/src/index.ts +1 -0
- package/src/types/DataError.ts +25 -0
package/README.md
CHANGED
package/lib/cjs/NumberUtils.js
CHANGED
|
@@ -60,7 +60,7 @@ var NumberUtils;
|
|
|
60
60
|
const i = size === 0 ? 0 : Math.floor(Math.log(size) / Math.log(1024));
|
|
61
61
|
return ((size / Math.pow(1024, i)).toFixed(fractionDigits) +
|
|
62
62
|
' ' +
|
|
63
|
-
['B', 'KB', 'MB', 'GB', 'TB'][i]);
|
|
63
|
+
['B', 'KB', 'MB', 'GB', 'TB', 'PB'][i]);
|
|
64
64
|
}
|
|
65
65
|
NumberUtils.formatFileSize = formatFileSize;
|
|
66
66
|
/**
|
package/lib/cjs/index.d.ts
CHANGED
package/lib/cjs/index.js
CHANGED
|
@@ -15,6 +15,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./types/ContentDisposition"), exports);
|
|
18
|
+
__exportStar(require("./types/DataError"), exports);
|
|
18
19
|
__exportStar(require("./types/DelayedExecutorType"), exports);
|
|
19
20
|
__exportStar(require("./types/EColor"), exports);
|
|
20
21
|
__exportStar(require("./types/EHistory"), exports);
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Error with custom data
|
|
3
|
+
* Other information can be hold by 'name', 'cause', and 'stack' property
|
|
4
|
+
*
|
|
5
|
+
*/
|
|
6
|
+
export declare class DataError<T = Record<string, unknown>> extends Error {
|
|
7
|
+
/**
|
|
8
|
+
* Custom data
|
|
9
|
+
*/
|
|
10
|
+
readonly data: T;
|
|
11
|
+
/**
|
|
12
|
+
* Constructor
|
|
13
|
+
* @param message Error message
|
|
14
|
+
* @param data Custom data
|
|
15
|
+
*/
|
|
16
|
+
constructor(message: string, data: T);
|
|
17
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DataError = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Error with custom data
|
|
6
|
+
* Other information can be hold by 'name', 'cause', and 'stack' property
|
|
7
|
+
*
|
|
8
|
+
*/
|
|
9
|
+
class DataError extends Error {
|
|
10
|
+
/**
|
|
11
|
+
* Constructor
|
|
12
|
+
* @param message Error message
|
|
13
|
+
* @param data Custom data
|
|
14
|
+
*/
|
|
15
|
+
constructor(message, data) {
|
|
16
|
+
super(message);
|
|
17
|
+
this.data = data;
|
|
18
|
+
// Set the prototype explicitly to ensure instanceof works correctly
|
|
19
|
+
Object.setPrototypeOf(this, DataError.prototype);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
exports.DataError = DataError;
|
package/lib/mjs/NumberUtils.js
CHANGED
|
@@ -57,7 +57,7 @@ export var NumberUtils;
|
|
|
57
57
|
const i = size === 0 ? 0 : Math.floor(Math.log(size) / Math.log(1024));
|
|
58
58
|
return ((size / Math.pow(1024, i)).toFixed(fractionDigits) +
|
|
59
59
|
' ' +
|
|
60
|
-
['B', 'KB', 'MB', 'GB', 'TB'][i]);
|
|
60
|
+
['B', 'KB', 'MB', 'GB', 'TB', 'PB'][i]);
|
|
61
61
|
}
|
|
62
62
|
NumberUtils.formatFileSize = formatFileSize;
|
|
63
63
|
/**
|
package/lib/mjs/index.d.ts
CHANGED
package/lib/mjs/index.js
CHANGED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Error with custom data
|
|
3
|
+
* Other information can be hold by 'name', 'cause', and 'stack' property
|
|
4
|
+
*
|
|
5
|
+
*/
|
|
6
|
+
export declare class DataError<T = Record<string, unknown>> extends Error {
|
|
7
|
+
/**
|
|
8
|
+
* Custom data
|
|
9
|
+
*/
|
|
10
|
+
readonly data: T;
|
|
11
|
+
/**
|
|
12
|
+
* Constructor
|
|
13
|
+
* @param message Error message
|
|
14
|
+
* @param data Custom data
|
|
15
|
+
*/
|
|
16
|
+
constructor(message: string, data: T);
|
|
17
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Error with custom data
|
|
3
|
+
* Other information can be hold by 'name', 'cause', and 'stack' property
|
|
4
|
+
*
|
|
5
|
+
*/
|
|
6
|
+
export class DataError extends Error {
|
|
7
|
+
/**
|
|
8
|
+
* Constructor
|
|
9
|
+
* @param message Error message
|
|
10
|
+
* @param data Custom data
|
|
11
|
+
*/
|
|
12
|
+
constructor(message, data) {
|
|
13
|
+
super(message);
|
|
14
|
+
this.data = data;
|
|
15
|
+
// Set the prototype explicitly to ensure instanceof works correctly
|
|
16
|
+
Object.setPrototypeOf(this, DataError.prototype);
|
|
17
|
+
}
|
|
18
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@etsoo/shared",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.8",
|
|
4
4
|
"description": "TypeScript shared utilities and functions",
|
|
5
5
|
"main": "lib/cjs/index.js",
|
|
6
6
|
"module": "lib/mjs/index.js",
|
|
@@ -54,12 +54,12 @@
|
|
|
54
54
|
},
|
|
55
55
|
"homepage": "https://github.com/ETSOO/Shared#readme",
|
|
56
56
|
"devDependencies": {
|
|
57
|
-
"@types/jest": "^29.5.
|
|
57
|
+
"@types/jest": "^29.5.3",
|
|
58
58
|
"@types/lodash.isequal": "^4.5.6",
|
|
59
|
-
"jest": "^29.
|
|
60
|
-
"jest-environment-jsdom": "^29.
|
|
61
|
-
"ts-jest": "^29.1.
|
|
62
|
-
"typescript": "^5.1.
|
|
59
|
+
"jest": "^29.6.1",
|
|
60
|
+
"jest-environment-jsdom": "^29.6.1",
|
|
61
|
+
"ts-jest": "^29.1.1",
|
|
62
|
+
"typescript": "^5.1.6"
|
|
63
63
|
},
|
|
64
64
|
"dependencies": {
|
|
65
65
|
"lodash.isequal": "^4.5.0"
|
package/src/NumberUtils.ts
CHANGED
package/src/index.ts
CHANGED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Error with custom data
|
|
3
|
+
* Other information can be hold by 'name', 'cause', and 'stack' property
|
|
4
|
+
*
|
|
5
|
+
*/
|
|
6
|
+
export class DataError<T = Record<string, unknown>> extends Error {
|
|
7
|
+
/**
|
|
8
|
+
* Custom data
|
|
9
|
+
*/
|
|
10
|
+
public readonly data: T;
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Constructor
|
|
14
|
+
* @param message Error message
|
|
15
|
+
* @param data Custom data
|
|
16
|
+
*/
|
|
17
|
+
constructor(message: string, data: T) {
|
|
18
|
+
super(message);
|
|
19
|
+
|
|
20
|
+
this.data = data;
|
|
21
|
+
|
|
22
|
+
// Set the prototype explicitly to ensure instanceof works correctly
|
|
23
|
+
Object.setPrototypeOf(this, DataError.prototype);
|
|
24
|
+
}
|
|
25
|
+
}
|