{"id":37705140,"url":"https://github.com/zhengrenzhe/shear.js","last_synced_at":"2026-01-16T13:07:39.142Z","repository":{"id":57358181,"uuid":"114901687","full_name":"zhengrenzhe/shear.js","owner":"zhengrenzhe","description":"✂️truncate text across DOM nodes","archived":false,"fork":false,"pushed_at":"2023-08-03T06:36:26.000Z","size":510,"stargazers_count":61,"open_issues_count":5,"forks_count":5,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-08-09T15:56:38.965Z","etag":null,"topics":["ellipsis","javascript","multi-line","truncate","typescript"],"latest_commit_sha":null,"homepage":"https://codepen.io/droiz/full/YYWBBw","language":"TypeScript","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/zhengrenzhe.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-12-20T15:18:22.000Z","updated_at":"2024-07-04T08:37:54.000Z","dependencies_parsed_at":"2022-09-06T22:21:31.346Z","dependency_job_id":null,"html_url":"https://github.com/zhengrenzhe/shear.js","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/zhengrenzhe/shear.js","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zhengrenzhe%2Fshear.js","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zhengrenzhe%2Fshear.js/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zhengrenzhe%2Fshear.js/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zhengrenzhe%2Fshear.js/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zhengrenzhe","download_url":"https://codeload.github.com/zhengrenzhe/shear.js/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zhengrenzhe%2Fshear.js/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28478922,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-16T11:59:17.896Z","status":"ssl_error","status_checked_at":"2026-01-16T11:55:55.838Z","response_time":107,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["ellipsis","javascript","multi-line","truncate","typescript"],"created_at":"2026-01-16T13:07:37.671Z","updated_at":"2026-01-16T13:07:39.138Z","avatar_url":"https://github.com/zhengrenzhe.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003ch1\u003eshear.js\u003c/h1\u003e\n\n\u003cp\u003e\n\u003ca href=\"https://www.npmjs.com/package/shear.js\"\u003e\n\u003cimg src=\"https://badge.fury.io/js/shear.js.svg\" alt=\"npm\" /\u003e\n\u003c/a\u003e\n\u003c/p\u003e\n\n**shear.js** is a zero dependency javascript plugin, It uses [Selection API](https://developer.mozilla.org/zh-CN/docs/Web/API/Selection) to truncate multiple lines of text based on the actual visual content, and return the original and truncated content.\n\n## Features\n\n-   **the target element need not be set as a block level element**\n-   **truncate across dom nodes within the target element, keep the original dom node within the target element**\n-   **insert the html string at the end of the truncation**\n-   zero dependency\n-   very lightweight (1.9kb)\n\n## Browser Support\n\n| [\u003cimg src=\"https://raw.githubusercontent.com/alrra/browser-logos/master/src/edge/edge_48x48.png\" alt=\"IE / Edge\" width=\"24px\" height=\"24px\" /\u003e](http://godban.github.io/browsers-support-badges/)\u003c/br\u003eIE / Edge | [\u003cimg src=\"https://raw.githubusercontent.com/alrra/browser-logos/master/src/firefox/firefox_48x48.png\" alt=\"Firefox\" width=\"24px\" height=\"24px\" /\u003e](http://godban.github.io/browsers-support-badges/)\u003c/br\u003eFirefox | [\u003cimg src=\"https://raw.githubusercontent.com/alrra/browser-logos/master/src/chrome/chrome_48x48.png\" alt=\"Chrome\" width=\"24px\" height=\"24px\" /\u003e](http://godban.github.io/browsers-support-badges/)\u003c/br\u003eChrome | [\u003cimg src=\"https://raw.githubusercontent.com/alrra/browser-logos/master/src/opera/opera_48x48.png\" alt=\"Opera\" width=\"24px\" height=\"24px\" /\u003e](http://godban.github.io/browsers-support-badges/)\u003c/br\u003eOpera | [\u003cimg src=\"https://raw.githubusercontent.com/alrra/browser-logos/master/src/safari/safari_48x48.png\" alt=\"Safari\" width=\"24px\" height=\"24px\" /\u003e](http://godban.github.io/browsers-support-badges/)\u003c/br\u003eSafari |\n| :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: | :-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: | :-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: |\n|                                                                                                 IE9+ / Edge15+                                                                                                  |                                                                                                        16+                                                                                                        |                                                                                                      16+                                                                                                      |                                                                                                    15+                                                                                                    |                                                                                                      6+                                                                                                       |\n\n## Install\n\n```\nyarn add shear.js\n```\n\nor\n\n```\n\u003cscript src=\"https://rawgit.com/zhengrenzhe/shear.js/master/dist/shear.js\"\u003e\u003c/script\u003e\n```\n\n## Usage\n\n```\nimport shear from \"shear.js\";\n```\n\ndisplay three lines\n\n```\nshear(document.getElementById('target'), 3);\n```\n\ndisplay three lines, add html string at the end of the DOM\n\n```\nshear(document.getElementById('target'),  3, '\u003cspan\u003e...(More)\u003c/span\u003e');\n```\n\n## Example\n\n[Codepen](https://codepen.io/droiz/full/YYWBBw)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzhengrenzhe%2Fshear.js","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzhengrenzhe%2Fshear.js","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzhengrenzhe%2Fshear.js/lists"}