diff --git a/src/sprintf.js b/src/sprintf.js index 65d6324..eb77a68 100644 --- a/src/sprintf.js +++ b/src/sprintf.js @@ -26,6 +26,13 @@ return sprintf_format(sprintf_parse(key), arguments) } + Object.defineProperty(sprintf, 'parse', { + value: sprintf_parse, + configurable: true, + enumerable: false, + writable: true + }) + function vsprintf(fmt, argv) { return sprintf.apply(null, [fmt].concat(argv || [])) } diff --git a/test/test.js b/test/test.js index 9588da6..eb0f0c7 100644 --- a/test/test.js +++ b/test/test.js @@ -109,4 +109,20 @@ describe('sprintfjs', function() { it('should return formated strings for callbacks', function() { assert.equal('foobar', sprintf('%s', function() { return 'foobar' })) }) + + it('should return parsed tree', function() { + assert.deepEqual([ + { + placeholder: '%s', + param_no: undefined, + keys: undefined, + sign: undefined, + pad_char: undefined, + align: undefined, + width: undefined, + precision: undefined, + type: 's' + } + ], sprintf.parse('%s')) + }) })