This package has been deprecated

Author message:

Package no longer supported.

cond-spread
TypeScript icon, indicating that this package has built-in type declarations

0.1.1 • Public • Published

cond-spread npm downloads

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,
      },
    }),
  };
};

Package Sidebar

Install

npm i cond-spread

Weekly Downloads

0

Version

0.1.1

License

MIT

Unpacked Size

2.99 kB

Total Files

5

Last publish

Collaborators

  • jwr1