1
0
Fork 0
js-utils/README.md

5.0 KiB

JS Utils

This project is a collection of utilities meant to extend lodash, collected from my other Typescript projects, lightly documented, and heavily tested.

Contents

Status

Pipeline status Lines of Code Test coverage MIT license FOSSA Status

Open bug count Open issue count Closed issue count

Renovate badge Dependency status Dev dependency status Known vulnerabilities

Maintainability score Technical debt ratio Quality issues Language grade: JavaScript Total alerts

Releases

github release link github release version github commits since release

npm package link npm release version Typescript definitions

Usage

Install:

yarn add -D @apextoaster/js-utils

And import:

import { mustExist } from '@apextoaster/js-utils';

The library is bundled and has no dependencies.

Features

  • array mapper
    • map elements to keys by order
    • skip initial, gather remaining
  • async
    • defer
    • promise timeout
    • wait for predicate
  • async tracker
    • track and log leaking async resources for tests
  • buffer
  • checklist
    • include/exclude mode (whitelist/blacklist)
  • child process
    • wait for exit and gather output
    • write and flush
  • env
    • check DEBUG
  • list
    • concat lists
  • logger
    • get test logger (null or console depending on DEBUG)
  • map
    • must get (assertion)
    • get or default
    • get head from list value
    • get head or default
    • set or push to key
    • merge maps
    • push-merge maps
    • convert dict to map and vice versa
    • normalize map values to lists
    • create map from name-value pairs
  • maybe
    • is nil test (negative nil test)
    • count array or maybe
    • filter nil from list
    • must find (assertion)
    • does exist (positive nil test)
    • must exist (assertion)
    • must default (assertion)
  • pid file
    • write pid file
    • delete pid file
  • reflect
    • get constructor name
    • get methods from prototype chain
  • signals
    • wait for OS signal
  • string
    • left pad (please don't import just for this)
    • trim with suffix