0.9.2 • Published 2 years ago

@zerodep/utils v0.9.2

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

@zerodep/utils

This is a library of commonly used utilities, formatters, tests, and guards that help developers be more productive. This is a barrel package of all @zerodep.* utility packages.

Works in the browser and on the server. Includes typescript definitions as well as tree-shakable CJS and ESM exports. Works out-of-the-box; may be configured as required.

Table of Contents

Install

npm install @zerodep/utils

Of course, you may use yarn, pnpm, or the package manager of your choice. Only npm examples are shown for brevity.

Included Packages

The @zerodep/utils package is a tree-shakable collection of utility-related packages in the @zerodep ecosystem.

Base Error

Method NamePackagePurposeSize
ZeroDepErrorerrorsA namespaced subclass of the Error object with additional properties, used by all @zerodep methodsmin    gzip

Can

A set of functions that test for specific language construct capabilities or features.

Method NamePackagePurposeSize
canIteratecan.iterateDetermine if a value is iterable in a for...of loop (with opinionated safeguards)min    gzip

Format

A set of locale-aware, configurable functions that format a value for a specific use case.

Method NamePackagePurposeSize
formatCurrencyformat.currencyA configurable, locale-aware utility to format a value to a currencymin    gzip

Guard

A collection of configurable defensive programming utilities that guard for specific data types.

Method NamePackagePurposeSize
guardArrayguard.arrayA configurable defensive programming utility to guard against non-array valuesmin    gzip
guardBigIntguard.bigintA configurable defensive programming utility to guard against non-BigInt valuesmin    gzip
guardBooleanguard.booleanA configurable defensive programming utility to guard against non-boolean valuesmin    gzip
guardDateguard.dateA configurable defensive programming utility to guard against non-Date valuesmin    gzip
guardFloatguard.floatA configurable defensive programming utility to guard against non-float valuesmin    gzip
guardFunctionguard.functionA configurable defensive programming utility to guard against non-function valuesmin    gzip
guardIntegerguard.integerA configurable defensive programming utility to guard against non-integer valuesmin    gzip
guardJSONguard.jsonA configurable defensive programming utility to guard against non-JSON object valuesmin    gzip
guardNumberguard.numberA configurable defensive programming utility to guard against non-float/non-integer valuesmin    gzip
guardObjectguard.objectA configurable defensive programming utility to guard against non-plain JavaScript object valuesmin    gzip
guardStringguard.stringA configurable defensive programming utility to guard against non-string valuesmin    gzip

Is

A collection of utility methods to determine the classification or equality of a value.

Method NamePackagePurposeSize
isArrayis.arrayA utility to determine if a value is an arraymin    gzip
isBigIntis.bigintA utility to determine if a value is a BigIntmin    gzip
isBooleanis.booleanA utility to determine if a value is a booleanmin    gzip
isDateis.dateA utility to determine if a value is a Datemin    gzip
isEqualis.equalA utility to deeply compare two values of any type for equalitymin    gzip
isFloatis.floatA utility to determine if a value is a non-infinite floatmin    gzip
isFunctionis.functionA utility to determine if a value is a functionmin    gzip
isIntegeris.integerA utility to determine if a value is a non-infinite integermin    gzip
isJSONis.jsonA utility to determine if a value is a serializable JSON objectmin    gzip
isMapis.mapA utility to determine if a value is a Mapmin    gzip
isNilis.nilA utility to determine if a value is null or undefinedmin    gzip
isNullis.nullA utility to determine if a value is nullmin    gzip
isNumberis.numberA utility to determine if a value is a non-infinite float or integermin    gzip
isObjectis.objectA utility to determine if a value is a plain JavaScript objectmin    gzip
isPromiseis.promiseA utility to determine if a value is a Promisemin    gzip
isRegexis.regexA utility to determine if a value is a regular expressionmin    gzip
isSetis.setA utility to determine if a value is a Setmin    gzip
isStringis.stringA utility to determine if a value is a stringmin    gzip
isSymbolis.symbolA utility to determine if a value is a Symbolmin    gzip
isTypedArrayis.typedarrayA utility to determine if a value is a Typed Arraymin    gzip
isUndefinedis.undefinedA utility to determine if a value is undefinedmin    gzip
isWeakMapis.weakmapA utility to determine if a value is a WeakMapmin    gzip
isWeakSetis.weaksetA utility to determine if a value is a WeakSetmin    gzip

