{"id":16978677,"url":"https://github.com/srph/js-str-concat","last_synced_at":"2026-04-18T02:31:26.392Z","repository":{"id":27970094,"uuid":"31463275","full_name":"srph/js-str-concat","owner":"srph","description":"[DEPRECATED] Conditionally concatenate strings","archived":false,"fork":false,"pushed_at":"2015-03-23T11:31:43.000Z","size":320,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2026-03-12T03:27:16.647Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/srph.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"docs/contributing.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-02-28T13:24:20.000Z","updated_at":"2019-08-18T16:39:54.000Z","dependencies_parsed_at":"2022-09-05T20:50:41.248Z","dependency_job_id":null,"html_url":"https://github.com/srph/js-str-concat","commit_stats":null,"previous_names":["srph/str-concat.js"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/srph/js-str-concat","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/srph%2Fjs-str-concat","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/srph%2Fjs-str-concat/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/srph%2Fjs-str-concat/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/srph%2Fjs-str-concat/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/srph","download_url":"https://codeload.github.com/srph/js-str-concat/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/srph%2Fjs-str-concat/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31953760,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-18T00:39:45.007Z","status":"online","status_checked_at":"2026-04-18T02:00:07.018Z","response_time":103,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-14T01:43:59.508Z","updated_at":"2026-04-18T02:31:26.372Z","avatar_url":"https://github.com/srph.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"![cover](https://cloud.githubusercontent.com/assets/5093058/6545434/14d17d92-c5c2-11e4-97fe-4517b365c3d5.png)\n\n# js-str-concat [![Build Status](https://travis-ci.org/srph/js-str-concat.svg?branch=master)](https://travis-ci.org/srph/js-str-concat?branch=master) [![npm version](http://img.shields.io/npm/v/srph-str-concat.svg?style=flat)](https://npmjs.org/package/srph-str-concat) [![MIT license](http://img.shields.io/badge/license-MIT-brightgreen.svg)](http://opensource.org/licenses/MIT)\n\nConditionally concatenate strings.\n\n## Why?\n\nBecause concatenating strings this way is hard to read and tedious to write:\n\n```js\nvar classNames = '';\n\nif ( /* insert true statement */ ){\n  classNames += 'className1 ';\n}\n\nif ( /* insert false statement */ ){\n  classNames += 'className2 ';\n}\n\nif ( /* insert true statement */ ){\n  classNames += 'className3 ';\n}\n\nconsole.log(classNames) // classNames =\u003e className1 className3\n```\n\nCompared to how simple and clean this is:\n\n```js\nconcat({\n  'className1': true,\n  'className2': false,\n  'className3': true\n}); // =\u003e true\n```\n\nThis is helpful for adding `class`es to an `element` conditionally (like in adding classes in *vanilla* or in *ReactJS*, for example).\n\n- [Getting Started](https://github.com/srph/js-str-concat/blob/master/docs/getting-started.md)\n  - [Installation](https://github.com/srph/js-str-concat/blob/master/docs/getting-started.md#installation)\n  - [Usage](https://github.com/srph/js-str-concat/blob/master/docs/getting-started.md#usage)\n  - [Non-node usage](https://github.com/srph/js-str-concat/blob/master/docs/getting-started.md#non-node-usage)\n    - [Browser usage](https://github.com/srph/js-str-concat/blob/master/docs/getting-started.md#browser-usage)\n- [Contribution](https://github.com/srph/js-str-concat/blob/master/docs/faq.md)\n  - [Building](https://github.com/srph/js-str-concat/blob/master/docs/contributing.md#building)\n- [Changelog](https://github.com/srph/js-str-concat/blob/master/docs/changelog.md)\n\n## Important Note\n\nThis is an experimental pet project; and technically a dead project. Although It Just Works™, it is not recommended for production. If you'd like to continue this project, feel free to (friendly) fork, or contact me for project continuation or collaboration.\n\nThis was written for practice, and, also, because I found [`JedWatson/classnames`](https://github.com/JedWatson/classnames)'s project name to be unlikable for its specific project name, and that it did not provide inline code documentation.\n\n### Alternatives\n\n[**classnames** (`JedWatson/classnames`)](https://github.com/JedWatson/classnames)\n\n## Acknowledgement\n\n**js-str-concat** © 2015+, Kier Borromeo (srph). **js-str-concat** is released under the [MIT](mit-license.org) license.\n\n\u003e [srph.github.io](http://srph.github.io) \u0026nbsp;\u0026middot;\u0026nbsp;\n\u003e GitHub [@srph](https://github.com/srph) \u0026nbsp;\u0026middot;\u0026nbsp;\n\u003e Twitter [@_srph](https://twitter.com/_srph)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsrph%2Fjs-str-concat","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsrph%2Fjs-str-concat","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsrph%2Fjs-str-concat/lists"}