What is @chakra-ui/shared-utils?
@chakra-ui/shared-utils is a utility package that provides shared utility functions and constants used across various Chakra UI components. It helps in maintaining consistency and reducing code duplication within the Chakra UI library.
What are @chakra-ui/shared-utils's main functionalities?
isFunction
The `isFunction` utility checks if a given value is a function. This is useful for type-checking and ensuring that certain operations are only performed on functions.
const { isFunction } = require('@chakra-ui/shared-utils');
console.log(isFunction(() => {})); // true
console.log(isFunction(123)); // false
isObject
The `isObject` utility checks if a given value is a plain object. This helps in validating inputs and ensuring that operations meant for objects are not mistakenly applied to other types.
const { isObject } = require('@chakra-ui/shared-utils');
console.log(isObject({})); // true
console.log(isObject(null)); // false
mergeWith
The `mergeWith` utility merges two objects deeply, combining their properties. This is useful for combining configuration objects or state objects in a predictable manner.
const { mergeWith } = require('@chakra-ui/shared-utils');
const obj1 = { a: 1, b: { c: 2 } };
const obj2 = { b: { d: 3 } };
const result = mergeWith(obj1, obj2);
console.log(result); // { a: 1, b: { c: 2, d: 3 } }
Other packages similar to @chakra-ui/shared-utils
lodash
Lodash is a popular utility library that provides a wide range of functions for common programming tasks, such as manipulating arrays, objects, and functions. It offers more comprehensive functionality compared to @chakra-ui/shared-utils, but it is also larger in size.
ramda
Ramda is a functional programming library for JavaScript that emphasizes immutability and side-effect-free functions. It provides utilities for working with arrays, objects, and functions, similar to @chakra-ui/shared-utils, but with a focus on functional programming paradigms.
underscore
Underscore is a utility library that provides a range of functions for dealing with arrays, objects, and other data types. It is similar to Lodash but with a smaller footprint and fewer features. It offers some overlapping functionality with @chakra-ui/shared-utils.
@chakra-ui/shared-utils
A Quick description of the component
This is an internal utility, not intended for public usage.
Installation
yarn add @chakra-ui/shared-utils
npm i @chakra-ui/shared-utils
Contribution
Yes please! See the
contributing guidelines
for details.
Licence
This project is licensed under the terms of the
MIT license.