https://github.com/wmfs/cardscript-expressions
https://github.com/wmfs/cardscript-expressions
cardscript tymly
Last synced: about 1 month ago
JSON representation
- Host: GitHub
- URL: https://github.com/wmfs/cardscript-expressions
- Owner: wmfs
- License: mit
- Created: 2019-01-18T08:28:14.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2025-02-16T01:09:01.000Z (3 months ago)
- Last Synced: 2025-04-14T03:54:48.148Z (about 1 month ago)
- Topics: cardscript, tymly
- Language: JavaScript
- Size: 189 KB
- Stars: 0
- Watchers: 6
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# cardscript-expressions
[](https://tymly.io/)
[](https://circleci.com/gh/wmfs/cardscript-expressions)
[](https://www.npmjs.com/package/@wmfs/cardscript-expressions)
[](https://codecov.io/gh/wmfs/cardscript-expressions)
[](https://www.codefactor.io/repository/github/wmfs/cardscript-expressions)
[](https://dependabot.com/)
[](http://commitizen.github.io/cz-cli/)
[](https://standardjs.com)
[](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)