项目作者: serslon

项目描述 :
Join to a string with one space between strings
高级语言: JavaScript
项目地址: git://github.com/serslon/concatString.git
创建时间: 2018-12-14T10:55:23Z
项目社区:https://github.com/serslon/concatString

开源协议:MIT License

下载


Motivation

Many times I need to joining strings in different projects.

For example, make a full name for users/customers with a prefix or without it. But not all fields customer filled. Then you joined string with space, many times we have an incorrect string with space inside, before, and after a sentence. It is not a big problem because simple function decided this problem. But it happened many times, and I decided to make this library for more comfortable implement this functionality to any projects.

Install

For install function into your project, you need run command:

  1. npm install --save @serslon/concat-string

or

  1. yarn add @serslon/concat-string

Usage

You can use many ways for execute this function:

  • as parameters concatString(par1, par2, par3,...)
  • as arrays concatString([par1, par2, par3])
  • as mixes parameters concatString([par1, par2, par3], par4).

node.js

  1. const concatString = require('@serslon/concat-string');
  2. ...
  3. const fullName = concatString(userProfile.prefix, userProfile.firstName, userProfile.lastName);
  4. ...

babel

  1. import concatString from '@serslon/concat-string';
  2. ...
  3. const fullName = concatString(userProfile.prefix, userProfile.firstName, userProfile.lastName);
  4. ...

License

MIT