postapl-remove-empty
v1.1.0
Published
PostAPL plugin to remove empty values
Downloads
9
Maintainers
Readme
PostAPL Remove Empty
PostAPL Remove Empty is a PostAPL plugin that looks for property values that are null, empty string, empty object, and empty array and removes them.
Input
{
"type": "APL",
"version": "1.7",
"settings": {},
"theme": "dark",
"import": [],
"resources": [],
"styles": {},
"onMount": [],
"graphics": {},
"commands": {},
"layouts": {},
"mainTemplate": {
"parameters": [
"payload"
],
"items": [
{
"type": "Container",
"width": "100vw",
"height": "100vh",
"data": [],
"items": [
{
"type": "Frame",
"backgroundColor": "white",
"height": "100%",
"width": "100%",
"item": {}
}
]
}
]
}
}
Output
{
"type": "APL",
"version": "1.7",
"theme": "dark",
"mainTemplate": {
"parameters": [
"payload"
],
"items": [
{
"type": "Container",
"width": "100vw",
"height": "100vh",
"items": [
{
"type": "Frame",
"backgroundColor": "white",
"height": "100%",
"width": "100%"
}
]
}
]
}
}
Usage
Step 1: Install plugin:
npm install --save-dev postapl postapl-remove-empty
Step 2: Use:
'use strict'
const { postapl } = require('postapl');
const removeEmpty = require('postapl-remove-empty');
const fs = require('fs');
fs.readFile('src/screen.json', (err, apl) => {
postapl([removeEmpty])
.process(apl, { from: 'src/screen.json', to: 'dest/screen.json' })
.then(result => {
fs.writeFile(result.opts.to, result.apl, () => true)
})
});
Options
None