@esfaenza/extensions 11.2.7 → 11.2.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bundles/esfaenza-extensions.umd.js +39 -10
- package/bundles/esfaenza-extensions.umd.js.map +1 -1
- package/bundles/esfaenza-extensions.umd.min.js +1 -1
- package/bundles/esfaenza-extensions.umd.min.js.map +1 -1
- package/esfaenza-extensions.metadata.json +1 -1
- package/esm2015/lib/services/extensions.hashing.service.js +39 -11
- package/fesm2015/esfaenza-extensions.js +38 -10
- package/fesm2015/esfaenza-extensions.js.map +1 -1
- package/lib/services/extensions.hashing.service.d.ts +15 -3
- package/package.json +1 -1
|
@@ -1268,8 +1268,11 @@
|
|
|
1268
1268
|
/**
|
|
1269
1269
|
* Blacklist dei tipi da ignorare quando si effettua l'hashing degli oggetti
|
|
1270
1270
|
*/
|
|
1271
|
-
this.
|
|
1272
|
-
"
|
|
1271
|
+
this.objBlacklist = {
|
|
1272
|
+
"NgForm": true, "ElementRef": true, "ExtensionsService": true, "ToastrService": true, "LocaleService": true, "AppState": true, "Router": true,
|
|
1273
|
+
"ActivatedRoute": true, "HTTPService": true, "Location": true, "CanvasComponent": true, "ModalDirective": true, "ChangeDetectorRef": true,
|
|
1274
|
+
"DateService": true, "EventEmitter": true, "ViewRef_": true, "Subscriber": true, "ItemLocalization": true
|
|
1275
|
+
};
|
|
1273
1276
|
/**
|
|
1274
1277
|
* Array dei possibili valori di un simbolo esadecimale
|
|
1275
1278
|
*/
|
|
@@ -1293,14 +1296,40 @@
|
|
|
1293
1296
|
* @param {number} level Livello di ricorsione nel caso venga effettuato l'hash di un oggetto che contiene altri oggetti
|
|
1294
1297
|
* @param {boolean} navigateFullDepth Indica se navigare l'oggetto per l'intera lunghezza. In caso contrario si ferma al secondo livello
|
|
1295
1298
|
*
|
|
1296
|
-
* @returns {string}
|
|
1299
|
+
* @returns {string} Hash generato per l'oggetto in questione
|
|
1297
1300
|
*/
|
|
1298
|
-
HashingService.prototype.hashObject = function (o, level, navigateFullDepth) {
|
|
1301
|
+
HashingService.prototype.hashObject = function (o, level, navigateFullDepth, precise) {
|
|
1299
1302
|
if (level === void 0) { level = 0; }
|
|
1300
1303
|
if (navigateFullDepth === void 0) { navigateFullDepth = false; }
|
|
1304
|
+
if (precise === void 0) { precise = false; }
|
|
1301
1305
|
var strDef = this.stringify(o, level, navigateFullDepth);
|
|
1302
|
-
var
|
|
1303
|
-
return
|
|
1306
|
+
var hash = precise ? this.md5(strDef) : this.superSimpleHash(strDef);
|
|
1307
|
+
return hash;
|
|
1308
|
+
};
|
|
1309
|
+
/**
|
|
1310
|
+
* Hash più semplice e più veloce dell'md5, ma meno sicuro... vediamo come va
|
|
1311
|
+
*
|
|
1312
|
+
* @param {string} str Stringa di cui calcolare l'hash
|
|
1313
|
+
*/
|
|
1314
|
+
HashingService.prototype.simpleHash = function (str) {
|
|
1315
|
+
var hash = 0;
|
|
1316
|
+
for (var i = 0; i < str.length; i++) {
|
|
1317
|
+
var char = str.charCodeAt(i);
|
|
1318
|
+
hash = (hash << 5) - hash + char;
|
|
1319
|
+
hash &= hash; // Convert to 32bit integer
|
|
1320
|
+
}
|
|
1321
|
+
return new Uint32Array([hash])[0].toString(36);
|
|
1322
|
+
};
|
|
1323
|
+
/**
|
|
1324
|
+
* Hash più semplice e più veloce dell'md5, ma meno sicuro... vediamo come va
|
|
1325
|
+
*
|
|
1326
|
+
* @param {string} str Stringa di cui calcolare l'hash
|
|
1327
|
+
*/
|
|
1328
|
+
HashingService.prototype.superSimpleHash = function (str) {
|
|
1329
|
+
var h, i;
|
|
1330
|
+
for (i = 0, h = 0; i < str.length; i++)
|
|
1331
|
+
h = Math.imul(31, h) + str.charCodeAt(i) | 0;
|
|
1332
|
+
return h.toString();
|
|
1304
1333
|
};
|
|
1305
1334
|
/**
|
|
1306
1335
|
* Genera una stringa che identifica univocamente l'oggetto in questione
|
|
@@ -1318,14 +1347,14 @@
|
|
|
1318
1347
|
if (o === false)
|
|
1319
1348
|
return "f";
|
|
1320
1349
|
if (o instanceof Date)
|
|
1321
|
-
return
|
|
1350
|
+
return 'd:' + o.valueOf().toString();
|
|
1322
1351
|
i = typeof o;
|
|
1323
1352
|
if (i === "string")
|
|
1324
|
-
return "s:" + o
|
|
1353
|
+
return "s:" + o;
|
|
1325
1354
|
if (i === "number")
|
|
1326
1355
|
return "n:" + o;
|
|
1327
1356
|
if (o instanceof Function)
|
|
1328
|
-
return "m:" + o.toString()
|
|
1357
|
+
return "m:" + o.toString();
|
|
1329
1358
|
if (o instanceof Array) {
|
|
1330
1359
|
r = [];
|
|
1331
1360
|
for (i = 0; i < o.length; i++) {
|
|
@@ -1339,7 +1368,7 @@
|
|
|
1339
1368
|
//Se è oggetto, escludo tutti quelli di sistema/inutili
|
|
1340
1369
|
if (o) {
|
|
1341
1370
|
var name = o.__proto__.constructor.name;
|
|
1342
|
-
if (this.
|
|
1371
|
+
if (!this.objBlacklist[name]) {
|
|
1343
1372
|
for (i in o) {
|
|
1344
1373
|
if (o.hasOwnProperty(i) && (level <= 2 || navigateFullDepth)) {
|
|
1345
1374
|
var res = this.stringify(o[i], level + 1, navigateFullDepth);
|