diff options
author | Forrest L Norvell <forrest@npmjs.com> | 2014-12-12 11:21:47 +0300 |
---|---|---|
committer | Forrest L Norvell <forrest@npmjs.com> | 2014-12-12 11:21:47 +0300 |
commit | c7ad7279cc879930ec58ccc62fa642e621ecb65c (patch) | |
tree | 1b380572eb21447ec1f9b45d7324eb071e6910db /node_modules/columnify | |
parent | b6d6acfc02c8887f78067931babab8f7c5180fed (diff) |
columnify@1.3.2
Various improvements and dependency upgrades.
Diffstat (limited to 'node_modules/columnify')
12 files changed, 156 insertions, 79 deletions
diff --git a/node_modules/columnify/index.js b/node_modules/columnify/index.js index c44b8ca8f..8c15c993e 100644 --- a/node_modules/columnify/index.js +++ b/node_modules/columnify/index.js @@ -9,6 +9,14 @@ var splitIntoLines = utils.splitIntoLines var splitLongWords = utils.splitLongWords var truncateString = utils.truncateString +var DEFAULT_HEADING_TRANSFORM = function(key) { + return key.toUpperCase() +} + +var DEFAULT_DATA_TRANSFORM = function(cell, column, index) { + return cell +} + var DEFAULTS = { maxWidth: Infinity, minWidth: 0, @@ -18,12 +26,8 @@ var DEFAULTS = { preserveNewLines: false, paddingChr: ' ', showHeaders: true, - headingTransform: function(key) { - return key.toUpperCase() - }, - dataTransform: function(cell, column, index) { - return cell - } + headingTransform: DEFAULT_HEADING_TRANSFORM, + dataTransform: DEFAULT_DATA_TRANSFORM } module.exports = function(items, options) { @@ -68,9 +72,11 @@ module.exports = function(items, options) { // sanitize column settings columnNames.forEach(function(columnName) { var column = columns[columnName] + column.name = columnName column.maxWidth = Math.ceil(column.maxWidth) column.minWidth = Math.ceil(column.minWidth) column.truncate = !!column.truncate + column.align = column.align || 'left' }) // sanitize data @@ -96,7 +102,18 @@ module.exports = function(items, options) { columnNames.forEach(function(columnName) { var column = columns[columnName] items = items.map(function(item, index) { - item[columnName] = column.dataTransform(item[columnName], column, index) + var col = Object.create(column) + item[columnName] = column.dataTransform(item[columnName], col, index) + + var changedKeys = Object.keys(col) + // disable default heading transform if we wrote to column.name + if (changedKeys.indexOf('name') !== -1) { + if (column.headingTransform !== DEFAULT_HEADING_TRANSFORM) return + column.headingTransform = function(heading) {return heading} + } + changedKeys.forEach(function(key) { + column[key] = col[key] + }) return item }) }) @@ -106,7 +123,7 @@ module.exports = function(items, options) { if(options.showHeaders) { columnNames.forEach(function(columnName) { var column = columns[columnName] - headers[columnName] = column.headingTransform(columnName) + headers[columnName] = column.headingTransform(column.name) }) items.unshift(headers) } @@ -194,8 +211,8 @@ function createRows(items, columns, columnNames, paddingChr) { columnNames.forEach(function(columnName) { var column = columns[columnName] var val = item[columnName][i] || '' // || '' ensures empty columns get padded - if (column.align == 'right') row[i].push(padLeft(val, column.width, paddingChr)) - else if (column.align == 'center') row[i].push(padCenter(val, column.width, paddingChr)) + if (column.align === 'right') row[i].push(padLeft(val, column.width, paddingChr)) + else if (column.align === 'center' || column.align === 'centre') row[i].push(padCenter(val, column.width, paddingChr)) else row[i].push(padRight(val, column.width, paddingChr)) }) } diff --git a/node_modules/columnify/node_modules/strip-ansi/cli.js b/node_modules/columnify/node_modules/strip-ansi/cli.js index 602ae00e8..5b9546aab 100755 --- a/node_modules/columnify/node_modules/strip-ansi/cli.js +++ b/node_modules/columnify/node_modules/strip-ansi/cli.js @@ -2,38 +2,46 @@ 'use strict'; var fs = require('fs'); var pkg = require('./package.json'); -var strip = require('./'); -var input = process.argv[2]; +var stripAnsi = require('./'); +var argv = process.argv.slice(2); +var input = argv[0]; function help() { console.log([ - pkg.description, '', - 'Usage', - ' $ strip-ansi <input-file> > <output-file>', - ' $ cat <input-file> | strip-ansi > <output-file>', + ' ' + pkg.description, '', - 'Example', - ' $ strip-ansi unicorn.txt > unicorn-stripped.txt' + ' Usage', + ' strip-ansi <input-file> > <output-file>', + ' cat <input-file> | strip-ansi > <output-file>', + '', + ' Example', + ' strip-ansi unicorn.txt > unicorn-stripped.txt' ].join('\n')); } -if (process.argv.indexOf('--help') !== -1) { +function init(data) { + process.stdout.write(stripAnsi(data)); +} + +if (argv.indexOf('--help') !== -1) { help(); return; } -if (process.argv.indexOf('--version') !== -1) { +if (argv.indexOf('--version') !== -1) { console.log(pkg.version); return; } -if (input) { - process.stdout.write(strip(fs.readFileSync(input, 'utf8'))); - return; -} +if (process.stdin.isTTY) { + if (!input) { + help(); + return; + } -process.stdin.setEncoding('utf8'); -process.stdin.on('data', function (data) { - process.stdout.write(strip(data)); -}); + init(fs.readFileSync(input, 'utf8')); +} else { + process.stdin.setEncoding('utf8'); + process.stdin.on('data', init); +} diff --git a/node_modules/columnify/node_modules/strip-ansi/node_modules/ansi-regex/index.js b/node_modules/columnify/node_modules/strip-ansi/node_modules/ansi-regex/index.js index 783c5c7bb..2fcdd1e47 100644 --- a/node_modules/columnify/node_modules/strip-ansi/node_modules/ansi-regex/index.js +++ b/node_modules/columnify/node_modules/strip-ansi/node_modules/ansi-regex/index.js @@ -1,4 +1,4 @@ 'use strict'; module.exports = function () { - return /\u001b\[(?:[0-9]{1,3}(?:;[0-9]{1,3})*)?[m|K]/g; + return /(?:(?:\u001b\[)|\u009b)(?:(?:[0-9]{1,3})?(?:(?:;[0-9]{0,3})*)?[A-M|f-m])|\u001b[A-M]/g; }; diff --git a/node_modules/columnify/node_modules/strip-ansi/node_modules/ansi-regex/package.json b/node_modules/columnify/node_modules/strip-ansi/node_modules/ansi-regex/package.json index ca610250c..ab8ea0388 100644 --- a/node_modules/columnify/node_modules/strip-ansi/node_modules/ansi-regex/package.json +++ b/node_modules/columnify/node_modules/strip-ansi/node_modules/ansi-regex/package.json @@ -1,6 +1,6 @@ { "name": "ansi-regex", - "version": "0.2.1", + "version": "1.1.0", "description": "Regular expression for matching ANSI escape codes", "license": "MIT", "repository": { @@ -16,7 +16,8 @@ "node": ">=0.10.0" }, "scripts": { - "test": "mocha" + "test": "mocha test/test.js", + "view-supported": "node test/viewCodes.js" }, "files": [ "index.js" @@ -55,9 +56,9 @@ "url": "https://github.com/sindresorhus/ansi-regex/issues" }, "homepage": "https://github.com/sindresorhus/ansi-regex", - "_id": "ansi-regex@0.2.1", - "_shasum": "0d8e946967a3d8143f93e24e298525fc1b2235f9", - "_from": "ansi-regex@0.2.1", + "_id": "ansi-regex@1.1.0", + "_shasum": "67792c5d6ad05c792d6cd6057ac8f5e69ebf4357", + "_from": "ansi-regex@>=1.0.0 <2.0.0", "_npmVersion": "1.4.9", "_npmUser": { "name": "sindresorhus", @@ -67,12 +68,17 @@ { "name": "sindresorhus", "email": "sindresorhus@gmail.com" + }, + { + "name": "jbnicolai", + "email": "jappelman@xebia.com" } ], "dist": { - "shasum": "0d8e946967a3d8143f93e24e298525fc1b2235f9", - "tarball": "http://registry.npmjs.org/ansi-regex/-/ansi-regex-0.2.1.tgz" + "shasum": "67792c5d6ad05c792d6cd6057ac8f5e69ebf4357", + "tarball": "http://registry.npmjs.org/ansi-regex/-/ansi-regex-1.1.0.tgz" }, "directories": {}, - "_resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-0.2.1.tgz" + "_resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-1.1.0.tgz", + "readme": "ERROR: No README data found!" } diff --git a/node_modules/columnify/node_modules/strip-ansi/package.json b/node_modules/columnify/node_modules/strip-ansi/package.json index 64c4dee52..89d1041bd 100644 --- a/node_modules/columnify/node_modules/strip-ansi/package.json +++ b/node_modules/columnify/node_modules/strip-ansi/package.json @@ -1,11 +1,8 @@ { "name": "strip-ansi", - "version": "1.0.0", + "version": "2.0.0", "description": "Strip ANSI escape codes", "license": "MIT", - "bin": { - "strip-ansi": "cli.js" - }, "repository": { "type": "git", "url": "git://github.com/sindresorhus/strip-ansi" @@ -15,6 +12,9 @@ "email": "sindresorhus@gmail.com", "url": "http://sindresorhus.com" }, + "bin": { + "strip-ansi": "cli.js" + }, "engines": { "node": ">=0.10.0" }, @@ -51,19 +51,19 @@ "text" ], "dependencies": { - "ansi-regex": "^0.2.1" + "ansi-regex": "^1.0.0" }, "devDependencies": { "mocha": "*" }, - "gitHead": "6fea2ef935f1ba10d43e4c4d9814af328803935c", + "gitHead": "c5e780acc07532f5d651cfb6ea035198095c6c74", "bugs": { "url": "https://github.com/sindresorhus/strip-ansi/issues" }, "homepage": "https://github.com/sindresorhus/strip-ansi", - "_id": "strip-ansi@1.0.0", - "_shasum": "6c021321d6ece161a3c608fbab268c7328901c73", - "_from": "strip-ansi@>=1.0.0-0 <2.0.0-0", + "_id": "strip-ansi@2.0.0", + "_shasum": "fa8d69432e97674746f55f51d076ae78b18df13f", + "_from": "strip-ansi@>=2.0.0 <3.0.0", "_npmVersion": "1.4.14", "_npmUser": { "name": "sindresorhus", @@ -80,9 +80,10 @@ } ], "dist": { - "shasum": "6c021321d6ece161a3c608fbab268c7328901c73", - "tarball": "http://registry.npmjs.org/strip-ansi/-/strip-ansi-1.0.0.tgz" + "shasum": "fa8d69432e97674746f55f51d076ae78b18df13f", + "tarball": "http://registry.npmjs.org/strip-ansi/-/strip-ansi-2.0.0.tgz" }, "directories": {}, - "_resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-1.0.0.tgz" + "_resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-2.0.0.tgz", + "readme": "ERROR: No README data found!" } diff --git a/node_modules/columnify/node_modules/wcwidth/node_modules/defaults/node_modules/clone/README.md b/node_modules/columnify/node_modules/wcwidth/node_modules/defaults/node_modules/clone/README.md index 527743b60..d7231cfca 100644 --- a/node_modules/columnify/node_modules/wcwidth/node_modules/defaults/node_modules/clone/README.md +++ b/node_modules/columnify/node_modules/wcwidth/node_modules/defaults/node_modules/clone/README.md @@ -21,7 +21,7 @@ var clone = require('clone'); var a, b; -a = { foo: { bar: 'baz' } }; // inital value of a +a = { foo: { bar: 'baz' } }; // initial value of a b = clone(a); // clone a -> b a.foo.bar = 'foo'; // change a @@ -52,7 +52,7 @@ can clone dates in arrays in objects, for example. Call `clone` with `circular` set to `false` if you are certain that `obj` contains no circular references. This will give better performance if needed. There is no error if `undefined` or `null` is passed as `obj`. - * `depth` -- depth to wich the object is to be cloned (optional, + * `depth` -- depth to which the object is to be cloned (optional, defaults to infinity) `clone.clonePrototype(obj)` diff --git a/node_modules/columnify/node_modules/wcwidth/node_modules/defaults/node_modules/clone/clone.js b/node_modules/columnify/node_modules/wcwidth/node_modules/defaults/node_modules/clone/clone.js index 5d402073b..f8fa3159a 100644 --- a/node_modules/columnify/node_modules/wcwidth/node_modules/defaults/node_modules/clone/clone.js +++ b/node_modules/columnify/node_modules/wcwidth/node_modules/defaults/node_modules/clone/clone.js @@ -72,6 +72,7 @@ function clone(parent, circular, depth, prototype) { return parent; var child; + var proto; if (typeof parent != 'object') { return parent; } @@ -88,8 +89,14 @@ function clone(parent, circular, depth, prototype) { parent.copy(child); return child; } else { - if (typeof prototype == 'undefined') child = Object.create(Object.getPrototypeOf(parent)); - else child = Object.create(prototype); + if (typeof prototype == 'undefined') { + proto = Object.getPrototypeOf(parent); + child = Object.create(proto); + } + else { + child = Object.create(prototype); + proto = prototype; + } } if (circular) { @@ -103,6 +110,14 @@ function clone(parent, circular, depth, prototype) { } for (var i in parent) { + var attrs; + if (proto) { + attrs = Object.getOwnPropertyDescriptor(proto, i); + } + + if (attrs && attrs.set == null) { + continue; + } child[i] = _clone(parent[i], depth - 1); } diff --git a/node_modules/columnify/node_modules/wcwidth/node_modules/defaults/node_modules/clone/package.json b/node_modules/columnify/node_modules/wcwidth/node_modules/defaults/node_modules/clone/package.json index 3c6b77647..dc56f3f19 100644 --- a/node_modules/columnify/node_modules/wcwidth/node_modules/defaults/node_modules/clone/package.json +++ b/node_modules/columnify/node_modules/wcwidth/node_modules/defaults/node_modules/clone/package.json @@ -8,7 +8,7 @@ "function", "date" ], - "version": "0.1.18", + "version": "0.1.19", "repository": { "type": "git", "url": "git://github.com/pvorb/node-clone.git" @@ -81,6 +81,11 @@ { "name": "Nathan Zadoks", "url": "https://github.com/nathan7" + }, + { + "name": "RĂ³bert Oroszi", + "email": "robert+gh@oroszi.net", + "url": "https://github.com/oroce" } ], "license": "MIT", @@ -96,11 +101,11 @@ "scripts": { "test": "nodeunit test.js" }, - "gitHead": "17eea36140d61d97a9954c53417d0e04a00525d9", + "gitHead": "bb11a43363a0f69e8ac014cb5376ce215ea1f8fd", "homepage": "https://github.com/pvorb/node-clone", - "_id": "clone@0.1.18", - "_shasum": "64a0d5d57eaa85a1a8af380cd1db8c7b3a895f66", - "_from": "clone@>=0.1.5-0 <0.2.0-0", + "_id": "clone@0.1.19", + "_shasum": "613fb68639b26a494ac53253e15b1a6bd88ada85", + "_from": "clone@>=0.1.5 <0.2.0", "_npmVersion": "1.4.14", "_npmUser": { "name": "pvorb", @@ -113,9 +118,10 @@ } ], "dist": { - "shasum": "64a0d5d57eaa85a1a8af380cd1db8c7b3a895f66", - "tarball": "http://registry.npmjs.org/clone/-/clone-0.1.18.tgz" + "shasum": "613fb68639b26a494ac53253e15b1a6bd88ada85", + "tarball": "http://registry.npmjs.org/clone/-/clone-0.1.19.tgz" }, "directories": {}, - "_resolved": "https://registry.npmjs.org/clone/-/clone-0.1.18.tgz" + "_resolved": "https://registry.npmjs.org/clone/-/clone-0.1.19.tgz", + "readme": "ERROR: No README data found!" } diff --git a/node_modules/columnify/node_modules/wcwidth/node_modules/defaults/node_modules/clone/test.js b/node_modules/columnify/node_modules/wcwidth/node_modules/defaults/node_modules/clone/test.js index ee49ad893..cb3d16631 100644 --- a/node_modules/columnify/node_modules/wcwidth/node_modules/defaults/node_modules/clone/test.js +++ b/node_modules/columnify/node_modules/wcwidth/node_modules/defaults/node_modules/clone/test.js @@ -269,3 +269,21 @@ exports['clone object with null children'] = function(test) { test.deepEqual(b, a); test.done(); } + +exports['clone instance with getter'] = function(test) { + test.expect(1); + function Ctor() {}; + Object.defineProperty(Ctor.prototype, 'prop', { + configurable: true, + enumerable: true, + get: function() { + return 'value'; + } + }); + + var a = new Ctor(); + var b = clone(a); + + test.strictEqual(b.prop, 'value'); + test.done(); +};
\ No newline at end of file diff --git a/node_modules/columnify/node_modules/wcwidth/node_modules/defaults/package.json b/node_modules/columnify/node_modules/wcwidth/node_modules/defaults/package.json index f9243a120..e3ee62191 100644 --- a/node_modules/columnify/node_modules/wcwidth/node_modules/defaults/package.json +++ b/node_modules/columnify/node_modules/wcwidth/node_modules/defaults/package.json @@ -45,6 +45,10 @@ ], "directories": {}, "_shasum": "3ae25f44416c6c01f9809a25fcdd285912d2a6b1", - "_from": "defaults@>=1.0.0-0 <2.0.0-0", - "_resolved": "https://registry.npmjs.org/defaults/-/defaults-1.0.0.tgz" + "_resolved": "https://registry.npmjs.org/defaults/-/defaults-1.0.0.tgz", + "_from": "defaults@>=1.0.0 <2.0.0", + "bugs": { + "url": "https://github.com/tmpvar/defaults/issues" + }, + "homepage": "https://github.com/tmpvar/defaults" } diff --git a/node_modules/columnify/node_modules/wcwidth/package.json b/node_modules/columnify/node_modules/wcwidth/package.json index f12d49b78..4744d9dc3 100644 --- a/node_modules/columnify/node_modules/wcwidth/package.json +++ b/node_modules/columnify/node_modules/wcwidth/package.json @@ -40,7 +40,7 @@ "gitHead": "5bc3aafd45c89f233c27b9479c18a23ca91ba660", "_id": "wcwidth@1.0.0", "_shasum": "02d059ff7a8fc741e0f6b5da1e69b2b40daeca6f", - "_from": "wcwidth@>=1.0.0-0 <2.0.0-0", + "_from": "wcwidth@>=1.0.0 <2.0.0", "_npmVersion": "1.4.23", "_npmUser": { "name": "timoxley", diff --git a/node_modules/columnify/package.json b/node_modules/columnify/package.json index ef307b509..c60e1d9de 100644 --- a/node_modules/columnify/package.json +++ b/node_modules/columnify/package.json @@ -1,20 +1,21 @@ { "name": "columnify", - "version": "1.2.1", - "description": "Render data in text columns, supports in-column text-wrap.", + "version": "1.3.2", + "description": "Render data in text columns. supports in-column text-wrap.", "main": "index.js", "scripts": { "pretest": "npm prune", - "test": "faucet" + "test": "tape test/*.js | tap-spec", + "bench": "npm test && node bench" }, "author": { "name": "Tim Oxley" }, "license": "MIT", "devDependencies": { - "chalk": "^0.4.0", - "faucet": "0.0.1", - "tape": "~2.12.3" + "chalk": "^0.5.1", + "tap-spec": "^2.1.1", + "tape": "^3.0.3" }, "repository": { "type": "git", @@ -34,17 +35,18 @@ }, "homepage": "https://github.com/timoxley/columnify", "dependencies": { - "strip-ansi": "^1.0.0", + "strip-ansi": "^2.0.0", "wcwidth": "^1.0.0" }, "directories": { "test": "test" }, - "gitHead": "14e77bef3f57acaa3f390145915a9f2d2a4f882c", - "_id": "columnify@1.2.1", - "_shasum": "921ec51c178f4126d3c07e9acecd67a55c7953e4", - "_from": "columnify@>=1.2.1-0 <2.0.0-0", - "_npmVersion": "1.4.23", + "gitHead": "5c7d4363a8d6178f0d415e8bdaf692281fe71975", + "_id": "columnify@1.3.2", + "_shasum": "61bd578a9269ae6fd949ce36fff589f3702c7867", + "_from": "columnify@>=1.3.2 <1.4.0", + "_npmVersion": "2.1.10", + "_nodeVersion": "0.10.33", "_npmUser": { "name": "timoxley", "email": "secoif@gmail.com" @@ -56,8 +58,8 @@ } ], "dist": { - "shasum": "921ec51c178f4126d3c07e9acecd67a55c7953e4", - "tarball": "http://registry.npmjs.org/columnify/-/columnify-1.2.1.tgz" + "shasum": "61bd578a9269ae6fd949ce36fff589f3702c7867", + "tarball": "http://registry.npmjs.org/columnify/-/columnify-1.3.2.tgz" }, - "_resolved": "https://registry.npmjs.org/columnify/-/columnify-1.2.1.tgz" + "_resolved": "https://registry.npmjs.org/columnify/-/columnify-1.3.2.tgz" } |