Locale

A collection of helpers to appropriately work with locales.

Method NamePackagePurposeSize
localeGetlocale.getA helper to get the locales of the environment (server or browser)min    gzip
localeSettingslocale.settingsThe locale configuration getter and settermin    gzip

To

A collection of utility methods to convert a value to a specific data type.

Method NamePackagePurposeSize
toJSONto.jsonA configurable function that converts a value to a JSON objectmin    gzip
toNumberto.numberA configurable utility to convert a value (string, boolean, date, or BigInt) to a numbermin    gzip
toStringto.stringA configurable utility to convert a value (number, boolean, array, object, more...) to a locale-appropriate stringmin    gzip

Types

Some useful typescript type declarations.

Type NamePackagePurposeSize
TypesCurrencies &TypesCurrenciesCryptotypes.currenciesTypescript type declaration of currencies and crypto-currenciesN/A
TypesLocalestypes.localesTypescript type declaration of localesN/A
TypesTimeZonestypes.timezonesTypescript type declaration of time zonesN/A
TypesUnitstypes.unitsTypescript type declaration of supported units of measureN/A

Related Packages

The following @zerodep packages may be helpful or more appropriate for your specific case:

Advantages of @zerodep Packages

We help make source code more readable, more secure, faster to craft, less likely to have hidden defects, and easier to maintain.

  • Zero npm dependencies - completely eliminates all risk of supply-chain attacks, decreases node_modules folder size
  • Fully typed - typescript definitions are provided for every package for a better developer experience
  • Semantically named - package and method names are easy to grok, remember, use, and read
  • Documented - actually useful documentation with examples and helpful tips
  • Intelligently Packaged - multiple npm packages of different sizes available allowing a menu or a-la-carte composition of capabilities
  • 100% Tested - all methods and packages are fully unit tested
  • ESM & CJS - has both ecmascript modules and common javascript exports, both are fully tree-shakable
  • CDN Available - available on fast content delivery networks in UMD, CJS and ESM formats
  • FP Inspired - gently opinionated to encourage functional programming style for cleaner and more maintainable software
  • Predictably Versioned - semantically versioned for peace-of-mind upgrading, this includes changelogs
  • MIT Licensed - permissively licensed for maximum usability

Support

All @zerodep packages are built for the ES2020 specification. Should you need to support older environments you will need to add appropriate polyfills. All packages are tested on the following platforms/browsers:

Browsers

  • Chrome - last 2 major versions
  • Firefox - last 2 major versions
  • Safari - last 2 major versions
  • Edge - last 2 major versions
  • Android - last 2 major versions
  • iOS - last 2 major versions

Node

  • v16.x - Gallium LTS
  • v14.x - Fermium LTS

It is likely the package will work on other technologies and version, however development and testing effort is only spent on the above.

Semver

All @zerodep packages, including this one, adhere to Semantic Versioning practices:

  • major versions: correlates with breaking changes to one or more method signatures
  • minor versions: includes addition of new functionality or backwards-compatible software improvements
  • patch versions: are reserved for copy changes, documentation enhancements and bug fixes

The above said, a security best practice is to pin your software packages to specific versions and only upgrade to more recent releases after careful inspection of any CHANGELOG, release notes and all software changes.

Resources

License

MIT

0.9.2

2 years ago

0.9.1

2 years ago

0.9.0

2 years ago

0.8.0

2 years ago

0.7.0

2 years ago

0.6.0

2 years ago

0.5.0

2 years ago

0.4.0

2 years ago