@pluslabs/utils 0.0.1 → 0.1.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.
@@ -0,0 +1,2 @@
1
+ export * from './stamp';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC"}
@@ -0,0 +1,18 @@
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./stamp"), exports);
18
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,0CAAwB"}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * The idea is that you can create a stamp with an id, and then use that id to mark different steps in your code.
3
+ * `createStamp` should be called at the beginning of the execution context and then createStamp
4
+ * @param id String to identify the stamp
5
+ * @returns
6
+ */
7
+ export declare const createStamp: (id?: string) => typeof stamp;
8
+ export declare function stamp(name: string): void;
9
+ export declare function end(): void;
10
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/stamp/index.ts"],"names":[],"mappings":"AAYA;;;;;GAKG;AACH,eAAO,MAAM,WAAW,+BASvB,CAAC;AAEF,wBAAgB,KAAK,CAAC,IAAI,EAAE,MAAM,QAajC;AAED,wBAAgB,GAAG,SAIlB"}
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.end = exports.stamp = exports.createStamp = void 0;
4
+ const context = {
5
+ id: '',
6
+ idx: '',
7
+ step: 0,
8
+ now: 0
9
+ };
10
+ /**
11
+ * The idea is that you can create a stamp with an id, and then use that id to mark different steps in your code.
12
+ * `createStamp` should be called at the beginning of the execution context and then createStamp
13
+ * @param id String to identify the stamp
14
+ * @returns
15
+ */
16
+ const createStamp = (id = '') => {
17
+ if (!context.id) {
18
+ context.id = id;
19
+ context.idx = (Date.now() * Math.random() * 1e6).toString(36);
20
+ context.now = Date.now();
21
+ context.step = Date.now();
22
+ }
23
+ return stamp;
24
+ };
25
+ exports.createStamp = createStamp;
26
+ function stamp(name) {
27
+ if (!context.id) {
28
+ return;
29
+ }
30
+ const diff = Date.now() - context.step;
31
+ context.step = Date.now();
32
+ console.log(`[STAMP][${context.idx}][${context.id}] ${name} took ${diff}ms, total: ${Date.now() - context.now}ms`);
33
+ }
34
+ exports.stamp = stamp;
35
+ function end() {
36
+ context.id = '';
37
+ context.now = 0;
38
+ context.step = 0;
39
+ }
40
+ exports.end = end;
41
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/stamp/index.ts"],"names":[],"mappings":";;;AAAA,MAAM,OAAO,GAKT;IACA,EAAE,EAAE,EAAE;IACN,GAAG,EAAE,EAAE;IACP,IAAI,EAAE,CAAC;IACP,GAAG,EAAE,CAAC;CACT,CAAC;AAEF;;;;;GAKG;AACI,MAAM,WAAW,GAAG,CAAC,EAAE,GAAG,EAAE,EAAE,EAAE;IACnC,IAAI,CAAC,OAAO,CAAC,EAAE,EAAE;QACb,OAAO,CAAC,EAAE,GAAG,EAAE,CAAC;QAChB,OAAO,CAAC,GAAG,GAAG,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,MAAM,EAAE,GAAG,GAAG,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;QAC9D,OAAO,CAAC,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;QACzB,OAAO,CAAC,IAAI,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;KAC7B;IAED,OAAO,KAAK,CAAC;AACjB,CAAC,CAAC;AATW,QAAA,WAAW,eAStB;AAEF,SAAgB,KAAK,CAAC,IAAY;IAC9B,IAAI,CAAC,OAAO,CAAC,EAAE,EAAE;QACb,OAAO;KACV;IAED,MAAM,IAAI,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IACvC,OAAO,CAAC,IAAI,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;IAE1B,OAAO,CAAC,GAAG,CACP,WAAW,OAAO,CAAC,GAAG,KAAK,OAAO,CAAC,EAAE,KAAK,IAAI,SAAS,IAAI,cACvD,IAAI,CAAC,GAAG,EAAE,GAAG,OAAO,CAAC,GACzB,IAAI,CACP,CAAC;AACN,CAAC;AAbD,sBAaC;AAED,SAAgB,GAAG;IACf,OAAO,CAAC,EAAE,GAAG,EAAE,CAAC;IAChB,OAAO,CAAC,GAAG,GAAG,CAAC,CAAC;IAChB,OAAO,CAAC,IAAI,GAAG,CAAC,CAAC;AACrB,CAAC;AAJD,kBAIC"}
@@ -0,0 +1,2 @@
1
+ export * from './stamp';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * from './stamp';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC"}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * The idea is that you can create a stamp with an id, and then use that id to mark different steps in your code.
3
+ * `createStamp` should be called at the beginning of the execution context and then createStamp
4
+ * @param id String to identify the stamp
5
+ * @returns
6
+ */
7
+ export declare const createStamp: (id?: string) => typeof stamp;
8
+ export declare function stamp(name: string): void;
9
+ export declare function end(): void;
10
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/stamp/index.ts"],"names":[],"mappings":"AAYA;;;;;GAKG;AACH,eAAO,MAAM,WAAW,+BASvB,CAAC;AAEF,wBAAgB,KAAK,CAAC,IAAI,EAAE,MAAM,QAajC;AAED,wBAAgB,GAAG,SAIlB"}
@@ -0,0 +1,35 @@
1
+ const context = {
2
+ id: '',
3
+ idx: '',
4
+ step: 0,
5
+ now: 0
6
+ };
7
+ /**
8
+ * The idea is that you can create a stamp with an id, and then use that id to mark different steps in your code.
9
+ * `createStamp` should be called at the beginning of the execution context and then createStamp
10
+ * @param id String to identify the stamp
11
+ * @returns
12
+ */
13
+ export const createStamp = (id = '') => {
14
+ if (!context.id) {
15
+ context.id = id;
16
+ context.idx = (Date.now() * Math.random() * 1e6).toString(36);
17
+ context.now = Date.now();
18
+ context.step = Date.now();
19
+ }
20
+ return stamp;
21
+ };
22
+ export function stamp(name) {
23
+ if (!context.id) {
24
+ return;
25
+ }
26
+ const diff = Date.now() - context.step;
27
+ context.step = Date.now();
28
+ console.log(`[STAMP][${context.idx}][${context.id}] ${name} took ${diff}ms, total: ${Date.now() - context.now}ms`);
29
+ }
30
+ export function end() {
31
+ context.id = '';
32
+ context.now = 0;
33
+ context.step = 0;
34
+ }
35
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3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C;AACrB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pluslabs/utils",
3
- "version": "0.0.1",
3
+ "version": "0.1.1",
4
4
  "description": "A set of utilities used across projects",
5
5
  "keywords": [
6
6
  "javascript",