@rc-component/util
Advanced tools
| /** | ||
| * Merges multiple props objects into one. Unlike `Object.assign()` or `{ ...a, ...b }`, it skips | ||
| * properties whose value is explicitly set to `undefined`. | ||
| */ | ||
| declare function mergeProps<A, B>(a: A, b: B): B & A; | ||
| declare function mergeProps<A, B, C>(a: A, b: B, c: C): C & B & A; | ||
| declare function mergeProps<A, B, C, D>(a: A, b: B, c: C, d: D): D & C & B & A; | ||
| export default mergeProps; |
| /** | ||
| * Merges multiple props objects into one. Unlike `Object.assign()` or `{ ...a, ...b }`, it skips | ||
| * properties whose value is explicitly set to `undefined`. | ||
| */ | ||
| function mergeProps(...items) { | ||
| const ret = {}; | ||
| for (const item of items) { | ||
| if (item) { | ||
| for (const key of Object.keys(item)) { | ||
| if (item[key] !== undefined) { | ||
| ret[key] = item[key]; | ||
| } | ||
| } | ||
| } | ||
| } | ||
| return ret; | ||
| } | ||
| export default mergeProps; |
| /** | ||
| * Merges multiple props objects into one. Unlike `Object.assign()` or `{ ...a, ...b }`, it skips | ||
| * properties whose value is explicitly set to `undefined`. | ||
| */ | ||
| declare function mergeProps<A, B>(a: A, b: B): B & A; | ||
| declare function mergeProps<A, B, C>(a: A, b: B, c: C): C & B & A; | ||
| declare function mergeProps<A, B, C, D>(a: A, b: B, c: C, d: D): D & C & B & A; | ||
| export default mergeProps; |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { | ||
| value: true | ||
| }); | ||
| exports.default = void 0; | ||
| /** | ||
| * Merges multiple props objects into one. Unlike `Object.assign()` or `{ ...a, ...b }`, it skips | ||
| * properties whose value is explicitly set to `undefined`. | ||
| */ | ||
| function mergeProps(...items) { | ||
| const ret = {}; | ||
| for (const item of items) { | ||
| if (item) { | ||
| for (const key of Object.keys(item)) { | ||
| if (item[key] !== undefined) { | ||
| ret[key] = item[key]; | ||
| } | ||
| } | ||
| } | ||
| } | ||
| return ret; | ||
| } | ||
| var _default = exports.default = mergeProps; |
@@ -52,4 +52,4 @@ /* eslint-disable no-param-reassign */ | ||
| // Measure. Get fallback style if provided | ||
| const scrollWidth = ele && fallbackWidth && !isNaN(fallbackWidth) ? fallbackWidth : measureEle.offsetWidth - measureEle.clientWidth; | ||
| const scrollHeight = ele && fallbackHeight && !isNaN(fallbackHeight) ? fallbackHeight : measureEle.offsetHeight - measureEle.clientHeight; | ||
| const scrollWidth = ele && fallbackWidth && !Number.isNaN(fallbackWidth) ? fallbackWidth : measureEle.offsetWidth - measureEle.clientWidth; | ||
| const scrollHeight = ele && fallbackHeight && !Number.isNaN(fallbackHeight) ? fallbackHeight : measureEle.offsetHeight - measureEle.clientHeight; | ||
@@ -56,0 +56,0 @@ // Clean up |
@@ -1,2 +0,2 @@ | ||
| declare function useEvent<T extends ((...args: any[]) => any) | undefined>(callback: T): undefined extends T ? (...args: Parameters<NonNullable<T>>) => ReturnType<NonNullable<T>> | undefined : T; | ||
| declare const useEvent: <T extends (...args: any[]) => any>(callback: T) => undefined extends T ? (...args: Parameters<NonNullable<T>>) => ReturnType<NonNullable<T>> | undefined : T; | ||
| export default useEvent; |
@@ -1,5 +0,3 @@ | ||
| /* eslint-disable @typescript-eslint/ban-types */ | ||
| /* eslint-disable react-hooks/exhaustive-deps */ | ||
| import * as React from 'react'; | ||
| function useEvent(callback) { | ||
| const useEvent = callback => { | ||
| const fnRef = React.useRef(callback); | ||
@@ -9,3 +7,3 @@ fnRef.current = callback; | ||
| return memoFn; | ||
| } | ||
| }; | ||
| export default useEvent; |
+1
-0
@@ -10,1 +10,2 @@ export { default as useEvent } from './hooks/useEvent'; | ||
| export { default as toArray } from './Children/toArray'; | ||
| export { default as mergeProps } from './mergeProps'; |
+2
-1
@@ -9,2 +9,3 @@ export { default as useEvent } from "./hooks/useEvent"; | ||
| export { default as omit } from "./omit"; | ||
| export { default as toArray } from "./Children/toArray"; | ||
| export { default as toArray } from "./Children/toArray"; | ||
| export { default as mergeProps } from "./mergeProps"; |
+2
-2
@@ -1,2 +0,2 @@ | ||
| declare const _default: () => boolean; | ||
| export default _default; | ||
| declare const getIsMobile: () => boolean; | ||
| export default getIsMobile; |
+3
-2
| import isMobile from 'is-mobile'; | ||
| let cached; | ||
| export default (() => { | ||
| const getIsMobile = () => { | ||
| if (typeof cached === 'undefined') { | ||
@@ -8,2 +8,3 @@ cached = isMobile(); | ||
| return cached; | ||
| }); | ||
| }; | ||
| export default getIsMobile; |
@@ -60,4 +60,4 @@ "use strict"; | ||
| // Measure. Get fallback style if provided | ||
| const scrollWidth = ele && fallbackWidth && !isNaN(fallbackWidth) ? fallbackWidth : measureEle.offsetWidth - measureEle.clientWidth; | ||
| const scrollHeight = ele && fallbackHeight && !isNaN(fallbackHeight) ? fallbackHeight : measureEle.offsetHeight - measureEle.clientHeight; | ||
| const scrollWidth = ele && fallbackWidth && !Number.isNaN(fallbackWidth) ? fallbackWidth : measureEle.offsetWidth - measureEle.clientWidth; | ||
| const scrollHeight = ele && fallbackHeight && !Number.isNaN(fallbackHeight) ? fallbackHeight : measureEle.offsetHeight - measureEle.clientHeight; | ||
@@ -64,0 +64,0 @@ // Clean up |
@@ -1,2 +0,2 @@ | ||
| declare function useEvent<T extends ((...args: any[]) => any) | undefined>(callback: T): undefined extends T ? (...args: Parameters<NonNullable<T>>) => ReturnType<NonNullable<T>> | undefined : T; | ||
| declare const useEvent: <T extends (...args: any[]) => any>(callback: T) => undefined extends T ? (...args: Parameters<NonNullable<T>>) => ReturnType<NonNullable<T>> | undefined : T; | ||
| export default useEvent; |
@@ -10,6 +10,3 @@ "use strict"; | ||
| function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; } | ||
| /* eslint-disable @typescript-eslint/ban-types */ | ||
| /* eslint-disable react-hooks/exhaustive-deps */ | ||
| function useEvent(callback) { | ||
| const useEvent = callback => { | ||
| const fnRef = React.useRef(callback); | ||
@@ -19,3 +16,3 @@ fnRef.current = callback; | ||
| return memoFn; | ||
| } | ||
| }; | ||
| var _default = exports.default = useEvent; |
+1
-0
@@ -10,1 +10,2 @@ export { default as useEvent } from './hooks/useEvent'; | ||
| export { default as toArray } from './Children/toArray'; | ||
| export { default as mergeProps } from './mergeProps'; |
+7
-0
@@ -18,2 +18,8 @@ "use strict"; | ||
| }); | ||
| Object.defineProperty(exports, "mergeProps", { | ||
| enumerable: true, | ||
| get: function () { | ||
| return _mergeProps.default; | ||
| } | ||
| }); | ||
| Object.defineProperty(exports, "mergeWith", { | ||
@@ -100,4 +106,5 @@ enumerable: true, | ||
| var _toArray = _interopRequireDefault(require("./Children/toArray")); | ||
| var _mergeProps = _interopRequireDefault(require("./mergeProps")); | ||
| function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); } | ||
| function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; } | ||
| function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } |
@@ -1,2 +0,2 @@ | ||
| declare const _default: () => boolean; | ||
| export default _default; | ||
| declare const getIsMobile: () => boolean; | ||
| export default getIsMobile; |
+2
-2
@@ -10,3 +10,3 @@ "use strict"; | ||
| let cached; | ||
| var _default = () => { | ||
| const getIsMobile = () => { | ||
| if (typeof cached === 'undefined') { | ||
@@ -17,2 +17,2 @@ cached = (0, _isMobile.default)(); | ||
| }; | ||
| exports.default = _default; | ||
| var _default = exports.default = getIsMobile; |
+4
-4
| { | ||
| "name": "@rc-component/util", | ||
| "version": "1.9.0", | ||
| "version": "1.10.0", | ||
| "description": "Common Utils For React Component", | ||
@@ -49,3 +49,3 @@ "keywords": [ | ||
| "@types/jest": "^30.0.0", | ||
| "@types/node": "^24.6.1", | ||
| "@types/node": "^25.0.3", | ||
| "@types/react": "^19.2.7", | ||
@@ -63,5 +63,5 @@ "@types/react-dom": "^19.2.2", | ||
| "father": "^4.1.3", | ||
| "glob": "^11.0.3", | ||
| "glob": "^13.0.0", | ||
| "husky": "^9.1.6", | ||
| "lint-staged": "^15.1.0", | ||
| "lint-staged": "^16.2.7", | ||
| "prettier": "^3.3.2", | ||
@@ -68,0 +68,0 @@ "rc-test": "^7.0.14", |
+2
-2
@@ -16,4 +16,4 @@ # rc-util | ||
| [travis-url]: https://travis-ci.com/react-component/util | ||
| [github-actions-image]: https://github.com/react-component/util/workflows/CI/badge.svg | ||
| [github-actions-url]: https://github.com/react-component/util/actions | ||
| [github-actions-image]: https://github.com/react-component/util/actions/workflows/react-component-ci.yml/badge.svg | ||
| [github-actions-url]: https://github.com/react-component/util/actions/workflows/react-component-ci.yml | ||
| [codecov-image]: https://img.shields.io/codecov/c/github/react-component/util/master.svg?style=flat-square | ||
@@ -20,0 +20,0 @@ [codecov-url]: https://app.codecov.io/gh/react-component/util |
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
195990
1.08%167
2.45%6444
0.97%