0.1.1 • Published 3 years ago
cond-spread v0.1.1
cond-spread
Conditionally spread object and array items.
Installation
npm
npm i cond-spread
yarn
yarn add cond-spread
Usage
First import the cond-spread
package:
import condSpread from 'cond-spread';
condSpread
is a curried function that takes a boolean, and an object or array. It returns the object or array is the boolean was true, otherwise it returns an empty object or array.
Example with webpack
...
import condSpread from 'cond-spread';
export default (env, { mode }) => {
const isDev = condSpread(mode === 'development');
const isProd = condSpread(mode === 'production');
return {
plugins: [
...isDev([new BundleAnalyzerPlugin()]),
...isProd([
new CleanWebpackPlugin(),
new CopyPlugin(),
]),
],
...isDev({
devServer: {
hot: true,
},
}),
};
};