corexxx 1.0.82 → 1.0.85
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/dist/dcache.d.ts +4 -0
- package/dist/dcache.js +53 -0
- package/dist/dcache.js.map +1 -0
- package/dist/dlog.d.ts +1 -0
- package/dist/dlog.js +24 -0
- package/dist/dlog.js.map +1 -1
- package/dist/test.js +19 -3
- package/dist/test.js.map +1 -1
- package/package.json +1 -1
- package/src/dcache.ts +37 -0
- package/src/dlog.ts +23 -0
- package/src/test.ts +12 -3
package/dist/dcache.d.ts
ADDED
package/dist/dcache.js
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.dcache = void 0;
|
|
13
|
+
var dcache;
|
|
14
|
+
(function (dcache) {
|
|
15
|
+
/*
|
|
16
|
+
https://www.sitepoint.com/implementing-memoization-in-javascript/
|
|
17
|
+
function pow(a, b) {
|
|
18
|
+
return a ** b;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
// creates the memoized version
|
|
22
|
+
pow = memoize(pow);
|
|
23
|
+
|
|
24
|
+
pow(3, 5); // creates the index "[3,5]" and returns 243
|
|
25
|
+
*/
|
|
26
|
+
// make sure you have used await
|
|
27
|
+
function memoizeAsync(func) {
|
|
28
|
+
const cache = {};
|
|
29
|
+
return function memoized(...args) {
|
|
30
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
31
|
+
const key = JSON.stringify(args);
|
|
32
|
+
if (!cache[key]) {
|
|
33
|
+
cache[key] = yield func(...args);
|
|
34
|
+
}
|
|
35
|
+
return cache[key];
|
|
36
|
+
});
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
dcache.memoizeAsync = memoizeAsync;
|
|
40
|
+
// just call
|
|
41
|
+
function memoize(func) {
|
|
42
|
+
const cache = {};
|
|
43
|
+
return function memoized(...args) {
|
|
44
|
+
const key = JSON.stringify(args);
|
|
45
|
+
if (!cache[key]) {
|
|
46
|
+
cache[key] = func(...args);
|
|
47
|
+
}
|
|
48
|
+
return cache[key];
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
dcache.memoize = memoize;
|
|
52
|
+
})(dcache = exports.dcache || (exports.dcache = {}));
|
|
53
|
+
//# sourceMappingURL=dcache.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dcache.js","sourceRoot":"","sources":["../src/dcache.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,IAAiB,MAAM,CAmCtB;AAnCD,WAAiB,MAAM;IACrB;;;;;;;;;;QAUI;IACJ,gCAAgC;IAChC,SAAgB,YAAY,CAAC,IAAc;QACzC,MAAM,KAAK,GAAY,EAAE,CAAC;QAC1B,OAAO,SAAe,QAAQ,CAAC,GAAG,IAAS;;gBACzC,MAAM,GAAG,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;gBACjC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE;oBACf,KAAK,CAAC,GAAG,CAAC,GAAG,MAAM,IAAI,CAAC,GAAG,IAAI,CAAC,CAAC;iBAClC;gBACD,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC;YACpB,CAAC;SAAA,CAAC;IACJ,CAAC;IATe,mBAAY,eAS3B,CAAA;IAED,YAAY;IACZ,SAAgB,OAAO,CAAC,IAAc;QACpC,MAAM,KAAK,GAAY,EAAE,CAAC;QAC1B,OAAO,SAAS,QAAQ,CAAC,GAAG,IAAS;YACnC,MAAM,GAAG,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;YACjC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE;gBACf,KAAK,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,GAAG,IAAI,CAAC,CAAC;aAC5B;YACD,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC;QACpB,CAAC,CAAC;IACJ,CAAC;IATe,cAAO,UAStB,CAAA;AACH,CAAC,EAnCgB,MAAM,GAAN,cAAM,KAAN,cAAM,QAmCtB"}
|
package/dist/dlog.d.ts
CHANGED
package/dist/dlog.js
CHANGED
|
@@ -10,6 +10,12 @@ const underscore_1 = __importDefault(require("underscore"));
|
|
|
10
10
|
//let _log = colorogs(true, true, __filename);
|
|
11
11
|
var dlog;
|
|
12
12
|
(function (dlog) {
|
|
13
|
+
let ignoreLog = false;
|
|
14
|
+
// call this function to ignore log in prod
|
|
15
|
+
function isDev(isDev) {
|
|
16
|
+
ignoreLog = !isDev;
|
|
17
|
+
}
|
|
18
|
+
dlog.isDev = isDev;
|
|
13
19
|
function convertMsg(str, limit = 5000) {
|
|
14
20
|
if (str == null) {
|
|
15
21
|
return "null";
|
|
@@ -27,6 +33,9 @@ var dlog;
|
|
|
27
33
|
return final.substring(0, limit) + (final.length > limit ? "(trancated)" : "");
|
|
28
34
|
}
|
|
29
35
|
function d(msg, msg2 = null) {
|
|
36
|
+
if (ignoreLog) {
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
30
39
|
console.log(`[${new Date().toLocaleString()}][DEBUG] ${convertMsg(msg)} ${msg2 ? msg2 : ""} `);
|
|
31
40
|
}
|
|
32
41
|
dlog.d = d;
|
|
@@ -35,15 +44,24 @@ var dlog;
|
|
|
35
44
|
}
|
|
36
45
|
dlog.e = e;
|
|
37
46
|
function i(msg, msg2 = null) {
|
|
47
|
+
if (ignoreLog) {
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
38
50
|
console.log(`[${new Date().toLocaleString()}][INFO] ${convertMsg(msg)} ${msg2 ? msg2 : ""} `);
|
|
39
51
|
}
|
|
40
52
|
dlog.i = i;
|
|
41
53
|
function s(msg, msg2 = null) {
|
|
54
|
+
if (ignoreLog) {
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
42
57
|
console.log(`[${new Date().toLocaleString()}][SUCCESS] ${convertMsg(msg)} ${msg2 ? msg2 : ""} `);
|
|
43
58
|
}
|
|
44
59
|
dlog.s = s;
|
|
45
60
|
function ex(e, ignore = true) {
|
|
46
61
|
var _a;
|
|
62
|
+
if (ignoreLog) {
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
47
65
|
try {
|
|
48
66
|
if (ignore) {
|
|
49
67
|
console.log(`[${new Date().toLocaleString()}][EXCEPTION] ${e.message}. Please check: ${(_a = e.stack) === null || _a === void 0 ? void 0 : _a.split("\n").slice(0, 2).join("")})`);
|
|
@@ -56,12 +74,18 @@ var dlog;
|
|
|
56
74
|
}
|
|
57
75
|
dlog.ex = ex;
|
|
58
76
|
function obj(obj, msg = "DEBUG OBJECT") {
|
|
77
|
+
if (ignoreLog) {
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
59
80
|
console.log(`[${new Date().toLocaleString()}][DEBUG] =========================== ${msg} START ======================`);
|
|
60
81
|
console.log(convertMsg(obj));
|
|
61
82
|
console.log(`[${new Date().toLocaleString()}][DEBUG] =========================== ${msg} END ======================`);
|
|
62
83
|
}
|
|
63
84
|
dlog.obj = obj;
|
|
64
85
|
function map(map) {
|
|
86
|
+
if (ignoreLog) {
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
65
89
|
console.log("[${new Date().toLocaleString()}]=========================== DEBUG OBJECT START ======================");
|
|
66
90
|
for (let x in map.keys()) {
|
|
67
91
|
console.log(`${JSON.stringify(x)} ==> ${JSON.stringify(map.get(x))}`);
|
package/dist/dlog.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dlog.js","sourceRoot":"","sources":["../src/dlog.ts"],"names":[],"mappings":";AAAA,wDAAwD;AACxD,uCAAuC;;;;;;AAEvC,4DAA2B;AAE3B,8CAA8C;AAC9C,IAAiB,IAAI,
|
|
1
|
+
{"version":3,"file":"dlog.js","sourceRoot":"","sources":["../src/dlog.ts"],"names":[],"mappings":";AAAA,wDAAwD;AACxD,uCAAuC;;;;;;AAEvC,4DAA2B;AAE3B,8CAA8C;AAC9C,IAAiB,IAAI,CA0EpB;AA1ED,WAAiB,IAAI;IACnB,IAAI,SAAS,GAAG,KAAK,CAAC;IACtB,2CAA2C;IAC3C,SAAgB,KAAK,CAAC,KAAc;QAClC,SAAS,GAAG,CAAC,KAAK,CAAC;IACrB,CAAC;IAFe,UAAK,QAEpB,CAAA;IACD,SAAS,UAAU,CAAC,GAAQ,EAAE,KAAK,GAAG,IAAI;QACxC,IAAI,GAAG,IAAI,IAAI,EAAE;YACf,OAAO,MAAM,CAAC;SACf;QACD,IAAI,GAAG,IAAI,SAAS,EAAE;YACpB,OAAO,WAAW,CAAC;SACpB;QACD,IAAI,KAAK,GAAG,EAAE,CAAC;QACf,IAAI,oBAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE;YACnB,KAAK,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;SAC5C;aAAM;YACL,KAAK,GAAG,GAAG,GAAG,EAAE,CAAC;SAClB;QACD,OAAO,KAAK,CAAC,SAAS,CAAC,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,GAAG,KAAK,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;IACjF,CAAC;IAED,SAAgB,CAAC,CAAC,GAAW,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,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;SACvE;QACD,OAAO,CAAC,GAAG,CAAC,qGAAqG,CAAC,CAAC;IACrH,CAAC;IATe,QAAG,MASlB,CAAA;AACH,CAAC,EA1EgB,IAAI,GAAJ,YAAI,KAAJ,YAAI,QA0EpB"}
|
package/dist/test.js
CHANGED
|
@@ -1,12 +1,28 @@
|
|
|
1
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
|
+
};
|
|
2
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const
|
|
12
|
+
const dcache_1 = require("./dcache");
|
|
4
13
|
const dlog_1 = require("./dlog");
|
|
5
14
|
dlog_1.dlog.d("hello world");
|
|
6
15
|
//dvalidation.validateExistOrThrow({ a: [] }, ["a"]);
|
|
7
16
|
//console.log(dtime.isSameDay("2022-02-24T11:08:54.342Z", "2022-02-24T11:08:54.342Z"));
|
|
8
17
|
//console.log(dtime.getIstTime(new Date().toISOString()));
|
|
9
18
|
//console.log(dformat.formatMe("Hello #{me} #{me}", { me: "dipankar" }));
|
|
10
|
-
console.log(
|
|
11
|
-
console.log(
|
|
19
|
+
//console.log(dcrypto.decrypt(dcrypto.encrypt("dipankar", "dip"), "dip"));
|
|
20
|
+
//console.log(dcrypto.decrypt(dcrypto.encrypt("dipankar", "dip"), "dip1"));
|
|
21
|
+
let pow = dcache_1.dcache.memoizeAsync((a, b) => {
|
|
22
|
+
return Math.pow(a, b);
|
|
23
|
+
});
|
|
24
|
+
(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
25
|
+
yield pow(3, 5); // creates the index "[3,5]" and returns 243
|
|
26
|
+
yield pow(3, 5);
|
|
27
|
+
}))();
|
|
12
28
|
//# sourceMappingURL=test.js.map
|
package/dist/test.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"test.js","sourceRoot":"","sources":["../src/test.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"test.js","sourceRoot":"","sources":["../src/test.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,qCAAkC;AAClC,iCAA8B;AAE9B,WAAI,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC;AACtB,qDAAqD;AACrD,uFAAuF;AACvF,0DAA0D;AAC1D,yEAAyE;AAEzE,0EAA0E;AAC1E,2EAA2E;AAE3E,IAAI,GAAG,GAAG,eAAM,CAAC,YAAY,CAAC,CAAC,CAAM,EAAE,CAAM,EAAE,EAAE;IAC/C,OAAO,SAAA,CAAC,EAAI,CAAC,CAAA,CAAC;AAChB,CAAC,CAAC,CAAC;AAEH,CAAC,GAAS,EAAE;IACV,MAAM,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,4CAA4C;IAC7D,MAAM,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AAClB,CAAC,CAAA,CAAC,EAAE,CAAC"}
|
package/package.json
CHANGED
package/src/dcache.ts
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { TObject } from ".";
|
|
2
|
+
export namespace dcache {
|
|
3
|
+
/*
|
|
4
|
+
https://www.sitepoint.com/implementing-memoization-in-javascript/
|
|
5
|
+
function pow(a, b) {
|
|
6
|
+
return a ** b;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
// creates the memoized version
|
|
10
|
+
pow = memoize(pow);
|
|
11
|
+
|
|
12
|
+
pow(3, 5); // creates the index "[3,5]" and returns 243
|
|
13
|
+
*/
|
|
14
|
+
// make sure you have used await
|
|
15
|
+
export function memoizeAsync(func: Function) {
|
|
16
|
+
const cache: TObject = {};
|
|
17
|
+
return async function memoized(...args: any) {
|
|
18
|
+
const key = JSON.stringify(args);
|
|
19
|
+
if (!cache[key]) {
|
|
20
|
+
cache[key] = await func(...args);
|
|
21
|
+
}
|
|
22
|
+
return cache[key];
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// just call
|
|
27
|
+
export function memoize(func: Function) {
|
|
28
|
+
const cache: TObject = {};
|
|
29
|
+
return function memoized(...args: any) {
|
|
30
|
+
const key = JSON.stringify(args);
|
|
31
|
+
if (!cache[key]) {
|
|
32
|
+
cache[key] = func(...args);
|
|
33
|
+
}
|
|
34
|
+
return cache[key];
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
}
|
package/src/dlog.ts
CHANGED
|
@@ -5,6 +5,11 @@ import _ from "underscore";
|
|
|
5
5
|
|
|
6
6
|
//let _log = colorogs(true, true, __filename);
|
|
7
7
|
export namespace dlog {
|
|
8
|
+
let ignoreLog = false;
|
|
9
|
+
// call this function to ignore log in prod
|
|
10
|
+
export function isDev(isDev: boolean) {
|
|
11
|
+
ignoreLog = !isDev;
|
|
12
|
+
}
|
|
8
13
|
function convertMsg(str: any, limit = 5000) {
|
|
9
14
|
if (str == null) {
|
|
10
15
|
return "null";
|
|
@@ -22,18 +27,30 @@ export namespace dlog {
|
|
|
22
27
|
}
|
|
23
28
|
|
|
24
29
|
export function d(msg: String, msg2: any = null) {
|
|
30
|
+
if (ignoreLog) {
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
25
33
|
console.log(`[${new Date().toLocaleString()}][DEBUG] ${convertMsg(msg)} ${msg2 ? msg2 : ""} `);
|
|
26
34
|
}
|
|
27
35
|
export function e(msg: String, msg2: any = null) {
|
|
28
36
|
console.log(`[${new Date().toLocaleString()}][ERROR] ${convertMsg(msg)} ${msg2 ? msg2 : ""} `);
|
|
29
37
|
}
|
|
30
38
|
export function i(msg: String, msg2: any = null) {
|
|
39
|
+
if (ignoreLog) {
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
31
42
|
console.log(`[${new Date().toLocaleString()}][INFO] ${convertMsg(msg)} ${msg2 ? msg2 : ""} `);
|
|
32
43
|
}
|
|
33
44
|
export function s(msg: String, msg2: any = null) {
|
|
45
|
+
if (ignoreLog) {
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
34
48
|
console.log(`[${new Date().toLocaleString()}][SUCCESS] ${convertMsg(msg)} ${msg2 ? msg2 : ""} `);
|
|
35
49
|
}
|
|
36
50
|
export function ex(e: Error, ignore = true) {
|
|
51
|
+
if (ignoreLog) {
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
37
54
|
try {
|
|
38
55
|
if (ignore) {
|
|
39
56
|
console.log(`[${new Date().toLocaleString()}][EXCEPTION] ${e.message}. Please check: ${e.stack?.split("\n").slice(0, 2).join("")})`);
|
|
@@ -44,11 +61,17 @@ export namespace dlog {
|
|
|
44
61
|
} catch (e) {}
|
|
45
62
|
}
|
|
46
63
|
export function obj(obj?: Object, msg: string = "DEBUG OBJECT") {
|
|
64
|
+
if (ignoreLog) {
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
47
67
|
console.log(`[${new Date().toLocaleString()}][DEBUG] =========================== ${msg} START ======================`);
|
|
48
68
|
console.log(convertMsg(obj));
|
|
49
69
|
console.log(`[${new Date().toLocaleString()}][DEBUG] =========================== ${msg} END ======================`);
|
|
50
70
|
}
|
|
51
71
|
export function map(map: Map<string, any>) {
|
|
72
|
+
if (ignoreLog) {
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
52
75
|
console.log("[${new Date().toLocaleString()}]=========================== DEBUG OBJECT START ======================");
|
|
53
76
|
for (let x in map.keys()) {
|
|
54
77
|
console.log(`${JSON.stringify(x)} ==> ${JSON.stringify(map.get(x))}`);
|
package/src/test.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { dcache } from "./dcache";
|
|
2
2
|
import { dlog } from "./dlog";
|
|
3
3
|
|
|
4
4
|
dlog.d("hello world");
|
|
@@ -7,5 +7,14 @@ dlog.d("hello world");
|
|
|
7
7
|
//console.log(dtime.getIstTime(new Date().toISOString()));
|
|
8
8
|
//console.log(dformat.formatMe("Hello #{me} #{me}", { me: "dipankar" }));
|
|
9
9
|
|
|
10
|
-
console.log(dcrypto.decrypt(dcrypto.encrypt("dipankar", "dip"), "dip"));
|
|
11
|
-
console.log(dcrypto.decrypt(dcrypto.encrypt("dipankar", "dip"), "dip1"));
|
|
10
|
+
//console.log(dcrypto.decrypt(dcrypto.encrypt("dipankar", "dip"), "dip"));
|
|
11
|
+
//console.log(dcrypto.decrypt(dcrypto.encrypt("dipankar", "dip"), "dip1"));
|
|
12
|
+
|
|
13
|
+
let pow = dcache.memoizeAsync((a: any, b: any) => {
|
|
14
|
+
return a ** b;
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
(async () => {
|
|
18
|
+
await pow(3, 5); // creates the index "[3,5]" and returns 243
|
|
19
|
+
await pow(3, 5);
|
|
20
|
+
})();
|