{"id":15689764,"url":"https://github.com/jonschlinkert/list-item","last_synced_at":"2025-05-07T21:42:03.971Z","repository":{"id":27646189,"uuid":"31131098","full_name":"jonschlinkert/list-item","owner":"jonschlinkert","description":"Generate a single formatted list item, allowing you to easily generate lists with proper indentation, bullets, numbers or other leading characters.","archived":false,"fork":false,"pushed_at":"2018-07-05T07:23:43.000Z","size":24,"stargazers_count":8,"open_issues_count":1,"forks_count":5,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-03-31T14:21:34.281Z","etag":null,"topics":["bullet","commonmark","items","javascript","li","list","markdown","nodejs","roman","ul"],"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/jonschlinkert.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":"2015-02-21T16:13:10.000Z","updated_at":"2022-09-13T05:39:13.000Z","dependencies_parsed_at":"2022-09-03T12:20:22.413Z","dependency_job_id":null,"html_url":"https://github.com/jonschlinkert/list-item","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonschlinkert%2Flist-item","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonschlinkert%2Flist-item/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonschlinkert%2Flist-item/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonschlinkert%2Flist-item/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jonschlinkert","download_url":"https://codeload.github.com/jonschlinkert/list-item/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252782589,"owners_count":21803404,"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":["bullet","commonmark","items","javascript","li","list","markdown","nodejs","roman","ul"],"created_at":"2024-10-03T18:04:24.072Z","updated_at":"2025-05-07T21:42:03.921Z","avatar_url":"https://github.com/jonschlinkert.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# list-item [![NPM version](https://img.shields.io/npm/v/list-item.svg?style=flat)](https://www.npmjs.com/package/list-item) [![NPM monthly downloads](https://img.shields.io/npm/dm/list-item.svg?style=flat)](https://npmjs.org/package/list-item) [![NPM total downloads](https://img.shields.io/npm/dt/list-item.svg?style=flat)](https://npmjs.org/package/list-item) [![Linux Build Status](https://img.shields.io/travis/jonschlinkert/list-item.svg?style=flat\u0026label=Travis)](https://travis-ci.org/jonschlinkert/list-item)\n\n\u003e Generate a single formatted list item, allowing you to easily generate lists with proper indentation, bullets, numbers or other leading characters.\n\nPlease consider following this project's author, [Jon Schlinkert](https://github.com/jonschlinkert), and consider starring the project to show your :heart: and support.\n\n## Install\n\nInstall with [npm](https://www.npmjs.com/):\n\n```sh\n$ npm install --save list-item\n```\n\n## Usage\n\n```js\nconst listitem = require('list-item');\n```\n\n## Examples\n\n**Basic list**\n\nGenerate a list using default bullets and indentation:\n\n```js\nconst listitem = require('list-item');\nconst li = listitem();\n\nlet list = ['a', 'b', 'c', 'd', 'e'].map((ele, i) =\u003e li(i, ele));\nconsole.log(list.join('\\n'));\n```\n\nResults in:\n\n```\n- a\n  * b\n    + c\n      - d\n        * e\n```\n\n**Roman numerals**\n\nGenerate roman numerals in increments of 10.\n\n```js\nconst listitem = require('list-item');\nconst romanize = require('romanize');\n\n// specify `chars` to pass to fill-range, and use the callback \n// to modify generated numerals\nconst li = listitem({ chars: '1..100..10' }, (indent, ch) =\u003e {\n  return indent + romanize(ch) + '.';\n});\n\n// generate a formatted list!\nlet list = ['a', 'b', 'c', 'd', 'e'].map((ele, i) =\u003e li(i, ele));\nconsole.log(list.join('\\n'));\n```\n\nResults in:\n\n```\nI. a\n  XI. b\n    XXI. c\n      XXXI. d\n        XLI. e\n```\n\n## API\n\n### [listitem](index.js#L39)\n\nReturns a function to generate a plain-text/markdown list-item, allowing options to be cached for subsequent calls.\n\n**Params**\n\n* `options` **{Object}**: pass options to customize list item characters, indentation, etc.\n* `options.nobullet` **{Boolean}**: Pass true if you only want the list iten and identation, but no bullets.\n* `options.indent` **{String}**: The amount of leading indentation to use. default is ``.\n* `options.chars` **{String|Array}**: If a string is passed, [fill-range](https://github.com/jonschlinkert/fill-range) will be used to generate an array of bullets (visit [fill-range](https://github.com/jonschlinkert/fill-range) to see all options.) Or directly pass an array of bullets, numbers, letters or other characters to use for each list item. Default `['-', '*', '+']`\n* `fn` **{Function}**: pass a function [fill-range](https://github.com/jonschlinkert/fill-range) to modify the bullet for an item as it's generated. See the [examples](#examples).\n* `returns` **{String}**: returns a formatted list item\n\n**Example**\n\n```js\nconst li = listitem(options);\n\nli(0, 'Level 0 list item');\n//=\u003e '- Level 0 list item'\n\nli(1, 'Level 1 list item');\n//=\u003e '  * Level 1 list item'\n\nli(2, 'Level 2 list item');\n//=\u003e '    + Level 2 list item'\n```\n\n## Release History\n\n### 2.0.0 - July 5, 2018\n\n**Breaking changes**\n\n* The callback signature has changed to `(indent, char, level)`.\n\n## About\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003cstrong\u003eContributing\u003c/strong\u003e\u003c/summary\u003e\n\nPull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new).\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003cstrong\u003eRunning Tests\u003c/strong\u003e\u003c/summary\u003e\n\nRunning and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command:\n\n```sh\n$ npm install \u0026\u0026 npm test\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003cstrong\u003eBuilding docs\u003c/strong\u003e\u003c/summary\u003e\n\n_(This project's readme.md is generated by [verb](https://github.com/verbose/verb-generate-readme), please don't edit the readme directly. Any changes to the readme must be made in the [.verb.md](.verb.md) readme template.)_\n\nTo generate the readme, run the following command:\n\n```sh\n$ npm install -g verbose/verb#dev verb-generate-readme \u0026\u0026 verb\n```\n\n\u003c/details\u003e\n\n### Related projects\n\nYou might also be interested in these projects:\n\n* [deromanize](https://www.npmjs.com/package/deromanize): Convert roman numerals to arabic numbers (useful for books, outlines, documentation, slide decks, etc) | [homepage](https://github.com/jonschlinkert/deromanize \"Convert roman numerals to arabic numbers (useful for books, outlines, documentation, slide decks, etc)\")\n* [fill-range](https://www.npmjs.com/package/fill-range): Fill in a range of numbers or letters, optionally passing an increment or `step` to… [more](https://github.com/jonschlinkert/fill-range) | [homepage](https://github.com/jonschlinkert/fill-range \"Fill in a range of numbers or letters, optionally passing an increment or `step` to use, or create a regex-compatible range with `options.toRegex`\")\n* [randomatic](https://www.npmjs.com/package/randomatic): Generate randomized strings of a specified length using simple character sequences. The original generate-password. | [homepage](https://github.com/jonschlinkert/randomatic \"Generate randomized strings of a specified length using simple character sequences. The original generate-password.\")\n* [romanize](https://www.npmjs.com/package/romanize): Convert numbers to roman numerals (useful for books, outlines, documentation, slide decks, etc) | [homepage](https://github.com/jonschlinkert/romanize \"Convert numbers to roman numerals (useful for books, outlines, documentation, slide decks, etc)\")\n* [to-regex-range](https://www.npmjs.com/package/to-regex-range): Pass two numbers, get a regex-compatible source string for matching ranges. Validated against more than… [more](https://github.com/micromatch/to-regex-range) | [homepage](https://github.com/micromatch/to-regex-range \"Pass two numbers, get a regex-compatible source string for matching ranges. Validated against more than 2.78 million test assertions.\")\n\n### Contributors\n\n| **Commits** | **Contributor** | \n| --- | --- |\n| 18 | [jonschlinkert](https://github.com/jonschlinkert) |\n| 7 | [adjohnson916](https://github.com/adjohnson916) |\n\n### Author\n\n**Jon Schlinkert**\n\n* [LinkedIn Profile](https://linkedin.com/in/jonschlinkert)\n* [GitHub Profile](https://github.com/jonschlinkert)\n* [Twitter Profile](https://twitter.com/jonschlinkert)\n\n### License\n\nCopyright © 2018, [Jon Schlinkert](https://github.com/jonschlinkert).\nReleased under the [MIT License](LICENSE).\n\n***\n\n_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.6.0, on July 05, 2018._","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjonschlinkert%2Flist-item","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjonschlinkert%2Flist-item","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjonschlinkert%2Flist-item/lists"}