# @wmfs/cardscript-cleaner

> Cleans Cardscript form data to ensure we only submit the data that we should.

Latest version **1.6.1** (published 2026-08-14) · MIT license · 0 weekly downloads

## Install

```sh
npm install @wmfs/cardscript-cleaner
pnpm add @wmfs/cardscript-cleaner
yarn add @wmfs/cardscript-cleaner
bun add @wmfs/cardscript-cleaner
```

## Health

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

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

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

## Facts

| | |
|---|---|
| Version | 1.6.1 |
| Published | 2026-08-14 |
| First published | 2019-01-25 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 39.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | West Midlands Fire Service |
| Maintainers | wmfsbot |
| Keywords | tymly, cardscript |

## Links

- npm: https://www.npmjs.com/package/@wmfs/cardscript-cleaner
- Repository: https://github.com/wmfs/cardscript-expressions
- Homepage: https://github.com/wmfs/cardscript-expressions#readme
- Issues: https://github.com/wmfs/cardscript-expressions/issues
- npm.io page: https://npm.io/package/@wmfs/cardscript-cleaner

## Dependencies (2)

- [esprima](https://npm.io/package/esprima.md) 4.0.1
- [static-eval](https://npm.io/package/static-eval.md) 2.1.1

## Alternatives

- [monaco-yaml](https://npm.io/package/monaco-yaml.md) — 420.1K weekly downloads
- [@crewx/workflow](https://npm.io/package/@crewx/workflow.md) — 3.1K weekly downloads
- [yaml-cat](https://npm.io/package/yaml-cat.md) — 38 weekly downloads
- [nunjucks-in-yaml](https://npm.io/package/nunjucks-in-yaml.md) — 9 weekly downloads
- [shopify-symlinks](https://npm.io/package/shopify-symlinks.md) — 3 weekly downloads

## Recent versions

- 1.6.1 (latest) — 2026-08-14
- 1.6.0 — 2025-10-21
- 1.5.0 — 2024-07-02
- 1.4.0 — 2020-07-16
- 1.3.0 — 2020-03-18
- 1.2.0 — 2020-01-07
- 1.1.0 — 2019-06-27
- 1.0.0 — 2019-01-25

## README

# cardscript-expressions

[![Tymly Cardscript](https://img.shields.io/badge/tymly-cardscript-blue.svg)](https://tymly.io/)
[![CircleCI](https://circleci.com/gh/wmfs/cardscript-expressions.svg?style=svg)](https://circleci.com/gh/wmfs/cardscript-expressions)
[![npm (scoped)](https://img.shields.io/npm/v/@wmfs/cardscript-expressions.svg)](https://www.npmjs.com/package/@wmfs/cardscript-expressions) 
[![codecov](https://codecov.io/gh/wmfs/cardscript-expressions/branch/master/graph/badge.svg)](https://codecov.io/gh/wmfs/cardscript-expressions) 
[![CodeFactor](https://www.codefactor.io/repository/github/wmfs/cardscript-expressions/badge)](https://www.codefactor.io/repository/github/wmfs/cardscript-expressions) 
[![Dependabot badge](https://img.shields.io/badge/Dependabot-active-brightgreen.svg)](https://dependabot.com/) 
[![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/) 
[![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com) 
[![license](https://img.shields.io/github/license/mashape/apistatus.svg)](https://github.com/wmfs/tymly/blob/master/packages/concrete-paths/LICENSE)

> cardscript-expressions provides a number of utilities to generate expressions, generate AST's, and clean cardscript data for submissions

## <a name="install"></a>Install
```bash
$ npm install cardscript-expressions --save
```

## <a name="usage"></a>Usage
```bash
const expressions = new CardscriptExpressionsxpressions()
```

##### Method summary

| Usage      | Description |
| -----------      | ----------- |
| `const expressionList = getExpressionsFromCardscript(cardscript)` | Takes a cardscript schema and extracts a list of expressions. |
| `convertExpressionsToAst(expressions)`| Takes a list of expressions generated by `getExpressionsFromCardscript()` and amends the generated AST's to an object `asts` available from `expressions.asts` |
| `addCardscript(cardscript)` | A combination of `getExpressionsFromCardscript(cardscript)` and `convertExpressionsToAst(expressions)`, used to generate AST's from cardscript in one function call |
| `const visibilityList = calculateWidgetVisibility(cardscript, data, asts)` | Takes a cardscript schema, submission data, and a list of AST's to generate an object of `{key: boolean}` values representing whether a widget should be visible or not |
| `const clean = cleanData(data, visibilityList)`| Takes submission data and a visibility list generated by `calculateWidgetVisibility` and returns a cleaned data object with values of hidden fields removed |


## <a name="license"></a>License
[MIT](https://github.com/wmfs/cardscript/blob/master/LICENSE)

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