@codecraftkit/utils
v1.5.3
Published
Utils
Downloads
43
Readme
Code Craft - Utils
INSTALLING
via npm
npm install @codecraftutils
Changelog
1.4.0
Requires uuid
package: https://www.npmjs.com/package/uuid
Changes
generateId()
: now generate and return an uuid strinv (v4)
HOW IS IT USED?
const Utils = require('@codecraftutils');
Utils.capitalizeFirstLetter('hello');
// Or
const { handlePagination } = require('@codecraftutils');
const { skip, limit } = handlePagination({ page: 1, limit: 20 })
// mongo example (mongoose)
const itemList = Item.find({}).skip(skip).limit(limit);
AVAILABLE METHODS
Methods | Params | Return :----------------------- | :--------------- | :--------- convertConstantToArray | obj | Array convertSpecificToObject | obj, id | Object convertObjectToArray | obj | Array listObjectToSimple | list, key | Array strReplaceAll | str, replace, by | String isBase64 | text | Boolean setAsObject | data | Object orderJson | obj | Object randomString | length | String capitalizeFirstLetter | string | String generateId | length | Number Int handlePagination | { page, limit} | Number Int unique | array | Array currency | Number, object | Number parseCurrency | (Number/String), Object | Array parsePhoneNumber | rawNumber, usage | normalize | | queryExtend | | abbr | | calculateAge | | __logge | | consoleColors, | | generateRandomFileName | | removeAccents | | nameSanitizer | | randomLimit | | generateLookups | | stringToCamelCase | | getMonth | | listMonth | | listGenres | | listLang | | listMaritalStatus | | isValidJSONString | String | Boolean getDayOfYear | Date | Number
Descriptions
generateId
: @param length (Int):return a String as long as length paramhandlePagination
: @param options Object { page: Int, limit: Int}: return an object with skip and limit properties. This is for mongo queries.unique
: @param array Array | return and array with uniques values.currency
: @params value: Number, options: Object | return formatted NumberparseCurrency
: @params value: Number or String, options: Object | return formatted Number. Extension for format-currencygetDayOfYear
: @param date: Date, return Number (day of year)