UNPKG

@zkochan/pnpm

Version:

Fast, disk space efficient package manager

143 lines (142 loc) 8.29 kB
{ "_args": [ [ { "raw": "printable-characters@^1.0.37", "scope": null, "escapedName": "printable-characters", "name": "printable-characters", "rawSpec": "^1.0.37", "spec": ">=1.0.37 <2.0.0", "type": "range" }, "/home/zkochan/src/pnpm/packages/pnpm/node_modules/as-table" ] ], "_from": "printable-characters@>=1.0.37 <2.0.0", "_id": "printable-characters@1.0.42", "_inCache": true, "_location": "/printable-characters", "_nodeVersion": "4.9.1", "_npmOperationalInternal": { "host": "s3://npm-registry-packages", "tmp": "tmp/printable-characters_1.0.42_1531778840434_0.9205782877395494" }, "_npmUser": { "name": "xpl", "email": "rocket.mind@gmail.com" }, "_npmVersion": "2.15.11", "_phantomChildren": {}, "_requested": { "raw": "printable-characters@^1.0.37", "scope": null, "escapedName": "printable-characters", "name": "printable-characters", "rawSpec": "^1.0.37", "spec": ">=1.0.37 <2.0.0", "type": "range" }, "_requiredBy": [ "/as-table" ], "_resolved": "https://registry.npmjs.org/printable-characters/-/printable-characters-1.0.42.tgz", "_shasum": "3f18e977a9bd8eb37fcc4ff5659d7be90868b3d8", "_shrinkwrap": null, "_spec": "printable-characters@^1.0.37", "_where": "/home/zkochan/src/pnpm/packages/pnpm/node_modules/as-table", "author": { "name": "Vitaly Gordon", "email": "rocket.mind@gmail.com" }, "bugs": { "url": "https://github.com/xpl/printable-characters/issues" }, "dependencies": {}, "description": "A little helper for handling strings containing zero width control characters, ANSI styling, whitespaces, newlines, 💩, etc.", "devDependencies": { "babel-cli": "^6.26.0", "babel-plugin-transform-es2015-block-scoped-functions": "^6.22.0", "babel-plugin-transform-es2015-destructuring": "^6.23.0", "coveralls": "^2.13.3", "eslint": "^4.8.0", "istanbul": "^0.4.5", "mocha": "^3.5.3", "nyc": "^11.2.1" }, "directories": {}, "dist": { "shasum": "3f18e977a9bd8eb37fcc4ff5659d7be90868b3d8", "tarball": "https://registry.npmjs.org/printable-characters/-/printable-characters-1.0.42.tgz", "fileCount": 13, "unpackedSize": 191608 }, "gitHead": "98fe4b7c4d9d9478850af93227d0aba04e93d095", "homepage": "https://github.com/xpl/printable-characters", "keywords": [ "string width", "string length", "real string width", "real string length", "optical string width", "printed width", "unicode", "codepoints", "code points", "strlen", "zero width", "zero width symbols", "zero width characters", "visible characters", "visible symbols", "visible", "invisible", "invisible symbols", "invisible characters", "printable", "printable length", "printable symbols", "printable characters", "non-printable characters", "nonprintable characters", "characters", "symbols", "string length", "real string length", "string trimming", "trimming", "escapes", "escape codes", "codes", "ansi escapes", "tokenizing", "ansi", "whitespaces" ], "license": "Unlicense", "main": "./build/printable-characters.js", "maintainers": [ { "name": "xpl", "email": "rocket.mind@gmail.com" } ], "name": "printable-characters", "optionalDependencies": {}, "readme": "# printable-characters\n\n[![Build Status](https://travis-ci.org/xpl/printable-characters.svg?branch=master)](https://travis-ci.org/xpl/printable-characters) [![Coverage Status](https://coveralls.io/repos/github/xpl/printable-characters/badge.svg)](https://coveralls.io/github/xpl/printable-characters) [![npm](https://img.shields.io/npm/v/printable-characters.svg)](https://npmjs.com/package/printable-characters) [![Scrutinizer Code Quality](https://img.shields.io/scrutinizer/g/xpl/printable-characters.svg)](https://scrutinizer-ci.com/g/xpl/printable-characters/?branch=master) [![dependencies Status](https://david-dm.org/xpl/printable-characters/status.svg)](https://david-dm.org/xpl/printable-characters)\n\nA little helper for handling strings containing zero width characters, ANSI styling, whitespaces, newlines, [weird Unicode 💩 symbols](http://blog.jonnew.com/posts/poo-dot-length-equals-two), etc.\n\n## Determining the real (visible) length of a string\n\n```javascript\nconst { strlen } = require ('printable-characters')\n\nstrlen ('foo bar') // === 7\nstrlen ('\\u001b[106mfoo bar\\u001b[49m') // === 7\n```\n\n## Detecting blank text\n\n```javascript\nconst { isBlank } = require ('printable-characters')\n\nisBlank ('foobar') // === false\nisBlank ('\\u001b[106m \\t \\t \\n \\u001b[49m') // === true\n```\n\n## Obtaining a blank string of the same width\n\n```javascript\nconst { blank } = require ('printable-characters')\n\nblank ('💩') // === ' '\nblank ('foo') // === ' '\nblank ('\\tfoo \\nfoo') // === '\\t \\n '\nblank ('\\u001b[22m\\u001b[1mfoo \\t\\u001b[39m\\u001b[22m')) // === ' \\t'\n```\n\n## Matching invisible characters\n\n```javascript\nconst { ansiEscapeCodes, zeroWidthCharacters } = require ('printable-characters')\n\nconst s = '\\u001b[106m' + 'foo' + '\\n' + 'bar' + '\\u001b[49m'\n\ns.replace (ansiEscapeCodes, '') // === 'foo\\nbar'\n .replace (zeroWidthCharacters, '') // === 'foobar'\n```\n\n## Getting the first N visible symbols, preserving the invisible parts\n\nUse for safely truncating strings to maximum width without breaking ANSI codes:\n\n```javascript\nconst { first } = require ('printable-characters')\n\nconst s = '\\u001b[22mfoobar\\u001b[22m'\n\nfirst (s, 0) // === '\\u001b[22m\\u001b[22m'\nfirst (s, 1) // === '\\u001b[22mf\\u001b[22m'\nfirst (s, 3) // === '\\u001b[22mfoo\\u001b[22m'\nfirst (s, 6) // === '\\u001b[22mfoobar\\u001b[22m'\n```\n\n## Extracting the invisible parts followed by the visible ones (parsing)\n\n```javascript\nconst { partition } = require ('printable-characters')\n\npartition ('') // [ ])\npartition ('foo') // [['', 'foo'] ])\npartition ('\\u001b[1mfoo') // [['\\u001b[1m', 'foo'] ])\npartition ('\\u001b[1mfoo\\u0000bar') // [['\\u001b[1m', 'foo'], ['\\u0000', 'bar'] ])\npartition ('\\u001b[1mfoo\\u0000bar\\n') // [['\\u001b[1m', 'foo'], ['\\u0000', 'bar'], ['\\n', '']])\n```\n\n## Applications\n\n- [as-table](https://github.com/xpl/as-table) — a simple function that prints objects as ASCII tables\n- [string.bullet](https://github.com/xpl/string.bullet) — ASCII-mode bulleting for the list-style data\n- [string.ify](https://github.com/xpl/string.ify) — a fancy pretty printer for the JavaScript entities\n- [Ololog!](https://github.com/xpl/ololog) — a better `console.log` for the log-driven debugging junkies!\n\n## TODO\n\nHandle multi-component emojis, as in [this article](http://blog.jonnew.com/posts/poo-dot-length-equals-two):\n\n```javascript\nassert.equal (strlen ('👩‍❤️‍💋‍👩'), 1) // FAILING, see http://blog.jonnew.com/posts/poo-dot-length-equals-two for possible solution\nassert.equal (blank ('👩‍❤️‍💋‍👩'), ' ') // FAILING, see http://blog.jonnew.com/posts/poo-dot-length-equals-two for possible solution\n```\n", "readmeFilename": "README.md", "repository": { "type": "git", "url": "git+https://github.com/xpl/printable-characters.git" }, "scripts": { "autotest": "env PRINTABLE_CHARACTERS_TEST_FILE=./printable-characters.js mocha --reporter spec --watch", "babel": "babel printable-characters.js --source-maps inline --out-file ./build/printable-characters.js", "build": "npm run lint && npm run lint-test && npm run babel", "coveralls": "nyc report --reporter=text-lcov | coveralls", "lint": "eslint printable-characters.js", "lint-test": "eslint printable-characters.js", "test": "npm run build && env PRINTABLE_CHARACTERS_TEST_FILE=./build/printable-characters.js nyc --reporter=html --reporter=text mocha --reporter spec" }, "version": "1.0.42" }