{"name":"smartwrap","version":"3.0.0","keywords":["wordwrap","textwrap","wide-characters","emoji","ansi","terminal","typescript","esm"],"author":{"name":"tecfu"},"license":"MIT","_id":"smartwrap@3.0.0","maintainers":[{"name":"tecfu","email":"help@tecfu.com"}],"homepage":"https://github.com/tecfu/smartwrap#readme","bugs":{"url":"https://github.com/tecfu/smartwrap/issues"},"bin":{"smartwrap":"dist/cjs/terminal-adapter.js"},"dist":{"shasum":"a026f22c3f119e1dcc930e5af3eb1c0af1987273","tarball":"http://registry-npm.ywwl.com/smartwrap/download/smartwrap-3.0.0.tgz","fileCount":21,"integrity":"sha512-xfMZARlXU10sIBc/AGifk4eMFRow5Yo+4qIMNgFFWA6rXerBfOK1ciDLd6TxdqtMdxMqOxFniBes+nKoeHUaoA==","signatures":[{"sig":"MEUCIQDvv4EhAE9ISkjJvq60iUUwisVrSWTGcaumOX6NuuVlgAIgCmEv+KY1uVrF9Se23fon5BWsCrPqh3UgGeFiyJYsJwg=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"},{"sig":"MEYCIQDMoYagUC1ExQoOHElZnjkBDN/5wcgYKHO/IUk6zFg5qgIhAMX+podeJ/FidqtW6WIYh77npCDVk7sMdB2CO3KnvVL7","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":46887,"size":9330,"noattachment":false,"key":"/smartwrap/-/smartwrap-3.0.0.tgz"},"main":"./dist/cjs/main.js","types":"./dist/cjs/main.d.ts","module":"./dist/esm/main.js","engines":{"node":">=14"},"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":"2275893c3d09aeb4950ddd7a0b8e3ac768ce7f4e","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"},"_npmUser":{"name":"tecfu","email":"help@tecfu.com"},"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":{},"_nodeVersion":"26.8.1","dependencies":{"yargs":"^17.7.2","wcwidth":"^1.0.1","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":{"tmp":"tmp/smartwrap_3.0.0_1789894256122_0.011727310108943678","host":"s3://npm-registry-packages-npm-production"},"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":1789894256205,"_cnpm_publish_time":1789894256205,"dist-tags":{"latest":"4.0.0"}}