Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/sprintf.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 || []))
}
Expand Down
16 changes: 16 additions & 0 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'))
})
})