{"_id":"unicode-byte-truncate","_rev":"3-96b44cdcdbca6219b362b0349c20b560","name":"unicode-byte-truncate","description":"Unicode aware string truncation that given a max byte size will truncate the string to or just below that size","dist-tags":{"latest":"1.0.0"},"versions":{"1.0.0":{"name":"unicode-byte-truncate","version":"1.0.0","description":"Unicode aware string truncation that given a max byte size will truncate the string to or just below that size","main":"index.js","dependencies":{"is-integer":"^1.0.6","unicode-substring":"^0.1.0"},"devDependencies":{"standard":"^6.0.4","tape":"^4.4.0"},"scripts":{"test":"standard && tape test.js"},"repository":{"type":"git","url":"git+https://github.com/watson/unicode-byte-truncate.git"},"keywords":["slice","substring","substr","trunc","truncate","trim","unicode","multibyte","multi-byte","surrogate","pair","pairs","max","byte","bytes","characters","chars"],"author":{"name":"Thomas Watson Steen","email":"w@tson.dk","url":"https://twitter.com/wa7son"},"license":"MIT","bugs":{"url":"https://github.com/watson/unicode-byte-truncate/issues"},"homepage":"https://github.com/watson/unicode-byte-truncate#readme","coordinates":[55.6666217,12.5798077],"gitHead":"87a61021a1afa23ffe97a84f74c1a76018044e23","_id":"unicode-byte-truncate@1.0.0","_shasum":"aa6f0f3475193fe20c320ac9213e36e62e8764a7","_from":".","_npmVersion":"2.14.7","_nodeVersion":"4.2.2","_npmUser":{"name":"watson","email":"w@tson.dk"},"maintainers":[{"name":"watson","email":"w@tson.dk"}],"dist":{"shasum":"aa6f0f3475193fe20c320ac9213e36e62e8764a7","tarball":"https://registry.npmjs.org/unicode-byte-truncate/-/unicode-byte-truncate-1.0.0.tgz","integrity":"sha512-GQgHk6DodEoKddKQdjnv7xKS9G09XCfHWX0R4RKht+EbUMSiVEmtWHGFO8HUm+6NvWik3E2/DG4MxTitOLL64A==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIGdALa6g+FbKlU4clGE8+BFdAufvSzY7AkKftobsHnPGAiARvvn9mGsKPzRiGOyqGJjk4RFqGaeXA7j0C0yz79QfDw=="}]},"_npmOperationalInternal":{"host":"packages-6-west.internal.npmjs.com","tmp":"tmp/unicode-byte-truncate-1.0.0.tgz_1454937970359_0.8347938964143395"}}},"readme":"# unicode-byte-truncate\n\nTruncate a string to a given byte size by removing bytes from the right\nwhile making sure not to slice in the middle of a multi-byte unicode\ncharacter.\n\n[![Build status](https://travis-ci.org/watson/unicode-byte-truncate.svg?branch=master)](https://travis-ci.org/watson/unicode-byte-truncate)\n[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat)](https://github.com/feross/standard)\n\n## Installation\n\n```\nnpm install unicode-byte-truncate --save\n```\n\n## Usage\n\n```js\nvar trunc = require('unicode-byte-truncate')\n\nvar str = 'foo🎉bar' // 10 byte string - byte 4 to 7 is a single character\n\nconsole.log(trunc(str, 4)) // `foo` == 0x666F6F (3 bytes)\nconsole.log(trunc(str, 5)) // `foo` == 0x666F6F (3 bytes)\nconsole.log(trunc(str, 6)) // `foo` == 0x666F6F (3 bytes)\nconsole.log(trunc(str, 7)) // `foo🎉` == 0x666F6FF09F8E89 (7 bytes)\n```\n\n## API\n\nThe unicode-byte-truncate module exposes a single `trunc` function.\n\n```js\nresult = trunc(string, maxBytes)\n```\n\nGiven a `string` and a `maxBytes` integer greater than or equal to zero,\nthe `trunc` function will slice characters off the end of the string to\nensure that it doesn't contain more bytes than specified by the\n`maxBytes` argument.\n\nThe truncated string will be returned as the `result`.\n\nThe `trunc` function is multi-byte unicode aware and will never cut up\nsurrogate pairs. This means that the `result` _may_ contain fewer bytes\nthan specified by the `maxBytes` argument.\n\n## License\n\nMIT\n","maintainers":[{"name":"watson","email":"w@tson.dk"}],"time":{"modified":"2022-06-28T04:24:55.184Z","created":"2016-02-08T13:26:12.983Z","1.0.0":"2016-02-08T13:26:12.983Z"},"homepage":"https://github.com/watson/unicode-byte-truncate#readme","keywords":["slice","substring","substr","trunc","truncate","trim","unicode","multibyte","multi-byte","surrogate","pair","pairs","max","byte","bytes","characters","chars"],"repository":{"type":"git","url":"git+https://github.com/watson/unicode-byte-truncate.git"},"author":{"name":"Thomas Watson Steen","email":"w@tson.dk","url":"https://twitter.com/wa7son"},"bugs":{"url":"https://github.com/watson/unicode-byte-truncate/issues"},"license":"MIT","readmeFilename":"README.md"}