{"id":22130937,"url":"https://github.com/kahwee/truncate-middle","last_synced_at":"2025-07-25T18:32:51.239Z","repository":{"id":28479081,"uuid":"31995137","full_name":"kahwee/truncate-middle","owner":"kahwee","description":"Truncates your str...iddle","archived":false,"fork":false,"pushed_at":"2022-12-06T17:19:32.000Z","size":690,"stargazers_count":9,"open_issues_count":17,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-11-10T02:50:14.460Z","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":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kahwee.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-03-11T02:59:37.000Z","updated_at":"2024-06-06T12:28:46.000Z","dependencies_parsed_at":"2023-01-14T08:53:50.916Z","dependency_job_id":null,"html_url":"https://github.com/kahwee/truncate-middle","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kahwee%2Ftruncate-middle","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kahwee%2Ftruncate-middle/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kahwee%2Ftruncate-middle/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kahwee%2Ftruncate-middle/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kahwee","download_url":"https://codeload.github.com/kahwee/truncate-middle/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":227609860,"owners_count":17793283,"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":[],"created_at":"2024-12-01T18:27:46.478Z","updated_at":"2024-12-01T18:27:47.067Z","avatar_url":"https://github.com/kahwee.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"## truncate-middle\n\nThere are cases where important information is at the end of the string and truncating the end isn't helpful.\n\n[![Build Status](https://travis-ci.org/kahwee/truncate-middle.svg?branch=master)](https://travis-ci.org/kahwee/truncate-middle) \n[![Coverage Status](https://coveralls.io/repos/kahwee/truncate-middle/badge.svg?branch=master)](https://coveralls.io/r/kahwee/truncate-middle?branch=master) \n[![npm version](https://badge.fury.io/js/truncate-middle.svg)](http://badge.fury.io/js/truncate-middle) \n[![Greenkeeper badge](https://badges.greenkeeper.io/kahwee/truncate-middle.svg)](https://greenkeeper.io/)\n\n## Example use cases\n\n```js\nvar book1 = \"America Again: Re-becoming the Greatness We Never Weren't by Stephen Colbert (978-0446583978)\";\nvar truncateMiddle = require('truncate-middle');\nvar display = truncateMiddle(book1, 30, 16, '...');\n// You get 'America Again: Re-becoming the...(978-0446583978)'\n```\n\n## Usage\nInstall from `npm`.\n\n```sh\nnpm install --save truncate-middle\n```\n\nRequiring in JavaScript\n\n```js\nvar truncateMiddle = require('truncate-middle');\ntruncateMiddle('the quick brown', 5, 3, '...');\n// Result:\n//  'the q...own'\n```\n\nDefaults:\n\n\n```js\ntruncateMiddle('the quick brown');\n// Result:\n//  'the quick brown'\n```\n\nSpecifying a front length of 5:\n\n```js\ntruncateMiddle('the quick brown', 5);\n// Result:\n//  'the q\u0026hellip;'\n```\n\nSpecifying a front length of 5 and back length of 3:\n\n```js\ntruncateMiddle('the quick brown', 5, 3);\n// Result:\n//  'the q\u0026hellip;own'\n```\n\nWhen there isn't anything to truncate:\n\n```js\ntruncateMiddle('the quick brown', 50, 50);\n// Result:\n//  'the quick brown'\n```\n\n### Function signature\n\n```js\ntruncateMiddle(str, frontLen, backLen, truncateStr)\n```\n\n1. **str (string)**: String to be truncated\n1. **frontLen (number):** Number of characters to be remained in front.\n1. **backLen (number):** Number of characters to be remained at the back.\n1. **truncateStr (string):** String that is replaced the truncated portion. Defaults to `\u0026hellip;`\n\nReturn is always the truncated string.\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkahwee%2Ftruncate-middle","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkahwee%2Ftruncate-middle","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkahwee%2Ftruncate-middle/lists"}