(function(global,factory){typeof exports==="object"&&typeof module!=="undefined"?factory(exports):typeof define==="function"&&define.amd?define("jsonlint-printer",["exports"],factory):(global=global||self,factory(global.jsonlintPrinter={}))})(this,function(exports){"use strict";function noop(){}function isIdentifierName(value){return/^[a-zA-Z$_][a-zA-Z0-9$_]*$/.test(value)}function concatenateTokens(tokens){var outputString="";var tokenCount=tokens.length;var tokenIndex;for(tokenIndex=0;tokenIndex0){addLineBreak();addIndent()}outputString+=tokenContent;foundLineBreak=false;addedLineBreak=false;needsLineBreak=true};tryAddingInlineComment=function(){foundLineBreak=false;addedLineBreak=false;addedSpace=false;var tryTokenIndex=tokenIndex+1;function skipWhitespace(){var token=tokens[tryTokenIndex];if(token&&token.type==="whitespace"){foundLineBreak=token.raw.indexOf("\n")>=0;token=tokens[++tryTokenIndex]}return token}var token=skipWhitespace();if(!foundLineBreak&&token&&token.type==="comment"){if(needsLineBreak){if(!addedLineBreak){addLineBreak();addIndent()}}else{if(!addedSpace){outputString+=" "}}outputString+=token.raw;tokenIndex=tryTokenIndex++;skipWhitespace();if(foundLineBreak){needsSpace=false;needsLineBreak=true}else{needsSpace=true;needsLineBreak=false}}}}else{addStandaloneComment=function(){if(tokenContent[1]==="/"){outputString+="/*";outputString+=tokenContent.substr(2,tokenContent.length-2);outputString+=" */"}else{outputString+=tokenContent}};tryAddingInlineComment=noop}}function addLiteral(){addDelayedSpaceOrLineBreak();var tokenValue=token.value;if(stripObjectKeys&&scopeType==="{"&&!isValue&&isIdentifierName(tokenValue)){outputString+=tokenValue}else if(typeof tokenValue==="string"){if(enforceDoubleQuotes&&tokenContent[0]!=='"'){outputString+=JSON.stringify(tokenValue)}else if(enforceSingleQuotes&&tokenContent[0]!=="'"){outputString+="'"+tokenValue.replace(/'/g,"\\'")+"'"}else{outputString+=tokenContent}}else{outputString+=tokenContent}tryAddingInlineComment()}function openScope(){addDelayedSpaceOrLineBreak();scopes.push(scopeType);scopeType=tokenContent;isValue=scopeType==="[";outputString+=tokenContent;tryAddingInlineComment();++indentLevel;needsLineBreak=true}function closeScope(){scopeType=scopes.pop();addLineBreak();--indentLevel;addIndent();needsSpace=needsLineBreak=false;outputString+=tokenContent;tryAddingInlineComment()}function addComma(){if(trimTrailingCommas){var nextToken=peekAtNextToken();if(nextToken&&nextToken.type==="symbol"){return tryAddingInlineComment()}}addDelayedSpaceOrLineBreak();outputString+=",";tryAddingInlineComment();addLineBreak();addIndent();addedLineBreak=true;needsLineBreak=false;isValue=scopeType==="["}function addColon(){addDelayedSpaceOrLineBreak();outputString+=":";needsSpace=true;tryAddingInlineComment();isValue=true}for(tokenIndex=0;tokenIndex=0}}return outputString}exports.print=print;Object.defineProperty(exports,"__esModule",{value:true})}); //# sourceMappingURL=printer.min.js.map