npm.io
6.0.8 • Published 2 weeks ago

@appello/common

Licence
ISC
Version
6.0.8
Deps
3
Size
285 kB
Vulns
0
Weekly
0

@appello/common

A collection of reusable TypeScript utilities, React hooks, helper types, and shared functions for building modern React and React Native applications.

Designed to be lightweight, tree-shakable, and framework-agnostic wherever possible.


Table of Contents


Features

  • Reusable React hooks
  • Utility functions for everyday development
  • Shared TypeScript types
  • Fully typed API
  • Tree-shakable exports
  • Compatible with React and React Native
  • Immutable helper functions
  • Zero runtime dependencies (except where required)

Installation

npm install @appello/common

Quick Start

Import only what you need.

import { useInterval, useDebounce, isNil, deepMergeObjects } from '@appello/common';

Every utility is exported from the package root.

import { entries, keys, pick } from '@appello/common';

Hooks

The package includes reusable React hooks for state management, lifecycle helpers, timers, forms, and utility behavior.

Category Hooks
Timing useInterval, useCodeTimer, useDebounce
Lifecycle useMountEffect, useUnmountEffect, useUpdateEffect, useFirstMountState, useIsMounted
State useDefault, useStateObject, useStep, useSwitchValue, usePrevious, useLatest, useManualUpdate, useListState
Forms useHookFormPersist, useSelectOptions
Utilities useCombinedRef, useMemoCallback, useQueryParamsBuilder, useIsClient

Each hook has its own documentation inside the corresponding package folder.


Utilities

Utilities are grouped by purpose.

Type Guards
  • isArray
  • isBlob
  • isDate
  • isEmpty
  • isFile
  • isFloat
  • isFunction
  • isInt
  • isNil
  • isNumber
  • isObject
  • isPrimitive
  • isPromise
  • isString
  • isSymbol

Object Utilities
  • deepMergeObjects
  • deepEqual
  • entries
  • keys
  • omit
  • pick
  • deepKeys
  • shake

Array Utilities
  • difference
  • intersection
  • uniq
  • compact
  • mergeCollectionByKey
  • group
  • fork
  • alphabetical
  • chunk
  • sequence
  • replaceOrAppend
  • filterMap
  • keyBy
  • countBy

Browser & Environment
  • checkIsServer
  • checkNavigator

File Utilities
  • formDataBuilder
  • makeFormData
  • mapFormData
  • toBase64
  • getFileExtension
  • getFileName

String Utilities
  • capitalize
  • truncate
  • pluralize
  • enumKeyToReadable

Number Utilities
  • formatCurrency
  • formatNumber
  • toFinite

URL Utilities
  • makeQueryString

Miscellaneous
  • debounce
  • throttle
  • sleep
  • noop
  • getDirtyValues
  • getProto
  • getWeekdaysNames
  • enumToSelectOptions

Types

The package exports commonly used utility types such as:

  • ElementType
  • Nullable
  • NotNullable
  • Nillable
  • NotNillable
  • Unidentifiable
  • Negative
  • ValueOf
  • AnyObject
  • AnyPromise
  • PartialRecord
  • PartialDeep
  • ResponseErrors
  • UnknownFunction
  • AnyFunction
  • PromiseType
  • RequiredKeys
  • OptionalKeys
  • Merge
  • AsyncReturnType
  • FirstArgument

Development

Every public module should be exported from the package root.

import { useInterval, deepMergeObjects, isNil } from '@appello/common';

When adding a new hook or utility:

  • create a dedicated folder;
  • export it through an index.ts;
  • re-export it from the package root;
  • include a README with usage examples.

This keeps the API consistent and enables tree-shaking.


  • Package Version: npm version
  • License: ISC
  • Author: Appello Software

For more examples and advanced usage, check the test files in the repository.

Keywords