<commit_before>var util = require('util'),
    _ = require('underscore'),
    error = require('../error'),
    memoizeAsyncAccessor = require('../memoizeAsyncAccessor'),
    Base = require('./Base');

function _JSON(config) { // Avoid clobbering the global JSON object
    Base.call(this, config);
}

util.inherits(_JSON, Base);

_.extend(_JSON.prototype, {
    contentType: 'application/json',

    defaultExtension: 'json',

    isPretty: false,

    getParseTree: memoizeAsyncAccessor('parseTree', function (cb) {
        var that = this;
        this.getDecodedSrc(error.passToFunction(cb, function (decodedSrc) {
            cb(null, JSON.parse(decodedSrc));
        }));
    }),

    prettyPrint: function (cb) {
        this.isPretty = true;
        process.nextTick(cb);
    },

    minify: function (cb) {
        this.isPretty = false;
        process.nextTick(cb);
    },

    getText: function (cb) {
        var that = this;
        that.getParseTree(error.passToFunction(cb, function (parseTree) {
            var jsonString;
            if (that.isPretty) {
                jsonString = JSON.stringify(parseTree, undefined, "    ") + "\n";
            } else {
                jsonString = JSON.stringify(parseTree);
            }
            cb(null, jsonString);
        }));
    }
});

module.exports = _JSON;
<commit_msg>Whoops, assets.JSON should inherit from assets.Text.<commit_after>var util = require('util'),
    _ = require('underscore'),
    error = require('../error'),
    memoizeAsyncAccessor = require('../memoizeAsyncAccessor'),
    Text = require('./Text');

function _JSON(config) { // Avoid clobbering the global JSON object
    Text.call(this, config);
}

util.inherits(_JSON, Text);

_.extend(_JSON.prototype, {
    contentType: 'application/json',

    defaultExtension: 'json',

    isPretty: false,

    getParseTree: memoizeAsyncAccessor('parseTree', function (cb) {
        var that = this;
        this.getDecodedSrc(error.passToFunction(cb, function (decodedSrc) {
            cb(null, JSON.parse(decodedSrc));
        }));
    }),

    prettyPrint: function (cb) {
        this.isPretty = true;
        process.nextTick(cb);
    },

    minify: function (cb) {
        this.isPretty = false;
        process.nextTick(cb);
    },

    getText: function (cb) {
        var that = this;
        that.getParseTree(error.passToFunction(cb, function (parseTree) {
            var jsonString;
            if (that.isPretty) {
                jsonString = JSON.stringify(parseTree, undefined, "    ") + "\n";
            } else {
                jsonString = JSON.stringify(parseTree);
            }
            cb(null, jsonString);
        }));
    }
});

module.exports = _JSON;

{'fraction_non_alphanumeric': 0.13828613460831188, 'fraction_numerical': 0.0, 'mean_word_length': 2.3292533659730723, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4467822', 'n_tokens_mistral': 816, 'n_tokens_neox': 793, 'n_words': 159}