lakutata
Version:
An IoC-based universal application framework.
419 lines (405 loc) • 13.5 kB
JavaScript
;
Object.defineProperty(exports, Symbol.toStringTag, {
value: "Module"
});
const r = require("../../../vendor/Package.5.cjs");
require("../../../vendor/Package.15.cjs");
const t = require("crypto");
const e = r => r && r.__esModule ? r : {
default: r
};
const n = e(t);
var i = {
exports: {}
};
var o = i.exports;
(function(r, t) {
"use strict";
var e = n.default;
t = r.exports = i;
function i(r, t) {
t = a(r, t);
return c(r, t);
}
t.sha1 = function(r) {
return i(r);
};
t.keys = function(r) {
return i(r, {
excludeValues: true,
algorithm: "sha1",
encoding: "hex"
});
};
t.MD5 = function(r) {
return i(r, {
algorithm: "md5",
encoding: "hex"
});
};
t.keysMD5 = function(r) {
return i(r, {
algorithm: "md5",
encoding: "hex",
excludeValues: true
});
};
var o = e.getHashes ? e.getHashes().slice() : [ "sha1", "md5" ];
o.push("passthrough");
var u = [ "buffer", "hex", "binary", "base64" ];
function a(r, t) {
t = t || {};
var e = {};
e.algorithm = t.algorithm || "sha1";
e.encoding = t.encoding || "hex";
e.excludeValues = t.excludeValues ? true : false;
e.algorithm = e.algorithm.toLowerCase();
e.encoding = e.encoding.toLowerCase();
e.ignoreUnknown = t.ignoreUnknown !== true ? false : true;
e.respectType = t.respectType === false ? false : true;
e.respectFunctionNames = t.respectFunctionNames === false ? false : true;
e.respectFunctionProperties = t.respectFunctionProperties === false ? false : true;
e.unorderedArrays = t.unorderedArrays !== true ? false : true;
e.unorderedSets = t.unorderedSets === false ? false : true;
e.unorderedObjects = t.unorderedObjects === false ? false : true;
e.replacer = t.replacer || undefined;
e.excludeKeys = t.excludeKeys || undefined;
if (typeof r === "undefined") {
throw new Error("Object argument required.");
}
for (var n = 0; n < o.length; ++n) {
if (o[n].toLowerCase() === e.algorithm.toLowerCase()) {
e.algorithm = o[n];
}
}
if (o.indexOf(e.algorithm) === -1) {
throw new Error('Algorithm "' + e.algorithm + '" not supported. ' + "supported values: " + o.join(", "));
}
if (u.indexOf(e.encoding) === -1 && e.algorithm !== "passthrough") {
throw new Error('Encoding "' + e.encoding + '" not supported. ' + "supported values: " + u.join(", "));
}
return e;
}
function s(r) {
if (typeof r !== "function") {
return false;
}
var t = /^function\s+\w*\s*\(\s*\)\s*{\s+\[native code\]\s+}$/i;
return t.exec(Function.prototype.toString.call(r)) != null;
}
function c(r, t) {
var n;
if (t.algorithm !== "passthrough") {
n = e.createHash(t.algorithm);
} else {
n = new l;
}
if (typeof n.write === "undefined") {
n.write = n.update;
n.end = n.update;
}
var i = f(t, n);
i.dispatch(r);
if (!n.update) {
n.end("");
}
if (n.digest) {
return n.digest(t.encoding === "buffer" ? undefined : t.encoding);
}
var o = n.read();
if (t.encoding === "buffer") {
return o;
}
return o.toString(t.encoding);
}
t.writeToStream = function(r, t, e) {
if (typeof e === "undefined") {
e = t;
t = {};
}
t = a(r, t);
return f(t, e).dispatch(r);
};
function f(r, t, e) {
e = e || [];
var n = function(r) {
if (t.update) {
return t.update(r, "utf8");
} else {
return t.write(r, "utf8");
}
};
return {
dispatch: function(t) {
if (r.replacer) {
t = r.replacer(t);
}
var e = typeof t;
if (t === null) {
e = "null";
}
return this["_" + e](t);
},
_object: function(t) {
var i = /\[object (.*)\]/i;
var o = Object.prototype.toString.call(t);
var u = i.exec(o);
if (!u) {
u = "unknown:[" + o + "]";
} else {
u = u[1];
}
u = u.toLowerCase();
var a = null;
if ((a = e.indexOf(t)) >= 0) {
return this.dispatch("[CIRCULAR:" + a + "]");
} else {
e.push(t);
}
if (typeof Buffer !== "undefined" && Buffer.isBuffer && Buffer.isBuffer(t)) {
n("buffer:");
return n(t);
}
if (u !== "object" && u !== "function" && u !== "asyncfunction") {
if (this["_" + u]) {
this["_" + u](t);
} else if (r.ignoreUnknown) {
return n("[" + u + "]");
} else {
throw new Error('Unknown object type "' + u + '"');
}
} else {
var c = Object.keys(t);
if (r.unorderedObjects) {
c = c.sort();
}
if (r.respectType !== false && !s(t)) {
c.splice(0, 0, "prototype", "__proto__", "constructor");
}
if (r.excludeKeys) {
c = c.filter((function(t) {
return !r.excludeKeys(t);
}));
}
n("object:" + c.length + ":");
var f = this;
return c.forEach((function(e) {
f.dispatch(e);
n(":");
if (!r.excludeValues) {
f.dispatch(t[e]);
}
n(",");
}));
}
},
_array: function(t, i) {
i = typeof i !== "undefined" ? i : r.unorderedArrays !== false;
var o = this;
n("array:" + t.length + ":");
if (!i || t.length <= 1) {
return t.forEach((function(r) {
return o.dispatch(r);
}));
}
var u = [];
var a = t.map((function(t) {
var n = new l;
var i = e.slice();
var o = f(r, n, i);
o.dispatch(t);
u = u.concat(i.slice(e.length));
return n.read().toString();
}));
e = e.concat(u);
a.sort();
return this._array(a, false);
},
_date: function(r) {
return n("date:" + r.toJSON());
},
_symbol: function(r) {
return n("symbol:" + r.toString());
},
_error: function(r) {
return n("error:" + r.toString());
},
_boolean: function(r) {
return n("bool:" + r.toString());
},
_string: function(r) {
n("string:" + r.length + ":");
n(r.toString());
},
_function: function(t) {
n("fn:");
if (s(t)) {
this.dispatch("[native]");
} else {
this.dispatch(t.toString());
}
if (r.respectFunctionNames !== false) {
this.dispatch("function-name:" + String(t.name));
}
if (r.respectFunctionProperties) {
this._object(t);
}
},
_number: function(r) {
return n("number:" + r.toString());
},
_xml: function(r) {
return n("xml:" + r.toString());
},
_null: function() {
return n("Null");
},
_undefined: function() {
return n("Undefined");
},
_regexp: function(r) {
return n("regex:" + r.toString());
},
_uint8array: function(r) {
n("uint8array:");
return this.dispatch(Array.prototype.slice.call(r));
},
_uint8clampedarray: function(r) {
n("uint8clampedarray:");
return this.dispatch(Array.prototype.slice.call(r));
},
_int8array: function(r) {
n("int8array:");
return this.dispatch(Array.prototype.slice.call(r));
},
_uint16array: function(r) {
n("uint16array:");
return this.dispatch(Array.prototype.slice.call(r));
},
_int16array: function(r) {
n("int16array:");
return this.dispatch(Array.prototype.slice.call(r));
},
_uint32array: function(r) {
n("uint32array:");
return this.dispatch(Array.prototype.slice.call(r));
},
_int32array: function(r) {
n("int32array:");
return this.dispatch(Array.prototype.slice.call(r));
},
_float32array: function(r) {
n("float32array:");
return this.dispatch(Array.prototype.slice.call(r));
},
_float64array: function(r) {
n("float64array:");
return this.dispatch(Array.prototype.slice.call(r));
},
_arraybuffer: function(r) {
n("arraybuffer:");
return this.dispatch(new Uint8Array(r));
},
_url: function(r) {
return n("url:" + r.toString(), "utf8");
},
_map: function(t) {
n("map:");
var e = Array.from(t);
return this._array(e, r.unorderedSets !== false);
},
_set: function(t) {
n("set:");
var e = Array.from(t);
return this._array(e, r.unorderedSets !== false);
},
_file: function(r) {
n("file:");
return this.dispatch([ r.name, r.size, r.type, r.lastModfied ]);
},
_blob: function() {
if (r.ignoreUnknown) {
return n("[blob]");
}
throw Error("Hashing Blob objects is currently not supported\n" + "(see https://github.com/puleos/object-hash/issues/26)\n" + 'Use "options.replacer" or "options.ignoreUnknown"\n');
},
_domwindow: function() {
return n("domwindow");
},
_bigint: function(r) {
return n("bigint:" + r.toString());
},
_process: function() {
return n("process");
},
_timer: function() {
return n("timer");
},
_pipe: function() {
return n("pipe");
},
_tcp: function() {
return n("tcp");
},
_udp: function() {
return n("udp");
},
_tty: function() {
return n("tty");
},
_statwatcher: function() {
return n("statwatcher");
},
_securecontext: function() {
return n("securecontext");
},
_connection: function() {
return n("connection");
},
_zlib: function() {
return n("zlib");
},
_context: function() {
return n("context");
},
_nodescript: function() {
return n("nodescript");
},
_httpparser: function() {
return n("httpparser");
},
_dataview: function() {
return n("dataview");
},
_signal: function() {
return n("signal");
},
_fsevent: function() {
return n("fsevent");
},
_tlswrap: function() {
return n("tlswrap");
}
};
}
function l() {
return {
buf: "",
write: function(r) {
this.buf += r;
},
end: function(r) {
this.buf += r;
},
read: function() {
return this.buf;
}
};
}
})(i, i.exports);
var u = i.exports;
const a = r.getDefaultExportFromCjs(u);
function s(r, t) {
return a(r, t);
}
exports.ObjectHash = s;