commit a80bd097dd28e5bc58046cc9038e4a4be838cbf9 Author: Philipp Dieter Date: Sun Jun 23 19:46:46 2024 +0200 Init diff --git a/index.js b/index.js new file mode 100644 index 0000000..df3e6a7 --- /dev/null +++ b/index.js @@ -0,0 +1,29 @@ +module.exports = { + ifProduction: function(env, option1, option2) { + if (env.production) { + return option1; + } + return option2; + }, + ifNotProduction: function(env, option1, option2) { + if (env.production) { + return option2; + } + return option1; + }, + removeEmpty: function(input) { + let output + if (Array.isArray(input)) { + output = input.filter(item => typeof item !== 'undefined') + } else { + output = {} + Object.keys(input).forEach(key => { + const value = input[key] + if (typeof value !== 'undefined') { + output[key] = value + } + }) + } + return output + } +} diff --git a/package.json b/package.json new file mode 100644 index 0000000..81b6774 --- /dev/null +++ b/package.json @@ -0,0 +1,11 @@ +{ + "name": "webpack-config-helpers", + "version": "0.0.1", + "description": "", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "author": "", + "license": "AGPL-3.0-or-later" +}