{"id":15978438,"url":"https://github.com/perry-mitchell/join-and-shorten","last_synced_at":"2025-06-22T22:02:28.480Z","repository":{"id":57157418,"uuid":"107267250","full_name":"perry-mitchell/join-and-shorten","owner":"perry-mitchell","description":"Join and shorten strings with priorities","archived":false,"fork":false,"pushed_at":"2018-01-08T15:40:03.000Z","size":42,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-05-27T07:17:56.033Z","etag":null,"topics":["concat","concatenation","join","shorten-strings","shortener"],"latest_commit_sha":null,"homepage":null,"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/perry-mitchell.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-10-17T12:44:14.000Z","updated_at":"2017-10-23T05:18:57.000Z","dependencies_parsed_at":"2022-09-03T20:32:55.874Z","dependency_job_id":null,"html_url":"https://github.com/perry-mitchell/join-and-shorten","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/perry-mitchell/join-and-shorten","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/perry-mitchell%2Fjoin-and-shorten","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/perry-mitchell%2Fjoin-and-shorten/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/perry-mitchell%2Fjoin-and-shorten/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/perry-mitchell%2Fjoin-and-shorten/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/perry-mitchell","download_url":"https://codeload.github.com/perry-mitchell/join-and-shorten/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/perry-mitchell%2Fjoin-and-shorten/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261374387,"owners_count":23148974,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["concat","concatenation","join","shorten-strings","shortener"],"created_at":"2024-10-07T23:20:29.396Z","updated_at":"2025-06-22T22:02:23.466Z","avatar_url":"https://github.com/perry-mitchell.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# join-and-shorten\nJoin and shorten strings with priorities\n\n[![npm version](https://badge.fury.io/js/join-and-shorten.svg)](https://www.npmjs.com/package/join-and-shorten) [![Build Status](https://travis-ci.org/perry-mitchell/join-and-shorten.svg?branch=master)](https://travis-ci.org/perry-mitchell/join-and-shorten)\n\n## About\n\nThis package was designed to shorten concatenated strings for use as IDs. It allows the specification of priorities for determining which items to remove from the string when shortening to fit a desired maximum length.\n\n## Installation\n\nSimply install it as a dependency using npm:\n\n```shell\nnpm install join-and-shorten --save\n```\n\n## Usage\n\nUsage is quite simple - to simply join items, you could use the following:\n\n```javascript\nconst join = require(\"join-and-shorten\");\n\njoin([\"one\", \"two\", \"three\"]); // \"one_two_three\"\n```\n\n_Notice that underscores are the default joiner of strings._\n\nYou can also customise the joining character and maximum length:\n\n```javascript\njoin([\"one\", \"two\", \"three\"], \"~\", 9); // \"one~two\"\n```\n\nOr you can give priorities to the function so that it knows which items to strip:\n\n```javascript\njoin([\n    [\"one\", 2],\n    [\"two\", 1],\n    [\"three\", 3]\n], \"_\", 11); // \"one_three\"\n```\n\n`join` also supports a strip-mode parameter, to allow for shortening by **character** instead of by **item**:\n\n```javascript\njoin([\n    [\"abcdef\", 2],\n    [\"123456\", 3]\n], \":\", 10, STRIP_MODE_REMOVE_CHARACTER); // \"abc:123456\"\n```\n\n## Tests\n\nRun the tests by executing `npm test`.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fperry-mitchell%2Fjoin-and-shorten","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fperry-mitchell%2Fjoin-and-shorten","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fperry-mitchell%2Fjoin-and-shorten/lists"}