mirror of
https://github.com/velocitatem/garlic.git
synced 2026-05-31 08:43:36 +00:00
package
This commit is contained in:
31
src/garlic.js
Normal file
31
src/garlic.js
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
function garlic(body) {
|
||||||
|
let bodyCopy = {...body};
|
||||||
|
if (body.props) {
|
||||||
|
if (body.props.children) {
|
||||||
|
// check if children is an array
|
||||||
|
if (Array.isArray(body.props.children)) {
|
||||||
|
let newList = []
|
||||||
|
for (let i = 0; i < body.props.children.length; i++) {
|
||||||
|
// if child is a string, convert it to base64
|
||||||
|
if (typeof body.props.children[i] === 'string') {
|
||||||
|
newList.push(btoa(body.props.children[i]));
|
||||||
|
} else {
|
||||||
|
// if child is not a string, apply this function to it
|
||||||
|
newList.push(garlic(body.props.children[i]));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
bodyCopy = {...bodyCopy, props: {...bodyCopy.props, children: newList}};
|
||||||
|
} else {
|
||||||
|
// if child is a string, convert it to base64
|
||||||
|
if (typeof body.props.children === 'string') {
|
||||||
|
bodyCopy = {...body, props: {...body.props, children: btoa(body.props.children)}};
|
||||||
|
} else {
|
||||||
|
bodyCopy = {...body, props: {...body.props, children: garlic(body.props.children)}};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return bodyCopy;
|
||||||
|
}
|
||||||
|
|
||||||
|
export default garlic;
|
||||||
13
src/package.json
Normal file
13
src/package.json
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
{
|
||||||
|
"name": "garlic",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"description": "",
|
||||||
|
"main": "garlic.js",
|
||||||
|
"type": "module",
|
||||||
|
"scripts": {
|
||||||
|
"test": "echo \"Error: no test specified\" && exit 1"
|
||||||
|
},
|
||||||
|
"keywords": ["garlic", "protection"],
|
||||||
|
"author": "",
|
||||||
|
"license": "ISC"
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user