# brews-toolboxjs

> Tools for your js

Latest version **1.0.19** (published 2020-05-11) · ISC license · 0 weekly downloads

## Install

```sh
npm install brews-toolboxjs
pnpm add brews-toolboxjs
yarn add brews-toolboxjs
bun add brews-toolboxjs
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.19 |
| Published | 2020-05-11 |
| First published | 2019-07-11 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 9.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | brewchetta |
| Maintainers | brewchetta |

## Links

- npm: https://www.npmjs.com/package/brews-toolboxjs
- Repository: https://github.com/brewchetta/brews-toolboxjs
- Homepage: https://github.com/brewchetta/brews-toolboxjs#readme
- Issues: https://github.com/brewchetta/brews-toolboxjs/issues
- npm.io page: https://npm.io/package/brews-toolboxjs

## Recent versions

- 1.0.19 (latest) — 2020-05-11
- 1.0.18 — 2020-04-30
- 1.0.17 — 2019-07-28
- 1.0.16 — 2019-07-28
- 1.0.15 — 2019-07-28
- 1.0.14 — 2019-07-11
- 1.0.13 — 2019-07-11
- 1.0.12 — 2019-07-11
- 1.0.11 — 2019-07-11
- 1.0.10 — 2019-07-11
- 1.0.9 — 2019-07-11
- 1.0.8 — 2019-07-11
- 1.0.7 — 2019-07-11
- 1.0.6 — 2019-07-11
- 1.0.5 — 2019-07-11
- … 5 more at https://npm.io/package/brews-toolboxjs/versions

## README

# Brew's Toolbox.js

This little toolbox has reusable code for different projects. No, they aren't yet highly developed or efficient algorithms but I like them anyhow. This is mostly for me to add code to other projects but it's obviously available for anyone to copy and use.

### capitalizeWords()

Takes in a word or words and returns them capitalized. For example:

`capitalizeWords("good morning") => Good Morning`

### compareAlphabetical() / sortAlphabetical()

The compare function takes in two values and attempts to sort them alphabetically.

`compareAlphabetical("alpha", "beta") => 1`
`compareAlphabetical("beta", "alpha") => -1`
`compareAlphabetical("beta", "beta") => 0`

The sort function takes in an array and attempts to return a new alphabetized array. For example:

`sortAlphabetical(["alpha", "gamma", "beta"])` => ["alpha", "beta", "gamma"]

This sort function is non-destructive.

### isALetter() / isAConsonant() / isAVowel()

A few simple ones that return true or false if a single string character is a letter, consonant, or vowel. For example:

`isALetter("a") => true`

`isAConsonant("a") => false`

`isAConsonant("b") => true`

`isAVowel("a") => true`

`isAVowel("b") => false`

### numWord()

This takes in a positive integer and spits out the corresponding word. For example:

`numWord(1) => "one"`

### nthNumWord()

Similar to numWord(), nthNumWord() takes in a positive integer and spits out the word in its nth form, for example:

`nthNumWord(10) => "tenth"`

### random()

Takes in an array, an object or string and returns a random element from it. For example:

`random([1, 2, 3, 4, 5]) => 2`

`random({1: "a", 2: "b", 3: "c", 4: "d", 5: "e"}) => {3: "c"}`

`random("panda") => "n"`

Many of these functions have been built to render error messages on the console if an incorrect argument gets passed in, however they won't throw errors themselves.

### stringToColor()

Takes in an argument of a string and converts that string to a hexadecimal color code. For example:

`stringToColor('I am a string') => "#cd14fb"`

### toBinary()

Takes an argument of an integer and converts that integer into a string of binary. For example:

`toBinary(5) => "101"`

### fromBinary()

Takes an argument of a string representing binary and converts that to an integer. For example:

`fromBinary("101") => 5`

## npm

I've added this as an npm package just for the fun of it. It can be added to a project by running:

`$ npm install brews-toolboxjs`

Once added, import functions to your local file like so:

`import {random, isALetter, sortAlphabetical} from 'brews-toolboxjs'`

You can also import the entire toolbox for use:

`import toolbox from 'brews-toolboxjs'`

`toolbox.isALetter("a") => true`

### Version

1.0.18

---
_Source: https://npm.io/package/brews-toolboxjs · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
