1.2.0 • Published 3 years ago

merge-string-conditionally v1.2.0

Weekly downloads
16
License
MIT
Repository
github
Last release
3 years ago

merge-string-conditionally

npm downloads

Simple package for merging multiple strings where some of the strings are conditionally applied. It can be used to merge multiple class names. A fixed string can be used as well as conditional strings through object(s)

It can be used in the React projects (to merge class names) as well as in Node.js projects.

No dependencies.

Install

$ npm install merge-string-conditionally

OR

$ yarn add merge-string-conditionally

Usage

import mergeString from 'merge-string-conditionally';

OR

const mergeString = require('merge-string-conditionally');

Examples

mergeString('fixed-class', { 'any-className': true }); // as long as the object values are true they will be merged

--- output ---
'fixed-class any-className`
mergeString(
  'fixed-class',
  { 'any-className': true },
  { 'any-className-2': true }
); // multiple objects can be passed

--- output ---
'fixed-class any-className any-className-2`
mergeString('fixed-class', { 'any-className': true, 'any-className-2': true }); // single objects with multiple properties can also be passed

--- output ---
'fixed-class any-className any-className-2`
mergeString('fixed-class', { 'false-className': false, 'any-className': true }); // single objects with multiple properties can also be passed

--- output ---
'fixed-class any-className`
1.2.0

3 years ago

1.1.0

3 years ago

1.0.9

3 years ago

1.0.8

3 years ago

1.0.7

3 years ago

1.0.6

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago