# @mimik/lib-filters

> Libraries for filter process

Latest version **2.1.1** (published 2026-07-07) · MIT license · 0 weekly downloads

## Install

```sh
npm install @mimik/lib-filters
pnpm add @mimik/lib-filters
yarn add @mimik/lib-filters
bun add @mimik/lib-filters
```

## Health

**Score 60/100 (C)** — status: active.

Positive: esm support; no vulnerabilities; recently updated; high maintenance score.

Warnings: low downloads; no types.

## Facts

| | |
|---|---|
| Version | 2.1.1 |
| Published | 2026-07-07 |
| First published | 2018-06-29 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Node | >=24.0.0 |
| Dependencies | 2 |
| Unpacked size | 10.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | mimik technology inc |
| Maintainers | mimik-npm-editor, hofachiang, miburger, mimikopensource, sasan.raisdana |
| Keywords | mimik, microservice |

## Links

- npm: https://www.npmjs.com/package/@mimik/lib-filters
- Repository: https://bitbucket.org/mimiktech/lib-filters
- Homepage: https://bitbucket.org/mimiktech/lib-filters#readme
- Issues: https://bitbucket.org/mimiktech/lib-filters/issues
- npm.io page: https://npm.io/package/@mimik/lib-filters

## Dependencies (2)

- [flatted](https://npm.io/package/flatted.md) 3.4.2
- [jsonpath](https://npm.io/package/jsonpath.md) 1.3.0

## Recent versions

- 2.1.1 (latest) — 2026-07-07
- 2.0.9 — 2026-03-22
- 2.0.8 — 2026-03-11
- 2.0.7 — 2026-02-23
- 2.0.6 — 2026-02-18
- 2.0.5 — 2026-02-15
- 2.0.4 — 2025-07-16
- 2.0.3 — 2025-03-25
- 2.0.2 — 2025-03-14
- 2.0.1 — 2025-02-25
- 1.5.4 — 2024-03-17
- 1.5.3 — 2024-03-07
- 1.5.2 — 2024-02-23
- 1.5.1 — 2024-02-05
- 1.5.0 — 2024-01-12
- … 13 more at https://npm.io/package/@mimik/lib-filters/versions

## README

<a name="module_lib-filters"></a>

## lib-filters
**Example** *(Default import)*  
```js
import libFilters from '@mimik/lib-filters';
```
**Example** *(Named imports)*  
```js
import { lengthyString, isProd, logs, MASK } from '@mimik/lib-filters';
```

* [lib-filters](#module_lib-filters)
    * [~MASK](#module_lib-filters..MASK) : <code>String</code>
    * _sync_
        * [~lengthyString(object, [length])](#module_lib-filters..lengthyString) ⇒ <code>\*</code>
        * [~isProd(env)](#module_lib-filters..isProd) ⇒ <code>Boolean</code>
        * [~logs(origObject, [config])](#module_lib-filters..logs) ⇒ <code>Object</code>

<a name="module_lib-filters..MASK"></a>

### lib-filters~MASK : <code>String</code>
The default masking string used by [logs](#module_lib-filters..logs) to replace sensitive values.

**Kind**: inner constant of [<code>lib-filters</code>](#module_lib-filters)  
**Default**: <code>&#x27;-------&#x27;</code>  
<a name="module_lib-filters..lengthyString"></a>

### lib-filters~lengthyString(object, [length]) ⇒ <code>\*</code>
Replace lengthy strings by `--concat(<string length>)--` in a given value.

**Kind**: inner method of [<code>lib-filters</code>](#module_lib-filters)  
**Returns**: <code>\*</code> - The input value with long strings replaced.  
**Category**: sync  

| Param | Type | Default | Description |
| --- | --- | --- | --- |
| object | <code>\*</code> |  | The value where long strings will be replaced. Strings, numbers, arrays and objects are all supported. |
| [length] | <code>Number</code> | <code>1000</code> | The length at which the replacement happens. If no length or a length of 0 is given the default length is 1000 characters. Optional. |

<a name="module_lib-filters..isProd"></a>

### lib-filters~isProd(env) ⇒ <code>Boolean</code>
Check if the environment is production.

**Kind**: inner method of [<code>lib-filters</code>](#module_lib-filters)  
**Returns**: <code>Boolean</code> - Returns true if env is any falsy value (e.g. undefined, null, '', 0, false), or is 'prod'/'production' (case-insensitive).  
**Category**: sync  

| Param | Type | Description |
| --- | --- | --- |
| env | <code>String</code> | The environment property. |

<a name="module_lib-filters..logs"></a>

### lib-filters~logs(origObject, [config]) ⇒ <code>Object</code>
Mask the variables defined in the config on the object.
Follows the jsonpath pattern for masking: https://www.npmjs.com/package/jsonpath

Security note: `config` is evaluated as JSONPath (including `[?(...)]` filter
expressions) and must always be developer-controlled, trusted input. An
attacker-influenced config string is an expression-evaluation vector.

**Kind**: inner method of [<code>lib-filters</code>](#module_lib-filters)  
**Returns**: <code>Object</code> - The filtered object.  
**Category**: sync  
**Throws**:

- <code>Error</code> 'Input must be a valid JSON object.' when origObject is not an object.
- <code>Error</code> 'Config must be an array of JSONPath strings.' when config is provided but not an array.


| Param | Type | Description |
| --- | --- | --- |
| origObject | <code>Object</code> | The object to apply filtering. |
| [config] | <code>Array.&lt;String&gt;</code> | An array of JSONPath strings defining the fields to mask. When omitted or empty, the object is returned unchanged. |

**Example**  
```js
const filtered = logs(
  { password: 'secret', user: 'john' },
  ['$.password'],
);
// filtered.password === '-------'
// filtered.user === 'john'
```

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