{"id":17472671,"url":"https://github.com/shinnn/truncated-list","last_synced_at":"2025-03-28T08:10:24.146Z","repository":{"id":57380312,"uuid":"98642289","full_name":"shinnn/truncated-list","owner":"shinnn","description":"Create a list of items with truncating lines to the specified maximum number","archived":false,"fork":false,"pushed_at":"2019-06-14T06:57:42.000Z","size":96,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-18T15:09:13.542Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://npm.runkit.com/truncated-list","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"isc","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/shinnn.png","metadata":{"files":{"readme":"README.md","changelog":null,"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-07-28T11:14:47.000Z","updated_at":"2024-07-01T19:26:01.000Z","dependencies_parsed_at":"2022-08-28T21:22:28.925Z","dependency_job_id":null,"html_url":"https://github.com/shinnn/truncated-list","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shinnn%2Ftruncated-list","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shinnn%2Ftruncated-list/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shinnn%2Ftruncated-list/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shinnn%2Ftruncated-list/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/shinnn","download_url":"https://codeload.github.com/shinnn/truncated-list/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245991582,"owners_count":20706129,"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-10-18T17:32:03.272Z","updated_at":"2025-03-28T08:10:24.112Z","avatar_url":"https://github.com/shinnn.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# truncated-list\n\n[![npm version](https://img.shields.io/npm/v/truncated-list.svg)](https://www.npmjs.com/package/truncated-list)\n[![Github Actions](https://action-badges.now.sh/shinnn/truncated-list)](https://wdp9fww0r9.execute-api.us-west-2.amazonaws.com/production/results/shinnn/truncated-list)\n[![codecov](https://codecov.io/gh/shinnn/truncated-list/branch/master/graph/badge.svg)](https://codecov.io/gh/shinnn/truncated-list)\n\nCreate a list of items with truncating lines to the specified maximum number\n\n```javascript\nconst truncatedList = require('truncated-list');\n\nconsole.log(truncatedList([\n  'Apple',\n  'Orange',\n  'Strawberry',\n  'Grape',\n  'Lemon',\n  'Kiwi'\n], 4));\n```\n\n```\n* Apple\n* Orange\n* Strawberry\n* Grape\n  ... and 2 more\n```\n\n## Installation\n\n[Use](https://docs.npmjs.com/cli/install) [npm](https://docs.npmjs.com/about-npm/).\n\n```\nnpm install truncated-list\n```\n\n## API\n\n```javascript\nconst truncatedList = require('truncated-list');\n```\n\n### truncatedList(*items*, *max*)\n\n*items*: `Iterable\u003cstring\u003e` (list items)  \n*max*: `integer` (maximum number of items)  \nReturn: `string`\n\nIt joins items into a list each of lines begins with `* `.\n\nIf the number of items exceeds `max`, it truncates the surplus and append `... and X more` to the result.\n\n```javascript\ntruncatedList(new Set(['a', 'b']), 2);\n//=\u003e '* a\\n* b'\n\ntruncatedList(new Set(['a', 'b']), 1);\n//=\u003e '* a\\n  ... and 1 more'\n```\n\n## License\n\n[ISC License](./LICENSE) © 2018 - 2019 Watanabe Shinnosuke\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshinnn%2Ftruncated-list","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fshinnn%2Ftruncated-list","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshinnn%2Ftruncated-list/lists"}