{"id":15646469,"url":"https://github.com/martinheidegger/wcstring","last_synced_at":"2026-02-15T01:05:03.401Z","repository":{"id":57397177,"uuid":"45316491","full_name":"martinheidegger/wcstring","owner":"martinheidegger","description":"JavaScript CommonJS (node.js) package for working with strings in a terminal (tty) context.","archived":false,"fork":false,"pushed_at":"2016-05-02T12:59:35.000Z","size":9,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-09-10T14:51:24.721Z","etag":null,"topics":["i18n","terminal","tty","wcsize","wcstring","wcwidth"],"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/martinheidegger.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}},"created_at":"2015-10-31T20:07:33.000Z","updated_at":"2021-05-17T04:13:50.000Z","dependencies_parsed_at":"2022-09-07T09:21:24.168Z","dependency_job_id":null,"html_url":"https://github.com/martinheidegger/wcstring","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/martinheidegger/wcstring","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/martinheidegger%2Fwcstring","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/martinheidegger%2Fwcstring/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/martinheidegger%2Fwcstring/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/martinheidegger%2Fwcstring/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/martinheidegger","download_url":"https://codeload.github.com/martinheidegger/wcstring/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/martinheidegger%2Fwcstring/sbom","scorecard":{"id":621706,"data":{"date":"2025-08-11","repo":{"name":"github.com/martinheidegger/wcstring","commit":"24358dd59c46b26f1b899bb1529a352b18bd86e8"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":2.6,"checks":[{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Code-Review","score":0,"reason":"Found 0/15 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"SAST","score":0,"reason":"no SAST tool detected","details":["Warn: no pull requests merged into dev branch"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":0,"reason":"license file not detected","details":["Warn: project does not have a license file"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}}]},"last_synced_at":"2025-08-21T05:21:55.630Z","repository_id":57397177,"created_at":"2025-08-21T05:21:55.630Z","updated_at":"2025-08-21T05:21:55.630Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29463592,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-15T01:01:38.065Z","status":"ssl_error","status_checked_at":"2026-02-15T01:01:23.809Z","response_time":53,"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":["i18n","terminal","tty","wcsize","wcstring","wcwidth"],"created_at":"2024-10-03T12:13:00.549Z","updated_at":"2026-02-15T01:05:03.366Z","avatar_url":"https://github.com/martinheidegger.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![ISC License](https://img.shields.io/badge/license-ISC-blue.svg?style=flat)](LICENSE.md)\n[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat)](http://standardjs.com/)\n[![npm version](https://badge.fury.io/js/wcstring.svg)](https://badge.fury.io/js/wcstring)\n[![Build Status](https://travis-ci.org/martinheidegger/wcstring.svg?branch=master)](https://travis-ci.org/martinheidegger/wcstring)\n\n# wcstring\n`wcstring` is a JavaScript CommonJS (node.js) package for working\nwith strings in a terminal (tty) context. In the terminal various characters\nare double the size of others, to operate on those characters `wcstring` is a helpful companion.\n\n## Installation \u0026 Usage\nWith [npm](https://docs.npmjs.com/getting-started/installing-node) you can install and use the `wcstring` like this:\n\n```\n$ npm install wcstring --save\n```\n\nWith the package being successfully installed you can create an instance like this:\n\n```JavaScript\nvar WCString = require('wcstring')\nvar str = new WCString('ABCdef', charWidth)\nvar str2 = WCString('abcDEF', charWidth) // You don't need to use `new`\n```\n\n## Operations\nOn the instance you can apply a set of operations. Note that the following explanation uses `size` as an accumulated amount of width and `width` as a single-line `size`.\n\n### `.width()`\nGet the `size` of the widest line in the string. \n\n### `.size()`\nGet the `size` of the complete string.\n\n### `.sizeBeforeFirst(search, [\u003cint\u003e startOffset])`\nAnalogous to [`String.indexOf`](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/String/indexOf). Looks for the first occurance of `search`. Optionally takes `startOffset` which is the `size` of characters that have to happen before the search takes place (default=0).\n\n### `.sizeBeforeLast(search, [\u003cint\u003e endOffset])`\nAnalogous to [`String.lastIndexOf`](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/String/lastIndexOf). Looks for the last occurance of `search`.\nOptionally takes `endOffset` which is the size offset from the end of the string from which to search for `search`.\n\n### `.substring(\u003cint\u003e startSize, [\u003cint\u003e endSize])`\nAnalogous to [`String.substring`](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/String/substring). This method will return the **fully visible** characters between `startSize` and `endSize`. If `endSize` is not given it will assume a substring from `startSize` until the end of the string.\n_However:_ **Unlike** `String.substring`, this method returns an object with the properties `size` and `string` in order to know the size of the substring.\n\nExample:\n```JavaScript\nvar vsstring = require('wcstring')\nvsstring('abcdef', charWidth).substring(0, 3) // {string: 'abc', size: 2.4}\n```\n\n### `.substr(\u003cint\u003e startSize, [\u003cint\u003e size])`\nEqual to `.substring(startSize, startSize + size)`.\n\n### `.wrap(\u003cint\u003e width, [padding])`\nNormalizes the string in order for all lines to fit within `width`.\n\nExample:\n```JavaScript\nvar vsstring = require('wcstring')\nvsstring('abcdef', charWidth).wrap(3) // 'abc\\ndef'\nvsstring('ab cd ef', charWidth).wrap(5) // 'ab cd\\nef'\nvsstring('ab cd ef', charWidth).wrap(3) // 'ab\\ncd\\nef'\n```\n\n#### Padding\nThe padding option takes a padding specification and applies it to the\nwrapping process.\n\nExample:\n\n```JavaScript\nvar padding = {\n    first: {left: ' - ', right: ' '},\n    regular: {left: '   ', right: ' '}\n}\nvsstring('abcdefghijklmnop', charWidth).wrap(10, padding)\n//  - abcdef\n//    ghijkl\n//    mnop\n```\n\nThere are a few shorthands to specifying the padding:\n\n```JavaScript\npadding = '  '\n```\n\n... is equals to ...\n\n```JavaScript\n{\n    first: '  ',\n    regular: '  '\n}\n```\n\n... is equals to ...\n\n```JavaScript\n{\n    first: {left: '  ': right: undefined},\n    regular: {left: '  ': right: undefined}\n}\n```\n\nAlso you can preset left/right for both first and regular:\n\n```JavScript\n{\n    right: 'x',\n    first: {left: ' - '},\n    regular: {left: '   '}\n}\n```\n\n... is equal to ... \n\n```JavaScript\n{\n    first: {left: ' - ', right: 'x'},\n    regular: {left: '   ', right: 'x'}\n}\n```\n\nNote that the left/right presets override the first/regular specification:\n\n```JavaScript\n{\n    left: 'x',\n    first: '-',\n    regular: ' '\n}\n```\n\n... is equal to ...\n\n```JavaScript\n{\n    first: {left: 'x', right: undefined},\n    regular: {left: 'x', right: undefined}\n}\n```\n\nAlso it supports a fallback to regular if first is missing:\n\n```JavaScript\n{\n    regular: {left: 'x', right: undefined}\n}\n```\n\n... is equal to ...\n\n```JavaScript\n{\n    first: {left: 'x', right: undefined},\n    regular: {left: 'x', right: undefined}\n}\n```\n\n### `wcstring.padding([process], [width], padding)`\nTurns a flexible padding definition into a clear padding definition. You can pass in an optional `process` variable to process the strings before they are being turned into wcstrings. You can also pass-in a `width` to make sure that the padding will not exceed the width of, say, a wrapped string.\n\n### `.truncate(\u003cint\u003e size, \u003cwcstring || String\u003e suffix)`\nTruncates the string after a size. Will append the given `suffix` to the string if it does exceed the size.\n\n### `.pop()`\nRemoves the last character from the string and returns the new `.size()`.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmartinheidegger%2Fwcstring","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmartinheidegger%2Fwcstring","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmartinheidegger%2Fwcstring/lists"}