# @firecamp/utils

> Utils functions

Latest version **0.0.24** (published 2023-04-27) · AGPL-3.0 license · 0 weekly downloads

## Install

```sh
npm install @firecamp/utils
pnpm add @firecamp/utils
yarn add @firecamp/utils
bun add @firecamp/utils
```

## Health

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

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.24 |
| Published | 2023-04-27 |
| First published | 2022-06-24 |
| Weekly downloads | 0 |
| License | AGPL-3.0 |
| TypeScript types | bundled |
| Module format | CommonJS |
| Node | >=10 |
| Dependencies | 9 |
| Unpacked size | 245.2 KB |
| Known vulnerabilities | 0 (+8 in 3 direct dependencies) |
| Install scripts | no |
| GitHub stars | 317 |
| Maintainers | nishchit14 |

## Links

- npm: https://www.npmjs.com/package/@firecamp/utils
- Repository: https://github.com/firecamp-io/firecamp/packages/utils
- npm.io page: https://npm.io/package/@firecamp/utils

## Dependencies (9)

- [uuid](https://npm.io/package/uuid.md) ^8.3.2
- [faker](https://npm.io/package/faker.md) 5.5.3
- [dedupe](https://npm.io/package/dedupe.md) ^3.0.3
- [lodash](https://npm.io/package/lodash.md) 4.17.21
- [nanoid](https://npm.io/package/nanoid.md) 3.3.4
- [deepmerge](https://npm.io/package/deepmerge.md) ^4.2.2
- [clean-deep](https://npm.io/package/clean-deep.md) ^3.4.0
- [is-electron](https://npm.io/package/is-electron.md) ^2.2.1
- [json-templates](https://npm.io/package/json-templates.md) ^4.2.0

## Recent versions

- 0.0.24 (latest) — 2023-04-27
- 0.0.23 — 2023-04-27
- 0.0.22 — 2023-04-27
- 0.0.21 — 2023-04-01
- 0.0.20 — 2023-03-28
- 0.0.19 — 2023-03-24
- 0.0.18 — 2023-03-15
- 0.0.17 — 2023-02-23
- 0.0.16 — 2023-02-23
- 0.0.15 — 2023-02-09
- 0.0.14 — 2023-02-02
- 0.0.13 — 2023-02-02
- 0.0.12 — 2023-01-14
- 0.0.11 — 2022-12-10
- 0.0.10 — 2022-08-26
- … 8 more at https://npm.io/package/@firecamp/utils/versions

## README

## @firecamp/utils

### Usage

```ts
import { _array, _object } from '@firecamp/utils';
```

### <ins>API</ins>
- [Array methods](#array)
- [Object methods](#object)

### Array

```ts
/**
 * Creates an array excluding all given values using SameValueZero for equality comparisons.
 *
 * @reference https://lodash.com/docs/4.17.15#without
 */
export type TWithout = (
  array: any[],
  element: string | number | Function
) => (string | number)[];

/**
 * This method is like _.sortBy except that it allows specifying the sort orders of
 * the iteratees to sort by. If orders is unspecified, all values are sorted in ascending order.
 * Otherwise, specify an order of "desc" for descending or "asc" for ascending sort order
 * of corresponding values.
 *
 * @reference https://lodash.com/docs/4.17.15#orderBy
 */
export type TOrderBy = (
  array: object[],
  iteratee: string | Function,
  order: 'asc' | 'desc'
) => object[];

/**
 * Creates an object composed of keys generated from the results of running each element of
 * collection thru iteratee. The corresponding value of each key is the last element responsible
 * for generating the key. The iteratee is invoked with one argument: (value).
 *
 * @reference https://lodash.com/docs/4.17.15#keyBy
 */
export type TKeyBy = (array: object[], prop: string) => object;

/**
 * Removes elements from array corresponding to indexes and returns an array of elements without values exist at indexes.
 *
 */
export type TRemoveItem = (array: any[], index: number) => any[];

/**
 * This method is like _.uniq except that it accepts iteratee which is invoked for each element in array to generate
 * the criterion by which uniqueness is computed. The order of result values is determined by the order they occur in the array.
 * The iteratee is invoked with one argument: (value).
 *
 * @reference https://lodash.com/docs/4.17.15#uniqBy
 */
export type TUniqBy = (
  array: any[],
  iteratee: string | number | Function
) => any[];
```

### Object

```ts
import { Options } from 'deepmerge'

/**
 * Gets the size of collection by returning its length for array-like values or 
 * the number of own enumerable string keyed properties for objects.
 * 
 * @reference https://lodash.com/docs/4.17.15#size
 */
export type TSize = (object: object) => number

/**
 * Checks if path is a direct property of object.
 * 
 * @reference https://lodash.com/docs/4.17.15#has
 */
export type THas = (object: object, prop: string | number) => boolean

/**
 * The opposite of _object.pick; this method creates an object composed of the own and 
 * inherited enumerable property paths of object that are not omitted.
 */
export type TOmit = (object: object, paths: string[]) => object

/**
 * Creates an object composed of the picked object properties.
 * 
 * @reference https://lodash.com/docs/4.17.15#pick
 */
export type TPick = (object: object, properties: string[]) => object

/**
 * Checks if value is the language type of Object. (e.g. objects)
 * note: return false if an object is an array
 * 
 * @reference https://lodash.com/docs/4.17.15#isObject
 */
export type TIsObject = (object: any) => boolean

/**
 * Merges the enumerable properties of two or more objects deeply.
 * 
 * @reference https://www.npmjs.com/package/deepmerge
 */
export type TMergeDeep = (target: object, source: object, cleanDeep?: boolean, options?: Options) => object

/**
 * return the object which contains the changes performed into the new object
 */
export type TDifference = (oldObject: object, newObject: object) => object

/**
 * return the list of paths from the object which path value matched with the passed value
 */
export type TValuePath = (object: object, value: any, currentPath: string) => string[]

/**
 * return the object after removing the specific characters from the 
 * object properties to the n-th level
 */
export type TOmitCharsFromProp = (object: object, chars?: string[]) => object
```

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