@alanscodelog/utils
TypeScript icon, indicating that this package has built-in type declarations

3.2.0 • Public • Published

Docs Build Release

A collection of my utility functions and types. Mostly intended for use within my own projects.

Docs

Install

npm install @alanscodelog/utils
# or
yarn add @alanscodelog/utils

Usage

There's four types of utility functions available:

  • utils - the main utility functions
    • Within these, some are node/browser only, they are tagged accordingly (@env node/@env browser).
  • testing - functions that are only useful for testing purposes
  • retypes - existing functions typed as something else (e.g. Object.keys cast to a type that's useful for iterating, etc)
  • types - all the types used internally + any utility types And there's also:
  • colors - contains the basic ansi escape codes, for small scripts, or debugging, where I don't need to add chalk.
// everything can be imported directly from the package (except individual colors)
import { keys, debounce, ... } from "@alanscodelog/utils"

You can also import an entire set, although this is not recommended because it makes it so the imports can't be treeshaken. Still it's possible because it's occasionally useful for prototyping.

import {utils, testing, retypes, types} from "@alanscodelog/utils"

Usually though, for better clarity, I import directly from the folders in the dist folder. The path becomes kind of long though so I set an alias to it (@utils) in my babel/typescript configs.

import { keys } from "@alanscodelog/utils/dist/retypes"
// @alanscodelog/utils/dist aliased to @utils:
import { keys } from "@utils/retypes"

Readme

Keywords

none

Package Sidebar

Install

npm i @alanscodelog/utils

Weekly Downloads

4

Version

3.2.0

License

MIT

Unpacked Size

478 kB

Total Files

342

Last publish

Collaborators

  • alanscodelog