@vroskus/library-helpers 1.0.29 → 1.0.30
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/dist/browser.d.ts +1 -0
- package/dist/browser.js +32 -1
- package/dist/common.d.ts +0 -2
- package/dist/common.js +1 -7
- package/dist/node.d.ts +2 -0
- package/dist/node.js +9 -1
- package/package.json +8 -6
package/dist/browser.d.ts
CHANGED
|
@@ -5,3 +5,4 @@ export declare const animationClass: (name: $AnimationName) => string;
|
|
|
5
5
|
export declare const getUrlGetParams: (input: string) => Record<string, null | string>;
|
|
6
6
|
export declare const scrollTop: (elementId?: string, offset?: number) => void;
|
|
7
7
|
export declare const scrollItem: (itemId: string, elementId: string, offset?: number) => void;
|
|
8
|
+
export declare const usePrevious: <T>(value: T) => T | undefined;
|
package/dist/browser.js
CHANGED
|
@@ -10,6 +10,28 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
|
|
|
10
10
|
if (k2 === undefined) k2 = k;
|
|
11
11
|
o[k2] = m[k];
|
|
12
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
|
+
})();
|
|
13
35
|
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
36
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
37
|
};
|
|
@@ -17,7 +39,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
17
39
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
18
40
|
};
|
|
19
41
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
-
exports.scrollItem = exports.scrollTop = exports.getUrlGetParams = exports.animationClass = exports.cleanFormValues = void 0;
|
|
42
|
+
exports.usePrevious = exports.scrollItem = exports.scrollTop = exports.getUrlGetParams = exports.animationClass = exports.cleanFormValues = void 0;
|
|
43
|
+
const React = __importStar(require("react"));
|
|
21
44
|
const lodash_1 = __importDefault(require("lodash"));
|
|
22
45
|
const query_string_1 = __importDefault(require("query-string"));
|
|
23
46
|
const react_animations_1 = require("react-animations");
|
|
@@ -111,3 +134,11 @@ const scrollItem = (itemId, elementId, offset) => {
|
|
|
111
134
|
}
|
|
112
135
|
};
|
|
113
136
|
exports.scrollItem = scrollItem;
|
|
137
|
+
const usePrevious = (value) => {
|
|
138
|
+
const ref = React.useRef(undefined);
|
|
139
|
+
React.useEffect(() => {
|
|
140
|
+
ref.current = value;
|
|
141
|
+
});
|
|
142
|
+
return ref.current;
|
|
143
|
+
};
|
|
144
|
+
exports.usePrevious = usePrevious;
|
package/dist/common.d.ts
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import type { RequestHandler } from 'express';
|
|
2
1
|
export declare const getValue: <V extends null | string | void>(value: V, defaultValue: V) => V;
|
|
3
|
-
export declare const durationMiddleware: () => RequestHandler;
|
|
4
2
|
export declare const getDuration: (start: [number, number] | void) => number;
|
|
5
3
|
export declare const sortData: <D extends Array<Record<string, unknown>>>(data: D, field: Array<string> | string, reverse?: boolean) => Promise<D>;
|
|
6
4
|
export declare const getImageUrl: ({ cdnUrl, image, size, undefinedImage, }: {
|
package/dist/common.js
CHANGED
|
@@ -12,7 +12,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
12
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.nullValue = exports.numberValue = exports.getObjectEntries = exports.getObjectValues = exports.getObjectKeys = exports.isDiff = exports.sleep = exports.makeRollingCode = exports.makeCode = exports.getFileUrl = exports.getImageUrl = exports.sortData = exports.getDuration = exports.
|
|
15
|
+
exports.nullValue = exports.numberValue = exports.getObjectEntries = exports.getObjectValues = exports.getObjectKeys = exports.isDiff = exports.sleep = exports.makeRollingCode = exports.makeCode = exports.getFileUrl = exports.getImageUrl = exports.sortData = exports.getDuration = exports.getValue = void 0;
|
|
16
16
|
const lodash_1 = __importDefault(require("lodash"));
|
|
17
17
|
const moment_1 = __importDefault(require("moment"));
|
|
18
18
|
const aigle_1 = __importDefault(require("aigle"));
|
|
@@ -29,12 +29,6 @@ const getValue = (value, defaultValue) => {
|
|
|
29
29
|
return output;
|
|
30
30
|
};
|
|
31
31
|
exports.getValue = getValue;
|
|
32
|
-
const durationMiddleware = () => (req, res, next) => {
|
|
33
|
-
const start = process.hrtime();
|
|
34
|
-
lodash_1.default.set(req, 'start', start);
|
|
35
|
-
next();
|
|
36
|
-
};
|
|
37
|
-
exports.durationMiddleware = durationMiddleware;
|
|
38
32
|
const getDuration = (start) => {
|
|
39
33
|
let timeInMs = zeroValue;
|
|
40
34
|
if (start) {
|
package/dist/node.d.ts
CHANGED
|
@@ -1,2 +1,4 @@
|
|
|
1
|
+
import type { NextFunction as $Next, Request as $Request, Response as $Response } from 'express';
|
|
1
2
|
export * from './common';
|
|
3
|
+
export declare const durationMiddleware: <REQ extends $Request>() => (req: REQ, res: $Response, next: $Next) => void;
|
|
2
4
|
export declare const generateHash: (value: string) => string;
|
package/dist/node.js
CHANGED
|
@@ -17,8 +17,16 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
17
17
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
18
18
|
};
|
|
19
19
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
-
exports.generateHash = void 0;
|
|
20
|
+
exports.generateHash = exports.durationMiddleware = void 0;
|
|
21
21
|
const crypto_1 = __importDefault(require("crypto"));
|
|
22
22
|
__exportStar(require("./common"), exports);
|
|
23
|
+
const durationMiddleware = () => (req, res, next) => {
|
|
24
|
+
Object.defineProperty(req, 'start', {
|
|
25
|
+
value: process.hrtime(),
|
|
26
|
+
writable: false,
|
|
27
|
+
});
|
|
28
|
+
next();
|
|
29
|
+
};
|
|
30
|
+
exports.durationMiddleware = durationMiddleware;
|
|
23
31
|
const generateHash = (value) => crypto_1.default.createHash('sha512').update(value).digest('hex');
|
|
24
32
|
exports.generateHash = generateHash;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vroskus/library-helpers",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.30",
|
|
4
4
|
"description": "Utility helpers",
|
|
5
5
|
"author": "Vilius Roškus <info@regattas.eu>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -24,18 +24,20 @@
|
|
|
24
24
|
"aigle": "^1.14.1",
|
|
25
25
|
"aphrodite": "^2.4.0",
|
|
26
26
|
"express": "^5.2.1",
|
|
27
|
-
"lodash": "^4.
|
|
27
|
+
"lodash": "^4.18.1",
|
|
28
28
|
"moment": "^2.30.1",
|
|
29
29
|
"query-string": "^9.3.1",
|
|
30
|
+
"react": "^18.3.1",
|
|
30
31
|
"react-animations": "^1.0.0",
|
|
31
32
|
"short-hash": "^1.0.0"
|
|
32
33
|
},
|
|
33
34
|
"devDependencies": {
|
|
34
35
|
"@types/jest": "^30.0.0",
|
|
35
|
-
"@types/lodash": "^4.17.
|
|
36
|
-
"@types/node": "^25.
|
|
36
|
+
"@types/lodash": "^4.17.24",
|
|
37
|
+
"@types/node": "^25.6.2",
|
|
37
38
|
"@types/query-string": "^6.3.0",
|
|
38
|
-
"@
|
|
39
|
-
"
|
|
39
|
+
"@types/react": "^18.3.3",
|
|
40
|
+
"@vroskus/eslint-config": "^1.1.3",
|
|
41
|
+
"typescript": "^6.0.3"
|
|
40
42
|
}
|
|
41
43
|
}
|