Skip to content

Commit

Permalink
fix: Standardize the interface of the "jsonlint/lib/formatter" module
Browse files Browse the repository at this point in the history
BREAKING CHANGE: The formatting method is exposed not as exports.formatter.formatJson, but as exports.format.
This module is not documented and it is unlikely, that it broke other project.
  • Loading branch information
prantlf committed May 19, 2019
1 parent cffa07c commit b8b041b
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions lib/formatter.js
@@ -1,19 +1,16 @@
#!/usr/bin/env node

/**
* Manual formatter taken straight from https://github.com/umbrae/jsonlintdotcom
**/

/**
* jsl.format - Provide json reformatting in a character-by-character approach, so that even invalid JSON may be reformatted (to the best of its ability).
*
**/
* jsl.format - Provide json reformatting in a character-by-character approach,
* so that even invalid JSON may be reformatted (to the best of its ability).
*
*/
var formatter = (function () {
function repeat (s, count) {
return new Array(count + 1).join(s)
}

function formatJson (json, indentChars) {
function format (json, indentChars) {
var i = 0
var il = 0
var tab = (typeof indentChars !== 'undefined') ? indentChars : ' '
Expand Down Expand Up @@ -79,9 +76,9 @@ var formatter = (function () {
return newJson
}

return { 'formatJson': formatJson }
return { format: format }
}())

if (typeof require !== 'undefined' && typeof exports !== 'undefined') {
exports.formatter = formatter
exports.format = formatter.format
}

0 comments on commit b8b041b

Please sign in to comment.