Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/wmfs/cardscript-expressions


https://github.com/wmfs/cardscript-expressions

cardscript tymly

Last synced: 3 months ago
JSON representation

Awesome Lists containing this project

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

## Install
```bash
$ npm install cardscript-expressions --save
```

## 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 |

## License
[MIT](https://github.com/wmfs/cardscript/blob/master/LICENSE)