@thumbmarkjs/thumbmarkjs 0.12.1

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.
Files changed (78) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +95 -0
  3. package/dist/components/audio/audio.d.ts +1 -0
  4. package/dist/components/audio/audio.js +91 -0
  5. package/dist/components/audio/audio.js.map +1 -0
  6. package/dist/components/canvas/canvas.d.ts +2 -0
  7. package/dist/components/canvas/canvas.js +71 -0
  8. package/dist/components/canvas/canvas.js.map +1 -0
  9. package/dist/components/canvas/canvas.test.d.ts +1 -0
  10. package/dist/components/canvas/canvas.test.js +32 -0
  11. package/dist/components/canvas/canvas.test.js.map +1 -0
  12. package/dist/components/fonts/fonts.d.ts +2 -0
  13. package/dist/components/fonts/fonts.js +179 -0
  14. package/dist/components/fonts/fonts.js.map +1 -0
  15. package/dist/components/hardware/hardware.d.ts +1 -0
  16. package/dist/components/hardware/hardware.js +37 -0
  17. package/dist/components/hardware/hardware.js.map +1 -0
  18. package/dist/components/index.d.ts +16 -0
  19. package/dist/components/index.js +19 -0
  20. package/dist/components/index.js.map +1 -0
  21. package/dist/components/locales/locales.d.ts +1 -0
  22. package/dist/components/locales/locales.js +20 -0
  23. package/dist/components/locales/locales.js.map +1 -0
  24. package/dist/components/math/math.d.ts +1 -0
  25. package/dist/components/math/math.js +76 -0
  26. package/dist/components/math/math.js.map +1 -0
  27. package/dist/components/permissions/permissions.d.ts +2 -0
  28. package/dist/components/permissions/permissions.js +109 -0
  29. package/dist/components/permissions/permissions.js.map +1 -0
  30. package/dist/components/plugins/plugins.d.ts +2 -0
  31. package/dist/components/plugins/plugins.js +20 -0
  32. package/dist/components/plugins/plugins.js.map +1 -0
  33. package/dist/components/screen/screen.d.ts +1 -0
  34. package/dist/components/screen/screen.js +44 -0
  35. package/dist/components/screen/screen.js.map +1 -0
  36. package/dist/components/system/browser.d.ts +6 -0
  37. package/dist/components/system/browser.js +47 -0
  38. package/dist/components/system/browser.js.map +1 -0
  39. package/dist/components/system/system.d.ts +1 -0
  40. package/dist/components/system/system.js +19 -0
  41. package/dist/components/system/system.js.map +1 -0
  42. package/dist/components/webgl/webgl.d.ts +1 -0
  43. package/dist/components/webgl/webgl.js +160 -0
  44. package/dist/components/webgl/webgl.js.map +1 -0
  45. package/dist/factory.d.ts +30 -0
  46. package/dist/factory.js +38 -0
  47. package/dist/factory.js.map +1 -0
  48. package/dist/fingerprint/functions.d.ts +6 -0
  49. package/dist/fingerprint/functions.js +122 -0
  50. package/dist/fingerprint/functions.js.map +1 -0
  51. package/dist/index.d.ts +8 -0
  52. package/dist/index.js +41 -0
  53. package/dist/index.js.map +1 -0
  54. package/dist/storage/getItem.d.ts +2 -0
  55. package/dist/storage/getItem.js +81 -0
  56. package/dist/storage/getItem.js.map +1 -0
  57. package/dist/storage/index.d.ts +3 -0
  58. package/dist/storage/index.js +8 -0
  59. package/dist/storage/index.js.map +1 -0
  60. package/dist/storage/setItem.d.ts +2 -0
  61. package/dist/storage/setItem.js +91 -0
  62. package/dist/storage/setItem.js.map +1 -0
  63. package/dist/utils/commonPixels.d.ts +1 -0
  64. package/dist/utils/commonPixels.js +37 -0
  65. package/dist/utils/commonPixels.js.map +1 -0
  66. package/dist/utils/ephemeralIFrame.d.ts +4 -0
  67. package/dist/utils/ephemeralIFrame.js +79 -0
  68. package/dist/utils/ephemeralIFrame.js.map +1 -0
  69. package/dist/utils/getMostFrequent.d.ts +5 -0
  70. package/dist/utils/getMostFrequent.js +36 -0
  71. package/dist/utils/getMostFrequent.js.map +1 -0
  72. package/dist/utils/hash.d.ts +1 -0
  73. package/dist/utils/hash.js +67 -0
  74. package/dist/utils/hash.js.map +1 -0
  75. package/dist/utils/raceAll.d.ts +9 -0
  76. package/dist/utils/raceAll.js +32 -0
  77. package/dist/utils/raceAll.js.map +1 -0
  78. package/package.json +39 -0
