JSPM

@trt-web/core

1.0.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 330
  • Score
    100M100P100Q69406F
  • License Apache-2.0

Shared building blocks for cleaner Angular web apps

Package Exports

  • @trt-web/core
  • @trt-web/core/src/public-api.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@trt-web/core) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

@trt-web/core

  • Shared building blocks for cleaner web apps

Installation

  • With NPM (or Yarn, Bun,...):
npm install @trt-web/core

Utilities

Browser

  • BrowserPermission: browser permission helper for checking and requesting permissions.
  • LocalStorage: typed wrapper around localStorage.
  • SessionStorage: typed wrapper around sessionStorage.
  • createWorker: create a Web Worker from a function.
  • runWorker: run a function in a Web Worker and resolve its result.

Date

  • generateTimestamp: generate a timestamp value.
  • getDateRange: resolve common preset ranges and dynamic ranges into startDate / endDate.

DOM

  • generateRandomColor: generate a random color value.
  • getElementInfo: read size and position details from an element.
  • varCSS: read/write CSS custom property values.

File

  • compressImageFile: compress and resize image files.
  • fileToDataUrl: convert a file to a data URL.
  • fileToObjectUrl: convert a file to an object URL.
  • getImageSize: inspect image dimensions.

Number

  • calcBayesianRating: calculate a Bayesian-style rating using a global average prior.
  • calcHaversineDistance: calculate distance between two latitude/longitude points.
  • calcSimpleBayesianRating: calculate a weighted rating without a prior.
  • generateRandomNumber: generate integer or decimal numbers in a range.
  • formatViewCount: format a view count into compact notation like 1.2k.

Object

  • cleanObj: remove empty values from objects and nested structures.
  • removeDuplicateObjects: deduplicate object arrays while preserving structure.

Rate Limit

  • debounce: debounce function calls.
  • throttle: throttle function calls.
  • wait: pause execution for a duration.

String

  • capitalizeFirst: capitalize the first letter of a string.
  • capitalizeTextFields: capitalize string fields in objects.
  • capitalizeWords: capitalize each word in a string.
  • generateHash: create a hash string.
  • generateId: create a unique identifier.
  • generateRandomString: generate a random string.
  • generateSearchKeys: build searchable prefixes and tokens from text.
  • generateSortOrderKey: generate a sortable order key for drag-and-drop style ordering.
  • removeTones: normalize text by removing accents and unsupported characters.