# @exocet/value-flagger

> ES6 Javascript value flagger

Latest version **1.0.0** (published 2019-04-02) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install @exocet/value-flagger
pnpm add @exocet/value-flagger
yarn add @exocet/value-flagger
bun add @exocet/value-flagger
```

## 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.0 |
| Published | 2019-04-02 |
| First published | 2019-04-02 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 19.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Exocet |
| Maintainers | vflopes |
| Keywords | value, flagger, protobuf, encoder, decoder |

## Links

- npm: https://www.npmjs.com/package/@exocet/value-flagger
- Repository: https://github.com/exocet-engineering/exocet-value-flagger
- Homepage: https://github.com/exocet-engineering/exocet-value-flagger#readme
- Issues: https://github.com/exocet-engineering/exocet-value-flagger/issues
- npm.io page: https://npm.io/package/@exocet/value-flagger

## Alternatives

- [flatbuffers](https://npm.io/package/flatbuffers.md) — 6.0M weekly downloads
- [@exodus/patch-broken-hermes-typed-arrays](https://npm.io/package/@exodus/patch-broken-hermes-typed-arrays.md) — 28.5K weekly downloads
- [@native-to-anchor/buffer-layout](https://npm.io/package/@native-to-anchor/buffer-layout.md) — 12.2K weekly downloads
- [binary-parser-encoder](https://npm.io/package/binary-parser-encoder.md) — 5.3K weekly downloads
- [datasets-fi-postalcodes](https://npm.io/package/datasets-fi-postalcodes.md) — 1.1K weekly downloads

## Recent versions

- 1.0.0 (latest) — 2019-04-02

## README

# @exocet/value-flagger

This package was created as an alternative to pass `null` values through protobuf encoded JSON. It search for `null` values and creates a boolean flag indicating that field was `null`. This package **doesn't use** recursion so it's very fast.

----------------------------

### Methods

#### encode(source[, options])

```javascript
const { encode } = require('@exocet/value-flagger');
```

Encode a source object or array flagging the source searching for `replaceValue` and flagging the object key with the `flagKey` as property's prefix.

* **source** - object or array to encode.
* **options.replaceValue** - value to replace with flags, the default value is `null`.
* **options.flagKey** - string with the prefix to be added to encoded object keys, the default value is `'__isNull_'`.

**Return value:** the source object or array with encoding flags.

----------------------------

#### decode(source[, options])

```javascript
const { decode } = require('@exocet/value-flagger');
```

Decode a source object or array removing flags from the source and adding original keys as properties with `replaceValue` as value.

* **source** - object or array to decode.
* **options.replaceValue** - value to replace flags, the default value is `null`.
* **options.flagKey** - string with the prefix to be removed from decoded object keys, the default value is `'__isNull_'`.

**Return value:** the source object without encoding flags and keys set to original values.

----------------------------

#### isObject(value)

```javascript
const { isObject } = require('@exocet/value-flagger');
```

Checks if a value is an object.

**Return value:** boolean.

----------------------------

Tests are done with mocha, chai and nyc for coverage. The lint preset is based on airbnb preset.

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