add flattenArray array util, some typedefs, and some code clean up

pull/67/head
dperolio 3 years ago
parent 4487548f45
commit 3a1361099a
No known key found for this signature in database
GPG Key ID: 3E9BBAA710D3DDCE

@ -256,6 +256,9 @@
"value": "value",
"ReactElement": "ReactElement",
"Git": "Git",
"Addon": "Addon",
"AddonType": "AddonType",
"AddonManifest": "AddonManifest",
"VizalityModules": "VizalityModules",
"WebpackModule": "WebpackModule",
"snowflake": "snowflake",

@ -37,9 +37,13 @@
* @property {AddonManager} manager
* @property {APIManager} apiManager
* @property {Git} git
* @property {boolean} _initialized
* @global
*/
//--------------
// Addons
//--------------
/**
* @typedef Addon
* @property {string} dir
@ -47,19 +51,15 @@
* @property {object} sections
* @property {object} styles
* @property {string} type
* @property {object} _events
* @property {number} _eventsCount
* @property {string[]} _labels
* @property {undefined} _maxListeners
* @property {boolean} _ready
* @property {string} _updateIdentifier
* @property {*} _watcher
* @property {boolean} _watcherEnabled
* @property {string} addonId
* @property {AddonManifest} manifest
* @property {object} _cwd
* @property {string} _cwd.cwd
*/
/**
* @typedef AddonType
* @property {('plugin'|'theme')} type
*/
/**
* @typedef AddonManifest
* @property {string} appMode
@ -70,6 +70,7 @@
* @property {string} name
* @property {string} version
*/
/**
* @typedef AddonManifestAuthor
* @property {string} id

@ -35,6 +35,17 @@ export const isArray = input => {
}
};
/**
* Flattens an array.
* @param {Array} array Array input
* @returns {string|null}
*/
export const flattenArray = array => {
return array.reduce((flat, toFlatten) => (
flat.concat(this.isArray(toFlatten) ? flattenArray(toFlatten) : toFlatten)
), []);
};
/**
* Asserts that the input is an array.
* If it isn't an array, it throws an error, otherwise it does nothing.

@ -63,7 +63,8 @@ const WHITELISTED_MODULES = [
'react',
'react-dom',
'react-router',
'react-spring'
'react-spring',
'framer-motion'
];
/**

Loading…
Cancel
Save