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

@front-utils/utils

v0.2.6

Published

Javascript utils

Downloads

558

Readme

Front-utils/utils

Javascript utilities

Base

| name | description | | ----------------------- | --------------------------------------------------------------------------------------------------------------------------------- | | declOfNum | Returns a string from the decls array. | | uuid | Returns a UUID string. | | iteratorToList | Returns an array of values from the iterator. | | createObserver | Returns an ObserverInstance with subscribe and notify methods. | | randomIntMinMax | Returns a random integer. | | replaceSearchMatch | Returns a modified string with matches replaced. | | createSafetyRegString | Returns a string with escaped special characters. | | safeHandleDecorate | Returns a tuple with an error or result. | | safeHandleDecorateAsync | Returns a promise resolving to a tuple with an error or result. | | shallowCompare | Utility that checks if two objects have the same keys and values at the first level of depth, without considering nested objects. |

Check

| name | description | | ----------------- | -------------------- | | isString | checks argument type | | isBoolean | - | | isFunction | - | | isNumber | - | | isObjectType | - | | isObject | - | | isAsyncFunction | - | | isNull | - | | isUndefined | - | | isNullOrUndefined | - |

File

| name | description | | --------------------- | ----------------------------------------------------------------- | | isEqual2Files | compares two files based on name, size, and type. | | base64ToBytesBuffer | converts a Base64 string to an ArrayBuffer. | | fileToBase64 | converts a File to a Base64 string using a FileReader. | | base64ToFile | creates a File from a Base64 string with specified type and name. | | getBodyFromBase64 | extracts the body from a Base64 string. | | getBase64BodyFromFile | converts a File to a Base64 body string. |

Image

| name | description | | -------------------- | ---------------------------------------------------------------------- | | getImageMeta | returns an object containing the image's naturalHeight and naturalWidt | | getImageMetaFromFile | creates a URL from a File object and calls getImageMeta with this URL. |

Net

| name | description | | ----------------- | -------------------------------------------------------------------------------------------------------------------- | | downloadByUrl | creates an anchor element, sets its download and href attributes, and triggers a click to download a file from a URL | | downloadLocalFile | creates a Blob from a File, generates a URL for it, and calls downloadByUrl. | | encodeQueryParams | iterates over an object, converts values to strings or JSON, and appends them to a URLSearchParams object |

Number

| name | description | | ----------------------------- | ----------------------------------------------------------------------------------------------------------- | | numberTo2SignString | checks if the input is a number and formats it to a two-sign string. | | numberWithSpaces | formats a number with spaces as thousands separators and optionally replaces spaces with a custom separator | | getNumberFromStringWithSpaces | converts a string with spaces into a number, returning 0 if conversion fails. |

Date

  1. The code imports necessary utilities and types for date manipulation.
  2. It defines constants and functions for formatting and validating dates.
  3. Functions are provided to add time intervals (milliseconds, minutes, hours, days, months) to dates.
  4. Date formatting functions convert dates to strings in various formats, including localized and ISO formats.
  5. Additional functions handle date comparisons and conversions between different date string formats.

| name | example/description/return | | ------------------------------------ | -------------------------------------------------------------------------------------------------------------------------------- | | format | Intl.format (Ru) | | isValidDate | check date is valid | | addMilliseconds | addMilliseconds(date, 5) | | addMinutues | addMinutues(date, 5) | | addHours | addHours(date, 5) | | addDays | addDays(date, 5) | | addMonth | addMonth(date, 5) | | formatDateWithOptions | The function attempts to format the date using the Intl.DateTimeFormat constructor with the Russian locale and provided options. | | get3digitMonthName | 'янв' | | toLocalTimeString | преобразование времени к псевдо локальному, в формате ISO8601 (без смещения) | | | | getMaxTimeEndDate | - | | getOptionalYear | - | | getDateString | '1 янв' | | getDateFullString | '1 янв 2023' | | getDateRangeString | '1 фев – 14 фев' | | getShortDateRangeString | '1 – 14 фев | | getEnDateStringFromRu | - | | isValidDateString | - | | getDateParamsFromCalendarFormat | - | | createCalendarStringFromISO | '01.02.2023 - 01.03.2023' | | getMonthNameByIndex | 'январь' | | getMonthNameByIndexGenitiveCase | 'января' | | getMonthNameByIndexPrepositionalCase | 'январе' | | getFullDateString | '6 апреля 2022' | | formatDateRangeFromCalendar | '1 фев – 14 фев' | | getMonthYearFullString | январь 2021 | | getWeekRangeDates | | | getWeekRange | '3 – 9 апр' | | getQuarterNumber | | | getQuarterString | 'II квартал 2000' | | getLocalDateString | | | getFullDatePeriod | 26 марта - 26 марта | | getCurrentWeekStartDate | | | getNextWeekPeriod | | | getNextMonthPeriodDates | | | formatShortEndDate | | | compareDates | |