# launchable

> All the shared logic and helpers used by Launchable Studio

Latest version **1.1.0** (published 2023-12-28) · ISC license · 0 weekly downloads

## Install

```sh
npm install launchable
pnpm add launchable
yarn add launchable
bun add launchable
```

## 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.1.0 |
| Published | 2023-12-28 |
| First published | 2023-12-09 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 10.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Daniel Stuski |
| Maintainers | launchable |

## Links

- npm: https://www.npmjs.com/package/launchable
- Repository: https://github.com/Launchable-Studio/launchable
- Homepage: https://github.com/Launchable-Studio/launchable#readme
- Issues: https://github.com/Launchable-Studio/launchable/issues
- npm.io page: https://npm.io/package/launchable

## Dependencies (2)

- [lodash](https://npm.io/package/lodash.md) ^4.17.21
- [date-fns](https://npm.io/package/date-fns.md) ^2.30.0

## Recent versions

- 1.1.0 (latest) — 2023-12-28
- 1.0.1 — 2023-12-13
- 1.0.0 — 2023-12-09

## README

# Launchable

[![NPM](https://flat.badgen.net/npm/v/launchable)](https://www.npmjs.com/package/launchable) [![Bundle](https://flat.badgen.net/bundlephobia/minzip/launchable)](https://bundlephobia.com/result?p=launchable@latest)

All the Javascript shared logic and helpers used by [Launchable Studio](https://launchable.studio).

## Installation

```bash
npm install launchable

yarn add launchable
```

## Usage

### `cx(className, conditionals)`

Generates a string of class names based on the provided base class name and a set of conditional class names.

We use it to conditionally style elements.

```javascript
// returns "base-class conditional-class-1 conditional-class-3"
cx("base-class", {
  "conditional-class-1": true,
  "conditional-class-2": false,
  "conditional-class-3": true,
});
```

### `dateFromNow(date)`

Calculates the distance between the current date and the provided date.

```javascript
// returns "5 days ago"
dateFromNow("2022-03-01");
```

```javascript
// returns "2 months ago"
dateFromNow("2022-01-06");
```

### `defined(value)`

Checks if a value is defined and not null.

We use it to conditionally render elements even when the value is an empty string or 0.

```javascript
// returns true
defined(0);

// returns true
defined("");

// returns false
defined(undefined);
```

### `formatNumber(number)`

Formats a number by inserting commas as thousand separators.

We use it to format large numbers in analytics stats, etc.

```javascript
const num = 1234567890;
const formattedNum = formatNumber(num);
console.log(formattedNum); // Outputs: "1,234,567,890"
```

### `nullify(value)`

Checks if the provided value is an empty string. If it is, it returns null; otherwise, it returns the original value.

We use it to prevent empty values in a nullable database column.

```javascript
// returns null
nullify("");

// returns "Hello, World!"
nullify("Hello, World!");
```

## Creating docs:

1. Open this repository in Cursor.
2. Type ⌘K and paste "Create a brief documentation for docs of how to use with examples".
3. Paste the output here.

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