npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@payping/utils

v7.4.3

Published

PayPing utils

Downloads

47

Readme

FrontUtils

This is a package for handling payping front's common utils.

Install

yarn:

yarn add @payping/utils

npm:

npm install @payping/utils

Description

The utilities in this package are separated into 4 parts:

  1. root (@payping/utils):

| Exports | Description | | :-----------------: | :----------------------------------- | | applyTaxAndDiscount | setting tax and discount for invoice | | generateQr | function for creating a qr code |

  1. dateUtils (@payping/utils/dateUtils):

| Exports | Description | | :-----------: | :---------------------------------------------------- | | toJalali | functions for converting date/time to jalali | | toUtc | functions for converting date/time to utc | | jalaliNow | functions for getting current jalali date/time | | utcNow | functions for getting current utc date/time | | dateFormats | usable date formats for using in PayPing applications | | isBeforeToday | if given date/time is before beginning of today | | SDKDateObject | type of PayPing date objects |

  1. fetchQueue (@payping/utils/fetchQueue):

These functions are used in desktop and mobile applications for queueing api requests while device is offline and handling them after becoming online.

| Exports | Description | | :----------------: | :---------- | | QueuePool | | | initAppQueuePool | | | queueNames | | | fetchQueueReducer | | | updateQueueList | | | updateFetchingKeys | |

  1. gitHooks utils. these utils are not used in any code, just used by husky in package.json files for validating code changes.

  2. hooks (@payping/utils/hooks):

| Exports | Description | | :-------------------------: | :-------------------------------------------------------------------------------- | | useMessagedAsync | react-use's useAsync hook combined with progress bar and message | | useMessagedAsyncFn | react-use's useAsyncFn hook combined with progress bar and message | | useMessagedAsyncRetry | react-use's useAsyncRetry hook combined with progress bar and message | | useRouteNameAsDocumentTitle | set document title of the page (translations should be present inside pageTitle |

  1. locales: only used inside the frontutils package for setting translations.

  2. localeUtils (@payping/utils/localeUtils): containing config constant & functions of i18n and:

| Exports | Description | | :--------------------: | :--------------------------------------------------------------------------------------------- | | adminLocaleNameSpaces | admin dashboard namespace enum | | localeNameSpaces | dashboard namespace enum | | useIsolatedTranslation | useTranslation with namespace | | initI18next | initial config of i18next for admin dashboard | | initAdminI18next | initial config of i18next for dashboard | | injectLocaleFiles | adding locale .json files to i18n resources | | Trans | Trans component of react-i18next package. do not import Trans from react-i18next directly. |

  1. platformConstants (@payping/utils/platformConstants):

| Exports | Description | | :--------------: | :------------------------------------------------- | | commonConstants | common constant variables for all platforms | | desktopConstants | specific constant variables for phone platform | | phoneConstants | specific constant variables for desktop platform | | tabletConstants | specific constant variables for tablet platform | | webConstants | specific constant variables for web platform |

  1. query-string (@payping/utils/query-string):

| Exports | Description | | :---------------: | :---------------------------------------------- | | submitQueryParams | function for modifying query params of the page |

  1. status (@payping/utils/status): getting correct status of some methods.

  2. string (@payping/utils/string):

| Exports | Description | | :--------------------: | :------------------------------------------------------------------------------------- | | addComma | separate thousands with comma | | addOverflow | add ... at the end of long strings | | commaMaskedInputHelper | has two methods for mask and unmask to insert or remove comma separators in number | | extensionMimeMap | map file extensions to corresponding html mime type | | getFileExtension | get the extension from a file name | | getFileName | generate a file name based on its extension | | getFileType | get mime type of a file name based on its extension | | isAlphabet | is just alphabets in the string | | onlyNumbers | only allow numbers in string | | removeLeadingZeros | removes zeros at the beginning of number | | safeDeletePath | remove path from base with perpetual heading / and remove tailing / | | safeJoinPath | concat path(s) to base, with heading / and without tailing / | | safeStr | convert number to string and return fallback value if not convertable to string | | toEnDigit | replace persian digits with english ones | | toFaAlpha | convert arabic letters to persian corresponding ones | | toRightPhoneNumber | validate phone number | | unmaskStrToNum | convert string with comma to number type without comma |

  1. validation (@payping/utils/validation):

| Exports | Description | | :-------------------: | :--------------------------------------------- | | ValidEmail | validation function for Email input | | ValidMobileNumber | validation function for MobileNumber input | | ValidNationalId | validation function for NationalId input | | ValidPostalCode | validation function for PostalCode input | | ValidSheba | validation function for Sheba input | | ValidUrl | validation function for Url input | | ValidUrlWithLocalhost | validation function for UrlWithLocalhost input | | ValidLocalPhoneNumber | validation function for LocalPhoneNumber input |

Usage

import { generateQr } from "@payping/utils";
import { toJalali } from "@payping/utils/dateUtils";

Checking changes before Publish

  1. Run script for building package on local (customPrepublishOnly).
  2. Output will be in a dist folder at the root of the project.
  3. Go to the project that you want to install this package in and install it locally:
    yarn add ../frontutils/dist/

    NOTE: If your project has submodules you need to use the -W option in yarn add command and replace the version of the package in all package.json files with this route ../frontutils/dist/.