import * as crypto from "crypto"
import * as vm from "vm"
export function indentForward(str) {
    if (!str) return ""
    let indent = "   "
    return indent + str.replace(/\n/ig, "\n" + indent).replace(/\n\s*\n/g, "\n\n")
}
export function hash(str: string | Buffer) {
    return crypto.createHash("md5").update(str).digest("hex")
}
export function parseLooseJSON(str: string | Buffer) {
    let ctx = vm.createContext()
    ctx["exports"] = null
    ctx["module"] = { exports: ctx["exports"] }
    let result = vm.runInContext("(" + str.toString() + ")", ctx)
    if (ctx["exports"]) {
        return ctx["exports"]
    }
    return result
}
