@gatekeeper_technology/utils
v0.0.4
Published
Gatekeeper's generic utils - shared in NPM
Readme
@gatekeeper-technology/utils
Gatekeeper's generic utilities package, designed to provide reusable utility functions for various common operations. This package is shared via NPM and can be used across multiple projects.
Features
- Date and Time Utilities: Functions for handling and formatting dates and times.
- General Utilities: Common utility functions such as sorting arrays, formatting text, and more.
Installation
Install the package via Yarn:
yarn add @gatekeeper-technology/utilsUsage
Import the utilities you need:
import { getDisplayValue, formatText, sortArrayByField } from "@gatekeeper-technology/utils";
// Example usage
const formattedText = formatText(" This is a Text ");
console.log(formattedText); // Output: "this_is_a_text"Utilities Overview
General Utilities
- getDisplayValue(object, field): Safely retrieves the value of a field from an object.
- getDisplayLabel(object, field): Retrieves a label for a field from an object.
- formatText(inputText, type?): Formats text by replacing spaces with underscores and converting to lowercase or uppercase.
- sortArrayByField(array, fieldName, sortDirection): Sorts an array of objects by a specified field.
Date and Time Utilities
Utilities for working with dates and times are available in the date_time_utils module.
Development
Building the Project To build the project, run:
yarn buildRunning Tests This project uses Jest for testing. To run the tests, execute:
yarn testDirectory Structure
- src/: Contains the source code for the utilities.
- test/: Contains unit tests for the utilities.
- coverage/: Contains code coverage reports.
License
This project is licensed under the GNU Lesser General Public License v2.1 or later. See the LICENSE file for details.
Contributing
Contributions are welcome! Please open an issue or submit a pull request on GitHub.
Author
David Holtzhausen
