{"_id":"smartwrap@4.0.0","bin":{"smartwrap":"dist/cjs/terminal-adapter.js"},"bugs":{"url":"https://github.com/tecfu/smartwrap/issues"},"dist":{"shasum":"5323f069a0a31af0ca25315b7ae34fc3d469618b","tarball":"http://registry-npm.ywwl.com/smartwrap/download/smartwrap-4.0.0.tgz","fileCount":21,"integrity":"sha512-Eq1C6vg/05wvn7Su/QnNomnCxABogVgm4hxnLz6npBttXqLEZdxojANUXQqM/uMvv5V3O2wxUqcVBHOCBUu/GQ==","signatures":[{"sig":"MEUCIQC8qyGqvm1qCaO7OoJneekeOBFrFp1evNG9qcB2YKS2fwIgA58jj2fFn+3rxjfkijWYKY0EbQ6mUQCHxlBgORgxYuU=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"},{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIFfAUmgpsafPT7APWlzCw88POy+cNQSvFOwxykic95cTAiALU75HCZl3cABPFaqmW9ZuUYwzqDDaVwuiPR922qCqUg=="}],"unpackedSize":48042,"size":9650,"noattachment":false,"key":"/smartwrap/-/smartwrap-4.0.0.tgz"},"main":"./dist/cjs/main.js","name":"smartwrap","types":"./dist/cjs/main.d.ts","author":{"name":"tecfu"},"module":"./dist/esm/main.js","engines":{"node":">=22"},"exports":{".":{"import":{"types":"./dist/esm/main.d.ts","default":"./dist/esm/main.js"},"default":"./dist/cjs/main.js","require":{"types":"./dist/cjs/main.d.ts","default":"./dist/cjs/main.js"}},"./package.json":"./package.json"},"gitHead":"82fda5e6cc8bfbb7c3c15fce5b1d7c1f845d8a68","license":"MIT","scripts":{"lint":"eslint src/","test":"mocha test/test.js","build":"npm run build:cjs && npm run build:esm && node scripts/write-package-jsons.js","pretest":"npm run build","build:cjs":"tsc -p tsconfig.cjs.json","build:esm":"tsc -p tsconfig.esm.json","test-display":"npm run build && mocha test/test.js --require test/display-hook.js","prepublishOnly":"npm run build"},"version":"4.0.0","_npmUser":{"name":"tecfu","email":"help@tecfu.com"},"homepage":"https://github.com/tecfu/smartwrap#readme","keywords":["wordwrap","textwrap","wide-characters","emoji","ansi","terminal","typescript","esm"],"repository":{"url":"git+https://github.com/tecfu/smartwrap.git","type":"git"},"_npmVersion":"11.19.0","description":"Textwrap for javascript/nodejs. Correctly handles wide characters (宽字符) and emojis (😃). Wraps strings with option to break on words.","directories":{},"maintainers":[{"name":"tecfu","email":"help@tecfu.com"}],"_nodeVersion":"26.8.1","dependencies":{"yargs":"^17.7.2","breakword":"^2.1.0","strip-ansi":"^6.0.1"},"_hasShrinkwrap":false,"devDependencies":{"chai":"^4.3.10","mocha":"^12.0.2","eslint":"^8.57.0","typescript":"^5.4.5","@types/node":"^18.19.0","@types/yargs":"^17.0.33","@types/strip-ansi":"^5.2.1"},"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/smartwrap_4.0.0_1789934976573_0.9124349284456295"},"readme":"# smartwrap\n\nTextwrap for JavaScript/Node.js, written in **TypeScript**.  \nCorrectly handles wide characters (宽字符) and emojis (😃).  \nOptionally break words when wrapping strings. Preserves ANSI escape codes.\n\nShips compiled CommonJS + declaration files (`.d.ts`).\n\n## Installation\n\n```bash\nnpm install smartwrap\n```\n\nCLI (global):\n\n```bash\nnpm install -g smartwrap\n```\n\n## Usage\n\n```ts\n// ESM\nimport smartwrap from 'smartwrap'\n// or: import { smartwrap } from 'smartwrap'\n\n// CommonJS\nconst smartwrap = require('smartwrap')\n\nconsole.log(smartwrap('宽字符', { width: 2 }))\n// 宽\n// 字\n// 符\n```\n\n```ts\nconsole.log(smartwrap('break at word', { width: 10 }))\n// break at\n// word\n```\n\n```ts\nconsole.log(smartwrap('break at word', { width: 10, breakword: true }))\n// break at w\n// ord\n```\n\n### Options (`SmartwrapOptions`)\n\n| Option         | Type     | Default     | Description |\n|----------------|----------|-------------|-------------|\n| `width`        | number   | `10`        | Target line width in terminal columns |\n| `breakword`    | boolean  | `false`     | Break words that exceed remaining space |\n| `minWidth`     | 1 \\| 2   | `2`         | Minimum usable width (use `1` only if no wide chars) |\n| `paddingLeft`  | number   | `0`         | Spaces prepended to each line |\n| `paddingRight` | number   | `0`         | Spaces appended to each line |\n| `splitAt`      | string[] | `[\" \",\"\\t\"]`| Characters that split words |\n| `trim`         | boolean  | `true`      | Trim leading/trailing whitespace from input |\n| `errorChar`    | string   | `\"�\"`       | Replacement when a single wide char cannot fit |\n\n## CLI\n\n```bash\necho \"somestring you want to wrap\" | smartwrap --width=3 --paddingLeft=1\nsmartwrap --help\n```\n\n## Development\n\n```bash\nnpm install\nnpm run build   # tsc → dist/\nnpm test\n```\n\nSource is pure TypeScript under `src/`. Published artifacts live in `dist/`.\n\n## Breaking changes in 3.0.0\n\n- **Node.js ≥ 22** required (matches breakword@2.1.0).\n- Display width is now measured by [`breakword.width()`](https://github.com/tecfu/breakword) instead of `wcwidth`: a generated Unicode 18.0.0 East Asian Width table plus UAX #51 `Emoji_Presentation`, no dependencies of its own. Output changes where the two disagree — code points `wcwidth` 1.x scored 1 cell but measure 2 (e.g. `⚡` U+26A1) now wrap wider.\n- Source rewritten in TypeScript; `main` / `types` point at `dist/`.\n- Removed unused `grapheme-splitter` and the `array.prototype.flat` polyfill.\n- See prior changelog notes on the modernize release for dependency cleanup details.\n\n## License\n\n[MIT](https://opensource.org/licenses/MIT)\n","publish_time":1789934976663,"_cnpm_publish_time":1789934976663,"dist-tags":{"latest":"4.0.0"}}