A lightweight npm package for data transformation utilities.
npm:
npm install @pologora/data-transformer
const {
invertBoolean,
addValues,
stringifyValue,
coerceToType,
convertToNumber,
convertToBoolean,
convertToBigInt,
convertToObject,
convertArrayToObject,
} = require('@pologora/data-transformer');
- invertBoolean: Inverts a boolean value.
- addValues: Adds two values together.
- stringifyValue: Converts a value to its string representation.
- coerceToType: Coerces a value to a specified data type.
- convertToNumber: Converts a value to a number.
- convertToBoolean: Converts a value to a boolean.
- convertToBigInt: Converts a value to a BigInt.
- convertToObject: Converts a value to a Object.
- convertArrayToObject: Converts an array to a Object.
For most functions, passing null
or undefined
as input will result in an
error being thrown, except for the following cases:
-
coerceToType: Passing
null
orundefined
will throw an error for most data types, except when coercing to boolean usingcoerceToType(value, 'boolean')
. -
convertToBoolean: Returns
false
when passednull
orundefined
.
Contributions are welcome! If you have any suggestions, bug reports, or feature requests, please open an issue.
This package is licensed under the MIT License.