Comparing version 0.1.0 to 0.1.1
@@ -45,3 +45,3 @@ | ||
Formatter.prototype._re = /\%(?:\(([\w_]+)\)|([1-9]\d*)\$)?([0 +\-\#]*)(\*|\d+)?(\.)?(\*|\d+)?[hlL]?([\%bscdeEfFgGioOuxX])/g; | ||
Formatter.prototype._re = /\%(?:\(([\w_]+)\)|([1-9]\d*)\$)?([0 +\-\#]*)(\*|\d+)?(\.)?(\*|\d+)?[hlL]?([\%AbscdeEfFgGioOuxX])/g; | ||
Formatter.prototype._parseDelim = function(mapping, intmapping, flags, minWidth, period, precision, specifier){ | ||
@@ -129,6 +129,9 @@ if(mapping){ | ||
O: { | ||
setArg: function(token){ | ||
token.arg = util.inspect(token.arg, true, null); | ||
} | ||
isObject: true, | ||
showNonEnumerable: true | ||
}, | ||
A: { | ||
isObject: true, | ||
showNonEnumerable: false | ||
}, | ||
}; | ||
@@ -202,2 +205,3 @@ Formatter.prototype.format = function(/*mixed...*/ filler){ | ||
token.isDouble = false; | ||
token.isObject = false; | ||
token.precision = 1; | ||
@@ -276,2 +280,4 @@ if(token.period == '.'){ | ||
this.formatDouble(token); | ||
}else if(token.isObject){ | ||
this.formatObject(token); | ||
} | ||
@@ -399,2 +405,7 @@ this.fitField(token); | ||
}; | ||
Formatter.prototype.formatObject = function(token) { | ||
// If no precision is specified, then reset it to null (infinite depth). | ||
var precision = (token.period === '.') ? token.precision : null; | ||
token.arg = util.inspect(token.arg, token.showNonEnumerable, precision); | ||
}; | ||
Formatter.prototype.zeroPad = function(token, /*Int*/ length) { | ||
@@ -401,0 +412,0 @@ length = (arguments.length == 2) ? length : token.precision; |
{ | ||
"name": "printf", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"description": "Full implementation of the `printf` family in pure JS.", | ||
@@ -9,3 +9,8 @@ "keywords": ["printf", "formatting", "sprintf", "format", "output", "print"], | ||
"maintainers": [ "David Worms <david@adaltas.com>"], | ||
"contributors": [ "David Worms <david@adaltas.com>"], | ||
"contributors": [ | ||
"David Worms <david@adaltas.com>", | ||
"Aluísio Augusto Silva Gonçalves <aluisio@aasg.name>", | ||
"Xavier Mendez <jmendeth@gmail.com>", | ||
"LLeo <lleoem@gmail.com>" | ||
], | ||
"main": "./lib/printf", | ||
@@ -12,0 +17,0 @@ "engines": { "node": ">= 0.1.90" }, |
@@ -17,3 +17,4 @@ _ _ __ | ||
## Installing | ||
Installing | ||
---------- | ||
@@ -26,3 +27,4 @@ Via [NPM][npm]: | ||
## Usage | ||
Usage | ||
----- | ||
@@ -43,3 +45,4 @@ Use it like you would in C (`printf`/`sprintf`): | ||
## Features | ||
Features | ||
-------- | ||
@@ -99,3 +102,4 @@ ``` javascript | ||
## Extra features! | ||
Extra features! | ||
--------------- | ||
@@ -117,2 +121,21 @@ ### Inspector | ||
Specifying a precision lets you control the depth up to which the object is formatted: | ||
``` javascript | ||
assert.eql("Debug: { depth0: { depth1_: 0, depth1: [Object] } }", | ||
printf('Debug: %.1O', {depth0: {depth1: {depth2: {depth3: true}}, depth1_: 0}}) | ||
); | ||
``` | ||
You can also use `%A` instead of `%O` to disable representation of non-enumerable properties: | ||
``` javascript | ||
assert.eql("With non-enumerable properties: [ 1, 2, 3, 4, 5, [length]: 5 ]", | ||
printf('With non-enumerable properties: %O', [1, 2, 3, 4, 5]) | ||
); | ||
assert.eql("Without non-enumerable properties: [ 1, 2, 3, 4, 5 ]", | ||
printf('Without non-enumerable properties: %A', [1, 2, 3, 4, 5]) | ||
); | ||
``` | ||
### Argument mapping | ||
@@ -134,2 +157,3 @@ | ||
``` | ||
[![Build Status](https://secure.travis-ci.org/wdavidw/node-printf.png)](http://travis-ci.org/wdavidw/node-printf) | ||
@@ -147,11 +171,29 @@ ### Positionals | ||
## Test | ||
Development | ||
----------- | ||
Using [Expresso][expresso]: | ||
Tests are executed with mocha. To install it, simple run `npm install`, it will install | ||
mocha and its dependencies in your project "node_modules" directory. | ||
``` bash | ||
expresso | ||
To run the tests: | ||
```bash | ||
npm test | ||
``` | ||
To generate the JavaScript files: | ||
```bash | ||
make build | ||
``` | ||
The test suite is run online with [Travis][travis] against Node.js version 0.6, 0.7, 0.8 and 0.9. | ||
Contributors | ||
------------ | ||
* David Worms: <https://github.com/wdavidw> | ||
* Aluísio Augusto Silva Gonçalves <https://github.com/AluisioASG> | ||
* Xavier Mendez <https://github.com/jmendeth> | ||
* LLeo <https://github.com/lleo> | ||
[dojo]: http://www.dojotoolkit.org "The Dojo Toolkit" | ||
@@ -158,0 +200,0 @@ [node]: http://nodejs.org "The Node.JS platform" |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
99289
9
437
197
0