{"id":20655572,"url":"https://github.com/lizhengnacl/vision-string","last_synced_at":"2026-05-27T18:32:50.240Z","repository":{"id":79013189,"uuid":"100603345","full_name":"lizhengnacl/vision-string","owner":"lizhengnacl","description":"字符串视觉上的长度计算","archived":false,"fork":false,"pushed_at":"2017-08-17T13:01:32.000Z","size":29,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-12-09T02:41:48.290Z","etag":null,"topics":["emoji","javascript","length","string","vision"],"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/lizhengnacl.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-08-17T12:53:50.000Z","updated_at":"2018-03-28T03:29:44.000Z","dependencies_parsed_at":"2023-03-23T09:18:30.889Z","dependency_job_id":null,"html_url":"https://github.com/lizhengnacl/vision-string","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/lizhengnacl/vision-string","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lizhengnacl%2Fvision-string","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lizhengnacl%2Fvision-string/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lizhengnacl%2Fvision-string/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lizhengnacl%2Fvision-string/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lizhengnacl","download_url":"https://codeload.github.com/lizhengnacl/vision-string/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lizhengnacl%2Fvision-string/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33579665,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-05-27T02:00:06.184Z","response_time":53,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["emoji","javascript","length","string","vision"],"created_at":"2024-11-16T18:11:52.728Z","updated_at":"2026-05-27T18:32:50.213Z","avatar_url":"https://github.com/lizhengnacl.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"一种多行文本文末省略号的JS解决方案\n\n字符串视觉感官上的长度计算方案\n\n核心思想：\n1. 将单个数字、字幕、符号算作一个长度\n2. 将中文、表情符等算作两个长度\n3. 将emoji表情符算作两个长度\n\n使用\n```\nnpm install vision-string\n```\n\n测试\n```\nnpm t\n```\n\n\n```\ntest(t =\u003e {\n    let { length, getLength, isDouble} = b;\n\n    t.is(getLength('asdfghjkl'), 9);\n    t.is(getLength('@#$%^\u0026*()'), 9);\n    t.is(getLength('123456789'), 9);\n    t.is(getLength('.........'), 9);\n    t.is(getLength('中中中中中'), 10);\n    t.is(getLength('😄😄😄😄😄'), 10);\n\n    t.is(isDouble('中'), true);\n    t.is(isDouble('😄'), true);\n    t.is(isDouble('1'), false);\n    t.is(isDouble('a'), false);\n    t.is(isDouble('@'), false);\n\n    t.is(length('1a中', 1), '1');\n    t.is(length('1a中', 2), '1a');\n    t.is(length('1a中', 3), '1a');\n    t.is(length('1a中', 4), '1a中');\n    t.is(length('1a中😄', 6), '1a中😄');\n    t.is(length('1a中😄😄', 8), '1a中😄😄');\n    t.is(length('😄😄😄😄😄😄😄😄😄😄😄😄😄😄', 4), '😄😄');\n});\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flizhengnacl%2Fvision-string","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flizhengnacl%2Fvision-string","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flizhengnacl%2Fvision-string/lists"}