@@ -0,0 +1,122 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __generator = (this && this.__generator) || function (thisArg, body) {
12
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
+ function verb(n) { return function (v) { return step([n, v]); }; }
15
+ function step(op) {
16
+ if (f) throw new TypeError("Generator is already executing.");
17
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
18
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
+ if (y = 0, t) op = [op[0] & 2, t.value];
20
+ switch (op[0]) {
21
+ case 0: case 1: t = op; break;
22
+ case 4: _.label++; return { value: op[1], done: false };
23
+ case 5: _.label++; y = op[1]; op = [0]; continue;
24
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
+ default:
26
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
+ if (t[2]) _.ops.pop();
31
+ _.trys.pop(); continue;
32
+ }
33
+ op = body.call(thisArg, _);
34
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
+ }
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.getFingerprintPerformance = exports.getFingerprint = exports.getFingerprintData = void 0;
40
+ var factory_1 = require("../factory");
41
+ var hash_1 = require("../utils/hash");
42
+ var raceAll_1 = require("../utils/raceAll");
43
+ var _TIMEOUT = 1000;
44
+ function getFingerprintData() {
45
+ return __awaiter(this, void 0, void 0, function () {
46
+ var promiseMap, keys_1, promises, resolvedValues, resolvedComponents_1, error_1;
47
+ return __generator(this, function (_a) {
48
+ switch (_a.label) {
49
+ case 0:
50
+ _a.trys.push([0, 2, , 3]);
51
+ promiseMap = (0, factory_1.getComponentPromises)();
52
+ keys_1 = Object.keys(promiseMap);
53
+ promises = Object.values(promiseMap);
54
+ return [4 /*yield*/, (0, raceAll_1.raceAll)(promises, _TIMEOUT, factory_1.timeoutInstance)];
55
+ case 1:
56
+ resolvedValues = _a.sent();
57
+ resolvedComponents_1 = {};
58
+ resolvedValues.forEach(function (value, index) {
59
+ resolvedComponents_1[keys_1[index]] = value;
60
+ });
61
+ return [2 /*return*/, resolvedComponents_1];
62
+ case 2:
63
+ error_1 = _a.sent();
64
+ throw error_1;
65
+ case 3: return [2 /*return*/];
66
+ }
67
+ });
68
+ });
69
+ }
70
+ exports.getFingerprintData = getFingerprintData;
71
+ function getFingerprint() {
72
+ return __awaiter(this, void 0, void 0, function () {
73
+ var fingerprintData, thisHash, error_2;
74
+ return __generator(this, function (_a) {
75
+ switch (_a.label) {
76
+ case 0:
77
+ _a.trys.push([0, 2, , 3]);
78
+ return [4 /*yield*/, getFingerprintData()];
79
+ case 1:
80
+ fingerprintData = _a.sent();
81
+ thisHash = (0, hash_1.hash)(JSON.stringify(fingerprintData));
82
+ return [2 /*return*/, thisHash.toString()];
83
+ case 2:
84
+ error_2 = _a.sent();
85
+ throw error_2;
86
+ case 3: return [2 /*return*/];
87
+ }
88
+ });
89
+ });
90
+ }
91
+ exports.getFingerprint = getFingerprint;
92
+ function getFingerprintPerformance() {
93
+ return __awaiter(this, void 0, void 0, function () {
94
+ var promiseMap, keys_2, promises, resolvedValues, resolvedComponents_2, error_3;
95
+ return __generator(this, function (_a) {
96
+ switch (_a.label) {
97
+ case 0:
98
+ _a.trys.push([0, 2, , 3]);
99
+ promiseMap = (0, factory_1.getComponentPromises)();
100
+ keys_2 = Object.keys(promiseMap);
101
+ promises = Object.values(promiseMap);
102
+ return [4 /*yield*/, (0, raceAll_1.raceAllPerformance)(promises, _TIMEOUT, factory_1.timeoutInstance)];
103
+ case 1:
104
+ resolvedValues = _a.sent();
105
+ resolvedComponents_2 = {
106
+ elapsed: {}
107
+ };
108
+ resolvedValues.forEach(function (value, index) {
109
+ resolvedComponents_2[keys_2[index]] = value.value;
110
+ resolvedComponents_2["elapsed"][keys_2[index]] = value.elapsed;
111
+ });
112
+ return [2 /*return*/, resolvedComponents_2];
113
+ case 2:
114
+ error_3 = _a.sent();
115
+ throw error_3;
116
+ case 3: return [2 /*return*/];
117
+ }
118
+ });
119
+ });
120
+ }
121
+ exports.getFingerprintPerformance = getFingerprintPerformance;
122
+ //# sourceMappingURL=functions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"functions.js","sourceRoot":"","sources":["../../src/fingerprint/functions.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,sCAAuF;AACvF,sCAAqC;AACrC,4CAA8D;AAE9D,IAAM,QAAQ,GAAW,IAAI,CAAA;AAE7B,SAAsB,kBAAkB;;;;;;;oBAE1B,UAAU,GAAG,IAAA,8BAAoB,GAAE,CAAC;oBACpC,SAAO,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;oBAC/B,QAAQ,GAAG,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;oBACpB,qBAAM,IAAA,iBAAO,EAAC,QAAQ,EAAE,QAAQ,EAAE,yBAAe,CAAE,EAAA;;oBAApE,cAAc,GAAG,SAAmD;oBACpE,uBAA6C,EAAE,CAAC;oBACtD,cAAc,CAAC,OAAO,CAAC,UAAC,KAAK,EAAE,KAAK;wBAChC,oBAAkB,CAAC,MAAI,CAAC,KAAK,CAAC,CAAC,GAAG,KAAK,CAAC;oBAC5C,CAAC,CAAC,CAAC;oBACH,sBAAO,oBAAkB,EAAC;;;oBAG1B,MAAM,OAAK,CAAC;;;;;CAEnB;AAfD,gDAeC;AAED,SAAsB,cAAc;;;;;;;oBAEJ,qBAAM,kBAAkB,EAAE,EAAA;;oBAA5C,eAAe,GAAG,SAA0B;oBAC5C,QAAQ,GAAG,IAAA,WAAI,EAAC,IAAI,CAAC,SAAS,CAAC,eAAe,CAAC,CAAC,CAAC;oBACvD,sBAAO,QAAQ,CAAC,QAAQ,EAAE,EAAC;;;oBAE3B,MAAM,OAAK,CAAC;;;;;CAEnB;AARD,wCAQC;AAED,SAAsB,yBAAyB;;;;;;;oBAEjC,UAAU,GAAG,IAAA,8BAAoB,GAAE,CAAC;oBACpC,SAAO,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;oBAC/B,QAAQ,GAAG,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;oBACpB,qBAAM,IAAA,4BAAkB,EAAC,QAAQ,EAAE,QAAQ,EAAE,yBAAe,CAAE,EAAA;;oBAA/E,cAAc,GAAG,SAA8D;oBAC/E,uBAA6C;wBAC/C,OAAO,EAAE,EAAE;qBACd,CAAA;oBACD,cAAc,CAAC,OAAO,CAAC,UAAC,KAAK,EAAE,KAAK;wBAChC,oBAAkB,CAAC,MAAI,CAAC,KAAK,CAAC,CAAC,GAAG,KAAK,CAAC,KAAK,CAAC;wBAC9C,oBAAkB,CAAC,SAAS,CAAC,CAAC,MAAI,CAAC,KAAK,CAAC,CAAC,GAAG,KAAK,CAAC,OAAO,CAAC;oBAC/D,CAAC,CAAC,CAAC;oBACH,sBAAO,oBAAkB,EAAC;;;oBAG1B,MAAM,OAAK,CAAC;;;;;CAEnB;AAlBD,8DAkBC"}
@@ -0,0 +1,8 @@
1
+ import { getFingerprint, getFingerprintData, getFingerprintPerformance } from './fingerprint/functions';
2
+ import './components';
3
+ interface fingerprintOptionsInterface {
4
+ showElapsed?: boolean;
5
+ }
6
+ declare const options: fingerprintOptionsInterface;
7
+ declare function getVersion(): string;
8
+ export { getVersion, getFingerprint, getFingerprintData, getFingerprintPerformance, options };
package/dist/index.js ADDED
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.options = exports.getFingerprintPerformance = exports.getFingerprintData = exports.getFingerprint = exports.getVersion = void 0;
27
+ var functions_1 = require("./fingerprint/functions");
28
+ Object.defineProperty(exports, "getFingerprint", { enumerable: true, get: function () { return functions_1.getFingerprint; } });
29
+ Object.defineProperty(exports, "getFingerprintData", { enumerable: true, get: function () { return functions_1.getFingerprintData; } });
30
+ Object.defineProperty(exports, "getFingerprintPerformance", { enumerable: true, get: function () { return functions_1.getFingerprintPerformance; } });
31
+ var packageJson = __importStar(require("../package.json"));
32
+ require("./components");
33
+ var options = {
34
+ showElapsed: false
35
+ };
36
+ exports.options = options;
37
+ function getVersion() {
38
+ return packageJson.version;
39
+ }
40
+ exports.getVersion = getVersion;
41
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qDAAwG;AAmBnF,+FAnBZ,0BAAc,OAmBY;AAAE,mGAnBZ,8BAAkB,OAmBY;AAAE,0GAnBZ,qCAAyB,OAmBY;AAlBlF,2DAA+C;AAC/C,wBAAqB;AASrB,IAAM,OAAO,GAAgC;IACzC,WAAW,EAAE,KAAK;CACrB,CAAA;AAMmF,0BAAO;AAJ3F,SAAS,UAAU;IACf,OAAO,WAAW,CAAC,OAAO,CAAC;AAC/B,CAAC;AAEQ,gCAAU"}
@@ -0,0 +1,2 @@
1
+ declare const getItem: (key: string) => Promise<string>;
2
+ export { getItem };
@@ -0,0 +1,81 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __generator = (this && this.__generator) || function (thisArg, body) {
12
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
+ function verb(n) { return function (v) { return step([n, v]); }; }
15
+ function step(op) {
16
+ if (f) throw new TypeError("Generator is already executing.");
17
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
18
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
+ if (y = 0, t) op = [op[0] & 2, t.value];
20
+ switch (op[0]) {
21
+ case 0: case 1: t = op; break;
22
+ case 4: _.label++; return { value: op[1], done: false };
23
+ case 5: _.label++; y = op[1]; op = [0]; continue;
24
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
+ default:
26
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
+ if (t[2]) _.ops.pop();
31
+ _.trys.pop(); continue;
32
+ }
33
+ op = body.call(thisArg, _);
34
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
+ }
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.getItem = void 0;
40
+ var index_1 = require("../index");
41
+ var getItem = function (key) { return __awaiter(void 0, void 0, void 0, function () {
42
+ var errors, storageUrl, namespace, fp, url;
43
+ return __generator(this, function (_a) {
44
+ switch (_a.label) {
45
+ case 0:
46
+ errors = validOptions(index_1.options);
47
+ if (errors) {
48
+ throw errors;
49
+ }
50
+ storageUrl = index_1.options.storageUrl, namespace = index_1.options.namespace;
51
+ return [4 /*yield*/, (0, index_1.getFingerprint)()];
52
+ case 1:
53
+ fp = _a.sent();
54
+ url = "".concat(storageUrl, "/").concat(namespace, "/").concat(fp, "/").concat(key);
55
+ return [2 /*return*/, fetch(url, {
56
+ method: 'GET',
57
+ })
58
+ .then(function (response) {
59
+ if (!response.ok) {
60
+ throw new Error("HTTP error! status: ".concat(response.status));
61
+ }
62
+ return response.json();
63
+ })
64
+ .catch(function (error) {
65
+ console.error('There was an error!', error);
66
+ })];
67
+ }
68
+ });
69
+ }); };
70
+ exports.getItem = getItem;
71
+ var validOptions = function (opt) {
72
+ var errors = [];
73
+ if (typeof opt.storageUrl !== 'string' || typeof opt.namespace !== 'string')
74
+ errors.push('storageUrl and namespace must be strings');
75
+ if (opt.namespace.length < 5)
76
+ errors.push('namespace must be at least 5 characters long');
77
+ if (errors.length > 0)
78
+ return new Error(errors.join(', '));
79
+ return null;
80
+ };
81
+ //# sourceMappingURL=getItem.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getItem.js","sourceRoot":"","sources":["../../src/storage/getItem.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,kCAA+E;AAG/E,IAAM,OAAO,GAAG,UAAO,GAAW;;;;;gBACxB,MAAM,GAAG,YAAY,CAAC,eAAO,CAAC,CAAA;gBACpC,IAAI,MAAM,EAAE,CAAC;oBAAC,MAAM,MAAM,CAAA;gBAAC,CAAC;gBACpB,UAAU,GAAgB,eAAO,WAAvB,EAAE,SAAS,GAAK,eAAO,UAAZ,CAAY;gBAC9B,qBAAM,IAAA,sBAAc,GAAE,EAAA;;gBAA3B,EAAE,GAAG,SAAsB;gBAC3B,GAAG,GAAG,UAAG,UAAU,cAAI,SAAS,cAAI,EAAE,cAAI,GAAG,CAAE,CAAA;gBAErD,sBAAO,KAAK,CAAC,GAAG,EAAE;wBACd,MAAM,EAAE,KAAK;qBAChB,CAAC;yBACD,IAAI,CAAC,UAAA,QAAQ;wBACV,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;4BACf,MAAM,IAAI,KAAK,CAAC,8BAAuB,QAAQ,CAAC,MAAM,CAAE,CAAC,CAAC;wBAC9D,CAAC;wBACD,OAAO,QAAQ,CAAC,IAAI,EAAE,CAAC;oBAC3B,CAAC,CAAC;yBACD,KAAK,CAAC,UAAA,KAAK;wBACR,OAAO,CAAC,KAAK,CAAC,qBAAqB,EAAE,KAAK,CAAC,CAAC;oBAChD,CAAC,CAAC,EAAC;;;KACN,CAAA;AAcQ,0BAAO;AAZhB,IAAM,YAAY,GAAG,UAAC,GAAgC;IAClD,IAAM,MAAM,GAAG,EAAE,CAAA;IACjB,IAAI,OAAO,GAAG,CAAC,UAAU,KAAK,QAAQ,IAAI,OAAO,GAAG,CAAC,SAAS,KAAK,QAAQ;QACvE,MAAM,CAAC,IAAI,CAAC,0CAA0C,CAAC,CAAA;IAC3D,IAAI,GAAG,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC;QACxB,MAAM,CAAC,IAAI,CAAC,8CAA8C,CAAC,CAAA;IAE/D,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC;QACjB,OAAO,IAAI,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAA;IACvC,OAAO,IAAI,CAAA;AACf,CAAC,CAAA"}
@@ -0,0 +1,3 @@
1
+ import { getItem } from './getItem';
2
+ import { setItem } from './setItem';
3
+ export { setItem, getItem };
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getItem = exports.setItem = void 0;
4
+ var getItem_1 = require("./getItem");
5
+ Object.defineProperty(exports, "getItem", { enumerable: true, get: function () { return getItem_1.getItem; } });
6
+ var setItem_1 = require("./setItem");
7
+ Object.defineProperty(exports, "setItem", { enumerable: true, get: function () { return setItem_1.setItem; } });
8
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/storage/index.ts"],"names":[],"mappings":";;;AAAA,qCAAmC;AAGjB,wFAHT,iBAAO,OAGS;AAFzB,qCAAmC;AAE1B,wFAFA,iBAAO,OAEA"}
@@ -0,0 +1,2 @@
1
+ declare const setItem: (key: string, value: string) => Promise<string>;
2
+ export { setItem };
@@ -0,0 +1,91 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __generator = (this && this.__generator) || function (thisArg, body) {
12
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
+ function verb(n) { return function (v) { return step([n, v]); }; }
15
+ function step(op) {
16
+ if (f) throw new TypeError("Generator is already executing.");
17
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
18
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
+ if (y = 0, t) op = [op[0] & 2, t.value];
20
+ switch (op[0]) {
21
+ case 0: case 1: t = op; break;
22
+ case 4: _.label++; return { value: op[1], done: false };
23
+ case 5: _.label++; y = op[1]; op = [0]; continue;
24
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
+ default:
26
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
+ if (t[2]) _.ops.pop();
31
+ _.trys.pop(); continue;
32
+ }
33
+ op = body.call(thisArg, _);
34
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
+ }
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.setItem = void 0;
40
+ var index_1 = require("../index");
41
+ var setItem = function (key, value) { return __awaiter(void 0, void 0, void 0, function () {
42
+ var errors, storageUrl, namespace, fp, data;
43
+ return __generator(this, function (_a) {
44
+ switch (_a.label) {
45
+ case 0:
46
+ errors = validOptions(index_1.options);
47
+ if (errors) {
48
+ throw errors;
49
+ }
50
+ storageUrl = index_1.options.storageUrl, namespace = index_1.options.namespace;
51
+ return [4 /*yield*/, (0, index_1.getFingerprint)()];
52
+ case 1:
53
+ fp = _a.sent();
54
+ data = {
55
+ key: key,
56
+ value: value,
57
+ namespace: namespace,
58
+ fingerprint: fp
59
+ };
60
+ console.log(data);
61
+ return [2 /*return*/, fetch(storageUrl, {
62
+ method: 'POST',
63
+ headers: {
64
+ 'Content-Type': 'application/json'
65
+ },
66
+ body: JSON.stringify(data),
67
+ })
68
+ .then(function (response) {
69
+ if (!response.ok) {
70
+ throw new Error("HTTP error! status: ".concat(response.status));
71
+ }
72
+ return response.json();
73
+ })
74
+ .catch(function (error) {
75
+ console.error('There was an error!', error);
76
+ })];
77
+ }
78
+ });
79
+ }); };
80
+ exports.setItem = setItem;
81
+ var validOptions = function (opt) {
82
+ var errors = [];
83
+ if (typeof opt.storageUrl !== 'string' || typeof opt.namespace !== 'string')
84
+ errors.push('storageUrl and namespace must be strings');
85
+ if (opt.namespace.length < 5)
86
+ errors.push('namespace must be at least 5 characters long');
87
+ if (errors.length > 0)
88
+ return new Error(errors.join(', '));
89
+ return null;
90
+ };
91
+ //# sourceMappingURL=setItem.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"setItem.js","sourceRoot":"","sources":["../../src/storage/setItem.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,kCAA+E;AAG/E,IAAM,OAAO,GAAG,UAAO,GAAW,EAAE,KAAa;;;;;gBACvC,MAAM,GAAG,YAAY,CAAC,eAAO,CAAC,CAAA;gBACpC,IAAI,MAAM,EAAE,CAAC;oBAAC,MAAM,MAAM,CAAA;gBAAC,CAAC;gBACpB,UAAU,GAAgB,eAAO,WAAvB,EAAE,SAAS,GAAK,eAAO,UAAZ,CAAY;gBAC9B,qBAAM,IAAA,sBAAc,GAAE,EAAA;;gBAA3B,EAAE,GAAG,SAAsB;gBAE3B,IAAI,GAAG;oBACT,GAAG,EAAE,GAAG;oBACR,KAAK,EAAE,KAAK;oBACZ,SAAS,EAAE,SAAS;oBACpB,WAAW,EAAE,EAAE;iBAClB,CAAA;gBACD,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;gBAEjB,sBAAO,KAAK,CAAC,UAAU,EAAE;wBACrB,MAAM,EAAE,MAAM;wBACd,OAAO,EAAE;4BACL,cAAc,EAAE,kBAAkB;yBACrC;wBACD,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC;qBAC7B,CAAC;yBACD,IAAI,CAAC,UAAA,QAAQ;wBACV,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;4BACf,MAAM,IAAI,KAAK,CAAC,8BAAuB,QAAQ,CAAC,MAAM,CAAE,CAAC,CAAC;wBAC9D,CAAC;wBACD,OAAO,QAAQ,CAAC,IAAI,EAAE,CAAC;oBAC3B,CAAC,CAAC;yBACD,KAAK,CAAC,UAAA,KAAK;wBACR,OAAO,CAAC,KAAK,CAAC,qBAAqB,EAAE,KAAK,CAAC,CAAC;oBAChD,CAAC,CAAC,EAAC;;;KACN,CAAA;AAcQ,0BAAO;AAZhB,IAAM,YAAY,GAAG,UAAC,GAAgC;IAClD,IAAM,MAAM,GAAG,EAAE,CAAA;IACjB,IAAI,OAAO,GAAG,CAAC,UAAU,KAAK,QAAQ,IAAI,OAAO,GAAG,CAAC,SAAS,KAAK,QAAQ;QACvE,MAAM,CAAC,IAAI,CAAC,0CAA0C,CAAC,CAAA;IAC3D,IAAI,GAAG,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC;QACxB,MAAM,CAAC,IAAI,CAAC,8CAA8C,CAAC,CAAA;IAE/D,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC;QACjB,OAAO,IAAI,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAA;IACvC,OAAO,IAAI,CAAA;AACf,CAAC,CAAA"}
@@ -0,0 +1 @@
1
+ export declare function getCommonPixels(images: ImageData[], width: number, height: number): ImageData;
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getCommonPixels = void 0;
4
+ function getCommonPixels(images, width, height) {
5
+ var finalData = [];
6
+ for (var i = 0; i < images[0].data.length; i++) {
7
+ var indice = [];
8
+ for (var u = 0; u < images.length; u++) {
9
+ indice.push(images[u].data[i]);
10
+ }
11
+ finalData.push(getMostFrequent(indice));
12
+ }
13
+ var pixelData = finalData;
14
+ var pixelArray = new Uint8ClampedArray(pixelData);
15
+ return new ImageData(pixelArray, width, height);
16
+ }
17
+ exports.getCommonPixels = getCommonPixels;
18
+ function getMostFrequent(arr) {
19
+ if (arr.length === 0) {
20
+ return 0; // Handle empty array case
21
+ }
22
+ var frequencyMap = {};
23
+ // Count occurrences of each number in the array
24
+ for (var _i = 0, arr_1 = arr; _i < arr_1.length; _i++) {
25
+ var num = arr_1[_i];
26
+ frequencyMap[num] = (frequencyMap[num] || 0) + 1;
27
+ }
28
+ var mostFrequent = arr[0];
29
+ // Find the number with the highest frequency
30
+ for (var num in frequencyMap) {
31
+ if (frequencyMap[num] > frequencyMap[mostFrequent]) {
32
+ mostFrequent = parseInt(num, 10);
33
+ }
34
+ }
35
+ return mostFrequent;
36
+ }
37
+ //# sourceMappingURL=commonPixels.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"commonPixels.js","sourceRoot":"","sources":["../../src/utils/commonPixels.ts"],"names":[],"mappings":";;;AAAA,SAAgB,eAAe,CAAC,MAAmB,EAAE,KAAa,EAAE,MAAc;IAC9E,IAAI,SAAS,GAAa,EAAE,CAAC;IAC7B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QAC7C,IAAI,MAAM,GAAa,EAAE,CAAC;QAC1B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;YACrC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;QACnC,CAAC;QACD,SAAS,CAAC,IAAI,CAAC,eAAe,CAAC,MAAM,CAAC,CAAC,CAAC;IAC5C,CAAC;IAED,IAAM,SAAS,GAAG,SAAS,CAAC;IAC5B,IAAM,UAAU,GAAG,IAAI,iBAAiB,CAAC,SAAS,CAAC,CAAC;IACpD,OAAO,IAAI,SAAS,CAAC,UAAU,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC;AACpD,CAAC;AAbD,0CAaC;AAED,SAAS,eAAe,CAAC,GAAa;IAClC,IAAI,GAAG,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACrB,OAAO,CAAC,CAAC,CAAC,0BAA0B;IACtC,CAAC;IAED,IAAM,YAAY,GAA8B,EAAE,CAAC;IAEnD,gDAAgD;IAChD,KAAkB,UAAG,EAAH,WAAG,EAAH,iBAAG,EAAH,IAAG,EAAE,CAAC;QAAnB,IAAM,GAAG,YAAA;QACZ,YAAY,CAAC,GAAG,CAAC,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC;IACnD,CAAC;IAED,IAAI,YAAY,GAAW,GAAG,CAAC,CAAC,CAAC,CAAC;IAElC,6CAA6C;IAC7C,KAAK,IAAM,GAAG,IAAI,YAAY,EAAE,CAAC;QAC/B,IAAI,YAAY,CAAC,GAAG,CAAC,GAAG,YAAY,CAAC,YAAY,CAAC,EAAE,CAAC;YACnD,YAAY,GAAG,QAAQ,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;QACnC,CAAC;IACH,CAAC;IAED,OAAO,YAAY,CAAC;AACtB,CAAC"}
@@ -0,0 +1,4 @@
1
+ export declare function ephemeralIFrame(callback: ({ iframe }: {
2
+ iframe: Document;
3
+ }) => void): Promise<any>;
4
+ export declare function wait<T = void>(durationMs: number, resolveWith?: T): Promise<T>;
@@ -0,0 +1,79 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __generator = (this && this.__generator) || function (thisArg, body) {
12
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
+ function verb(n) { return function (v) { return step([n, v]); }; }
15
+ function step(op) {
16
+ if (f) throw new TypeError("Generator is already executing.");
17
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
18
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
+ if (y = 0, t) op = [op[0] & 2, t.value];
20
+ switch (op[0]) {
21
+ case 0: case 1: t = op; break;
22
+ case 4: _.label++; return { value: op[1], done: false };
23
+ case 5: _.label++; y = op[1]; op = [0]; continue;
24
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
+ default:
26
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
+ if (t[2]) _.ops.pop();
31
+ _.trys.pop(); continue;
32
+ }
33
+ op = body.call(thisArg, _);
34
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
+ }
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.wait = exports.ephemeralIFrame = void 0;
40
+ function ephemeralIFrame(callback) {
41
+ var _a;
42
+ return __awaiter(this, void 0, void 0, function () {
43
+ var iframe, style, iframeDocument;
44
+ return __generator(this, function (_b) {
45
+ switch (_b.label) {
46
+ case 0:
47
+ if (!!document.body) return [3 /*break*/, 2];
48
+ return [4 /*yield*/, wait(50)];
49
+ case 1:
50
+ _b.sent();
51
+ return [3 /*break*/, 0];
52
+ case 2:
53
+ iframe = document.createElement('iframe');
54
+ style = iframe.style;
55
+ style.setProperty('display', 'block', 'important');
56
+ style.setProperty('visibility', 'visible');
57
+ iframe.src = 'about:blank';
58
+ document.body.appendChild(iframe);
59
+ iframeDocument = iframe.contentDocument || ((_a = iframe.contentWindow) === null || _a === void 0 ? void 0 : _a.document);
60
+ if (!iframeDocument) {
61
+ throw new Error('Iframe document is not accessible');
62
+ }
63
+ // Execute the callback function with access to the iframe's document
64
+ callback({ iframe: iframeDocument });
65
+ // Clean up after running the callback
66
+ setTimeout(function () {
67
+ document.body.removeChild(iframe);
68
+ }, 0);
69
+ return [2 /*return*/];
70
+ }
71
+ });
72
+ });
73
+ }
74
+ exports.ephemeralIFrame = ephemeralIFrame;
75
+ function wait(durationMs, resolveWith) {
76
+ return new Promise(function (resolve) { return setTimeout(resolve, durationMs, resolveWith); });
77
+ }
78
+ exports.wait = wait;
79
+ //# sourceMappingURL=ephemeralIFrame.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ephemeralIFrame.js","sourceRoot":"","sources":["../../src/utils/ephemeralIFrame.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAsB,eAAe,CAAC,QAAoD;;;;;;;yBAE/E,CAAC,QAAQ,CAAC,IAAI;oBACnB,qBAAM,IAAI,CAAC,EAAE,CAAC,EAAA;;oBAAd,SAAc,CAAA;;;oBAEV,MAAM,GAAG,QAAQ,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAA;oBACzC,KAAK,GAAG,MAAM,CAAC,KAAK,CAAA;oBAC1B,KAAK,CAAC,WAAW,CAAC,SAAS,EAAE,OAAO,EAAE,WAAW,CAAC,CAAA;oBAClD,KAAK,CAAC,WAAW,CAAC,YAAY,EAAE,SAAS,CAAC,CAAA;oBAC1C,MAAM,CAAC,GAAG,GAAG,aAAa,CAAA;oBAC1B,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,CAAA;oBAE3B,cAAc,GAAG,MAAM,CAAC,eAAe,KAAI,MAAA,MAAM,CAAC,aAAa,0CAAE,QAAQ,CAAA,CAAC;oBAChF,IAAI,CAAC,cAAc,EAAE,CAAC;wBACpB,MAAM,IAAI,KAAK,CAAC,mCAAmC,CAAC,CAAC;oBACvD,CAAC;oBAED,qEAAqE;oBACrE,QAAQ,CAAC,EAAE,MAAM,EAAE,cAAc,EAAE,CAAC,CAAC;oBAErC,sCAAsC;oBACtC,UAAU,CAAC;wBACT,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;oBACpC,CAAC,EAAE,CAAC,CAAC,CAAC;;;;;CACP;AAxBH,0CAwBG;AAED,SAAgB,IAAI,CAAW,UAAkB,EAAE,WAAe;IAChE,OAAO,IAAI,OAAO,CAAC,UAAC,OAAO,IAAK,OAAA,UAAU,CAAC,OAAO,EAAE,UAAU,EAAE,WAAW,CAAC,EAA5C,CAA4C,CAAC,CAAA;AAC/E,CAAC;AAFD,oBAEC"}
@@ -0,0 +1,5 @@
1
+ export declare function mostFrequentValuesInArrayOfDictionaries(arr: {
2
+ [key: string]: any;
3
+ }[], keys: string[]): {
4
+ [key: string]: any;
5
+ };
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.mostFrequentValuesInArrayOfDictionaries = void 0;
4
+ function mostFrequentValue(arr) {
5
+ if (arr.length === 0) {
6
+ return null; // Return null for an empty array
7
+ }
8
+ var frequencyMap = {};
9
+ // Count occurrences of each element in the array
10
+ arr.forEach(function (element) {
11
+ var key = String(element);
12
+ frequencyMap[key] = (frequencyMap[key] || 0) + 1;
13
+ });
14
+ var mostFrequent = arr[0]; // Assume the first element is the most frequent
15
+ var highestFrequency = 1; // Frequency of the assumed most frequent element
16
+ // Find the element with the highest frequency
17
+ Object.keys(frequencyMap).forEach(function (key) {
18
+ if (frequencyMap[key] > highestFrequency) {
19
+ mostFrequent = key;
20
+ highestFrequency = frequencyMap[key];
21
+ }
22
+ });
23
+ return mostFrequent;
24
+ }
25
+ function mostFrequentValuesInArrayOfDictionaries(arr, keys) {
26
+ var result = {};
27
+ keys.forEach(function (key) {
28
+ var valuesForKey = arr.map(function (obj) { return (key in obj ? obj[key] : undefined); }).filter(function (val) { return val !== undefined; });
29
+ var mostFrequentValueForKey = mostFrequentValue(valuesForKey);
30
+ if (mostFrequentValueForKey)
31
+ result[key] = mostFrequentValueForKey;
32
+ });
33
+ return result;
34
+ }
35
+ exports.mostFrequentValuesInArrayOfDictionaries = mostFrequentValuesInArrayOfDictionaries;
36
+ //# sourceMappingURL=getMostFrequent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getMostFrequent.js","sourceRoot":"","sources":["../../src/utils/getMostFrequent.ts"],"names":[],"mappings":";;;AAAA,SAAS,iBAAiB,CAAC,GAAU;IACjC,IAAI,GAAG,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACrB,OAAO,IAAI,CAAC,CAAC,iCAAiC;IAChD,CAAC;IAED,IAAM,YAAY,GAA8B,EAAE,CAAC;IAEnD,iDAAiD;IACjD,GAAG,CAAC,OAAO,CAAC,UAAC,OAAO;QAClB,IAAM,GAAG,GAAG,MAAM,CAAC,OAAO,CAAC,CAAC;QAC5B,YAAY,CAAC,GAAG,CAAC,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC;IACnD,CAAC,CAAC,CAAC;IAEH,IAAI,YAAY,GAAQ,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,gDAAgD;IAChF,IAAI,gBAAgB,GAAG,CAAC,CAAC,CAAC,iDAAiD;IAE3E,8CAA8C;IAC9C,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,OAAO,CAAC,UAAC,GAAG;QACpC,IAAI,YAAY,CAAC,GAAG,CAAC,GAAG,gBAAgB,EAAE,CAAC;YACzC,YAAY,GAAG,GAAG,CAAC;YACnB,gBAAgB,GAAG,YAAY,CAAC,GAAG,CAAC,CAAC;QACvC,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,OAAO,YAAY,CAAC;AACtB,CAAC;AAEH,SAAgB,uCAAuC,CAAC,GAA6B,EAAE,IAAc;IACjG,IAAM,MAAM,GAA2B,EAAE,CAAC;IAE1C,IAAI,CAAC,OAAO,CAAC,UAAC,GAAG;QACf,IAAM,YAAY,GAAG,GAAG,CAAC,GAAG,CAAC,UAAC,GAAG,IAAK,OAAA,CAAC,GAAG,IAAI,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,EAAnC,CAAmC,CAAC,CAAC,MAAM,CAAC,UAAC,GAAG,IAAK,OAAA,GAAG,KAAK,SAAS,EAAjB,CAAiB,CAAC,CAAC;QAC9G,IAAM,uBAAuB,GAAG,iBAAiB,CAAC,YAAY,CAAC,CAAC;QAChE,IAAI,uBAAuB;YACzB,MAAM,CAAC,GAAG,CAAC,GAAG,uBAAuB,CAAC;IAC1C,CAAC,CAAC,CAAC;IAEH,OAAO,MAAM,CAAC;AAChB,CAAC;AAXH,0FAWG"}
@@ -0,0 +1 @@
1
+ export declare function hash(key: string, seed?: number): string;