@eventvisor/module-timestamp 0.3.0

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/CHANGELOG.md ADDED
@@ -0,0 +1,30 @@
1
+ # Change Log
2
+
3
+ All notable changes to this project will be documented in this file.
4
+ See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
+
6
+ # [0.3.0](https://github.com/eventvisor/eventvisor/compare/v0.2.1...v0.3.0) (2025-10-01)
7
+
8
+
9
+ ### Features
10
+
11
+ * module-timestamp ([#5](https://github.com/eventvisor/eventvisor/issues/5)) ([1a654f2](https://github.com/eventvisor/eventvisor/commit/1a654f2de719d9ddb22a6c5f97c84006f522f35a))
12
+
13
+
14
+
15
+
16
+
17
+ ## [0.2.1](https://github.com/eventvisor/eventvisor/compare/v0.2.0...v0.2.1) (2025-10-01)
18
+
19
+ **Note:** Version bump only for package @eventvisor/module-uuid
20
+
21
+
22
+
23
+
24
+
25
+ # [0.2.0](https://github.com/eventvisor/eventvisor/compare/v0.1.0...v0.2.0) (2025-10-01)
26
+
27
+
28
+ ### Features
29
+
30
+ * module-uuid ([#3](https://github.com/eventvisor/eventvisor/issues/3)) ([7c5d5d1](https://github.com/eventvisor/eventvisor/commit/7c5d5d166fd519a484b0f146a666cb40bac1180a))
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2025 Fahad Heylaal (https://fahad19.com)
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,9 @@
1
+ # @eventvisor/module-timestamp
2
+
3
+ > Timestamp module for Eventvisor, for generating timestamps.
4
+
5
+ Visit [https://eventvisor.org/docs/modules/timestamp/](https://eventvisor.org/docs/modules/timestamp/) for more information.
6
+
7
+ ## License
8
+
9
+ MIT © [Fahad Heylaal](https://fahad19.com)
@@ -0,0 +1,6 @@
1
+ import { Module } from "@eventvisor/sdk";
2
+ export type TimestampModuleOptions = {
3
+ name?: string;
4
+ };
5
+ export declare function toLocalIsoOffset(d?: Date): string;
6
+ export declare function createTimestampModule(options?: TimestampModuleOptions): Module;
package/dist/index.js ADDED
@@ -0,0 +1,2 @@
1
+ !function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.EventvisorTimestampModule=e():t.EventvisorTimestampModule=e()}(this,()=>(()=>{"use strict";var t={};return{166:function(t,e){var n=this&&this.__awaiter||function(t,e,n,o){return new(n||(n=Promise))(function(r,a){function c(t){try{u(o.next(t))}catch(t){a(t)}}function i(t){try{u(o.throw(t))}catch(t){a(t)}}function u(t){var e;t.done?r(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(c,i)}u((o=o.apply(t,e||[])).next())})},o=this&&this.__generator||function(t,e){var n,o,r,a={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]},c=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return c.next=i(0),c.throw=i(1),c.return=i(2),"function"==typeof Symbol&&(c[Symbol.iterator]=function(){return this}),c;function i(i){return function(u){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;c&&(c=0,i[0]&&(a=0)),a;)try{if(n=1,o&&(r=2&i[0]?o.return:i[0]?o.throw||((r=o.return)&&r.call(o),0):o.next)&&!(r=r.call(o,i[1])).done)return r;switch(o=0,r&&(i=[2&i[0],r.value]),i[0]){case 0:case 1:r=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,o=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!((r=(r=a.trys).length>0&&r[r.length-1])||6!==i[0]&&2!==i[0])){a=0;continue}if(3===i[0]&&(!r||i[1]>r[0]&&i[1]<r[3])){a.label=i[1];break}if(6===i[0]&&a.label<r[1]){a.label=r[1],r=i;break}if(r&&a.label<r[2]){a.label=r[2],a.ops.push(i);break}r[2]&&a.ops.pop(),a.trys.pop();continue}i=e.call(t,a)}catch(t){i=[6,t],o=0}finally{n=r=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,u])}}};function r(t){void 0===t&&(t=new Date);var e=function(t,e){return void 0===e&&(e=2),String(t).padStart(e,"0")},n=-t.getTimezoneOffset(),o=n>=0?"+":"-",r=e(Math.floor(Math.abs(n)/60)),a=e(Math.abs(n)%60);return"".concat(t.getFullYear(),"-").concat(e(t.getMonth()+1),"-").concat(e(t.getDate()))+"T".concat(e(t.getHours()),":").concat(e(t.getMinutes()),":").concat(e(t.getSeconds()))+".".concat(e(t.getMilliseconds(),3)).concat(o).concat(r,":").concat(a)}Object.defineProperty(e,"__esModule",{value:!0}),e.toLocalIsoOffset=r,e.createTimestampModule=function(t){var e=this;void 0===t&&(t={});var a=t.name;return{name:void 0===a?"timestamp":a,lookup:function(t){return n(e,[t],void 0,function(t){var e=t.key;return o(this,function(t){if(e){if("epoch"===e)return[2,Math.floor(Date.now()/1e3)];if("epoch_ms"===e)return[2,Date.now()]}return[2,r()]})})}}}}}[166](0,t),t})());
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","mappings":"CAAA,SAA2CA,EAAMC,GAC1B,iBAAZC,SAA0C,iBAAXC,OACxCA,OAAOD,QAAUD,IACQ,mBAAXG,QAAyBA,OAAOC,IAC9CD,OAAO,GAAIH,GACe,iBAAZC,QACdA,QAAmC,0BAAID,IAEvCD,EAAgC,0BAAIC,GACrC,CATD,CASGK,KAAM,I,uBCNLC,EAAsB,CAAC,E,k/CCG3B,SAAgBC,EAAiBC,QAAA,IAAAA,IAAAA,EAAA,IAAQC,MACvC,IAAMC,EAAM,SAACC,EAAGC,GAAY,YAAZ,IAAAA,IAAAA,EAAA,GAAYC,OAAOF,GAAGG,SAASF,EAAK,IAAxB,EACtBG,GAAUP,EAAEQ,oBACZC,EAAOF,GAAU,EAAI,IAAM,IAC3BG,EAAKR,EAAIS,KAAKC,MAAMD,KAAKE,IAAIN,GAAU,KACvCO,EAAKZ,EAAIS,KAAKE,IAAIN,GAAU,IAElC,MACE,UAAGP,EAAEe,cAAa,YAAIb,EAAIF,EAAEgB,WAAa,GAAE,YAAId,EAAIF,EAAEiB,YACrD,WAAIf,EAAIF,EAAEkB,YAAW,YAAIhB,EAAIF,EAAEmB,cAAa,YAAIjB,EAAIF,EAAEoB,eACtD,WAAIlB,EAAIF,EAAEqB,kBAAmB,IAAE,OAAGZ,GAAI,OAAGC,EAAE,YAAII,EAEnD,C,iDAZA,qBAcA,iCAAsCQ,GAAtC,gBAAsC,IAAAA,IAAAA,EAAA,IAC5B,MAAuBA,EAAO,KAEtC,MAAO,CACLC,UAHU,IAAG,cAAW,EAKxBC,OAAQ,2CAAO,G,IAAEC,EAAG,M,0BAClB,GAAIA,EAAK,CACP,GAAY,UAARA,EAEF,MAAO,CAAP,EAAOd,KAAKC,MAAMX,KAAKyB,MAAQ,MAGjC,GAAY,aAARD,EAEF,MAAO,CAAP,EAAOxB,KAAKyB,MAEhB,CAGA,MAAO,CAAP,EAAO3B,I,MAGb,C,GDvCoB,KAAK,EAAGD,G","sources":["webpack://EventvisorTimestampModule/webpack/universalModuleDefinition","webpack://EventvisorTimestampModule/webpack/startup","webpack://EventvisorTimestampModule/./src/index.ts"],"sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"EventvisorTimestampModule\"] = factory();\n\telse\n\t\troot[\"EventvisorTimestampModule\"] = factory();\n})(this, () => {\nreturn ","// startup\n// Load entry module and return exports\n// This entry module is referenced by other modules so it can't be inlined\nvar __webpack_exports__ = {};\n__webpack_modules__[166](0, __webpack_exports__);\n","import { Module } from \"@eventvisor/sdk\";\n\nexport type TimestampModuleOptions = {\n name?: string;\n};\n\nexport function toLocalIsoOffset(d = new Date()) {\n const pad = (n, len = 2) => String(n).padStart(len, \"0\");\n const offMin = -d.getTimezoneOffset();\n const sign = offMin >= 0 ? \"+\" : \"-\";\n const hh = pad(Math.floor(Math.abs(offMin) / 60));\n const mm = pad(Math.abs(offMin) % 60);\n\n return (\n `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())}` +\n `T${pad(d.getHours())}:${pad(d.getMinutes())}:${pad(d.getSeconds())}` +\n `.${pad(d.getMilliseconds(), 3)}${sign}${hh}:${mm}`\n );\n}\n\nexport function createTimestampModule(options: TimestampModuleOptions = {}): Module {\n const { name = \"timestamp\" } = options;\n\n return {\n name,\n\n lookup: async ({ key }) => {\n if (key) {\n if (key === \"epoch\") {\n // seconds\n return Math.floor(Date.now() / 1000);\n }\n\n if (key === \"epoch_ms\") {\n // milliseconds\n return Date.now();\n }\n }\n\n // iso 8601 with offset\n return toLocalIsoOffset();\n },\n };\n}\n"],"names":["root","factory","exports","module","define","amd","this","__webpack_exports__","toLocalIsoOffset","d","Date","pad","n","len","String","padStart","offMin","getTimezoneOffset","sign","hh","Math","floor","abs","mm","getFullYear","getMonth","getDate","getHours","getMinutes","getSeconds","getMilliseconds","options","name","lookup","key","now"],"sourceRoot":""}
package/dist/index.mjs ADDED
@@ -0,0 +1,2 @@
1
+ var t={d:(e,n)=>{for(var o in n)t.o(n,o)&&!t.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:n[o]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e)},e={};t.d(e,{L:()=>r,x:()=>o});var n=function(t,e,n,o){return new(n||(n=Promise))(function(r,a){function c(t){try{u(o.next(t))}catch(t){a(t)}}function i(t){try{u(o.throw(t))}catch(t){a(t)}}function u(t){var e;t.done?r(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(c,i)}u((o=o.apply(t,e||[])).next())})};function o(t=new Date){const e=(t,e=2)=>String(t).padStart(e,"0"),n=-t.getTimezoneOffset(),o=n>=0?"+":"-",r=e(Math.floor(Math.abs(n)/60)),a=e(Math.abs(n)%60);return`${t.getFullYear()}-${e(t.getMonth()+1)}-${e(t.getDate())}T${e(t.getHours())}:${e(t.getMinutes())}:${e(t.getSeconds())}.${e(t.getMilliseconds(),3)}${o}${r}:${a}`}function r(t={}){const{name:e="timestamp"}=t;return{name:e,lookup:t=>n(this,[t],void 0,function*({key:t}){if(t){if("epoch"===t)return Math.floor(Date.now()/1e3);if("epoch_ms"===t)return Date.now()}return o()})}}const a=e.L,c=e.x;export{a as createTimestampModule,c as toLocalIsoOffset};
2
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.mjs","mappings":"AACA,IAAIA,EAAsB,CCA1BA,EAAwB,CAACC,EAASC,KACjC,IAAI,IAAIC,KAAOD,EACXF,EAAoBI,EAAEF,EAAYC,KAASH,EAAoBI,EAAEH,EAASE,IAC5EE,OAAOC,eAAeL,EAASE,EAAK,CAAEI,YAAY,EAAMC,IAAKN,EAAWC,MCJ3EH,EAAwB,CAACS,EAAKC,IAAUL,OAAOM,UAAUC,eAAeC,KAAKJ,EAAKC,I,oUCM3E,SAASI,EAAiBC,EAAI,IAAIC,MACvC,MAAMC,EAAM,CAACC,EAAGC,EAAM,IAAMC,OAAOF,GAAGG,SAASF,EAAK,KAC9CG,GAAUP,EAAEQ,oBACZC,EAAOF,GAAU,EAAI,IAAM,IAC3BG,EAAKR,EAAIS,KAAKC,MAAMD,KAAKE,IAAIN,GAAU,KACvCO,EAAKZ,EAAIS,KAAKE,IAAIN,GAAU,IAElC,MACE,GAAGP,EAAEe,iBAAiBb,EAAIF,EAAEgB,WAAa,MAAMd,EAAIF,EAAEiB,cACjDf,EAAIF,EAAEkB,eAAehB,EAAIF,EAAEmB,iBAAiBjB,EAAIF,EAAEoB,iBAClDlB,EAAIF,EAAEqB,kBAAmB,KAAKZ,IAAOC,KAAMI,GAEnD,CAEO,SAASQ,EAAsBC,EAAkC,CAAC,GACvE,MAAM,KAAEC,EAAO,aAAgBD,EAE/B,MAAO,CACLC,OAEAC,OAAQ,GAAmB,EAAD,2BAAX,IAAErC,IACf,GAAIA,EAAK,CACP,GAAY,UAARA,EAEF,OAAOuB,KAAKC,MAAMX,KAAKyB,MAAQ,KAGjC,GAAY,aAARtC,EAEF,OAAOa,KAAKyB,KAEhB,CAGA,OAAO3B,GACT,GAEJ,C","sources":["webpack://@eventvisor/module-timestamp/webpack/bootstrap","webpack://@eventvisor/module-timestamp/webpack/runtime/define property getters","webpack://@eventvisor/module-timestamp/webpack/runtime/hasOwnProperty shorthand","webpack://@eventvisor/module-timestamp/./src/index.ts"],"sourcesContent":["// The require scope\nvar __webpack_require__ = {};\n\n","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","import { Module } from \"@eventvisor/sdk\";\n\nexport type TimestampModuleOptions = {\n name?: string;\n};\n\nexport function toLocalIsoOffset(d = new Date()) {\n const pad = (n, len = 2) => String(n).padStart(len, \"0\");\n const offMin = -d.getTimezoneOffset();\n const sign = offMin >= 0 ? \"+\" : \"-\";\n const hh = pad(Math.floor(Math.abs(offMin) / 60));\n const mm = pad(Math.abs(offMin) % 60);\n\n return (\n `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())}` +\n `T${pad(d.getHours())}:${pad(d.getMinutes())}:${pad(d.getSeconds())}` +\n `.${pad(d.getMilliseconds(), 3)}${sign}${hh}:${mm}`\n );\n}\n\nexport function createTimestampModule(options: TimestampModuleOptions = {}): Module {\n const { name = \"timestamp\" } = options;\n\n return {\n name,\n\n lookup: async ({ key }) => {\n if (key) {\n if (key === \"epoch\") {\n // seconds\n return Math.floor(Date.now() / 1000);\n }\n\n if (key === \"epoch_ms\") {\n // milliseconds\n return Date.now();\n }\n }\n\n // iso 8601 with offset\n return toLocalIsoOffset();\n },\n };\n}\n"],"names":["__webpack_require__","exports","definition","key","o","Object","defineProperty","enumerable","get","obj","prop","prototype","hasOwnProperty","call","toLocalIsoOffset","d","Date","pad","n","len","String","padStart","offMin","getTimezoneOffset","sign","hh","Math","floor","abs","mm","getFullYear","getMonth","getDate","getHours","getMinutes","getSeconds","getMilliseconds","createTimestampModule","options","name","lookup","now"],"sourceRoot":""}
@@ -0,0 +1 @@
1
+ export {};
package/jest.config.js ADDED
@@ -0,0 +1,5 @@
1
+ module.exports = {
2
+ preset: "ts-jest",
3
+ bail: true,
4
+ collectCoverageFrom: ["src/**/*.ts"],
5
+ };
package/lib/index.d.ts ADDED
@@ -0,0 +1,6 @@
1
+ import { Module } from "@eventvisor/sdk";
2
+ export type TimestampModuleOptions = {
3
+ name?: string;
4
+ };
5
+ export declare function toLocalIsoOffset(d?: Date): string;
6
+ export declare function createTimestampModule(options?: TimestampModuleOptions): Module;
@@ -0,0 +1 @@
1
+ export {};
package/package.json ADDED
@@ -0,0 +1,46 @@
1
+ {
2
+ "name": "@eventvisor/module-timestamp",
3
+ "version": "0.3.0",
4
+ "description": "Eventvisor Timestamp module",
5
+ "main": "dist/index.cjs.js",
6
+ "module": "dist/index.mjs",
7
+ "types": "dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "require": "./dist/index.js",
12
+ "import": "./dist/index.mjs"
13
+ },
14
+ "./package.json": "./package.json"
15
+ },
16
+ "scripts": {
17
+ "transpile": "echo 'Nothing to transpile'",
18
+ "dist": "webpack --config ./webpack.config.js && tsc --project tsconfig.esm.json --declaration --emitDeclarationOnly --declarationDir dist",
19
+ "build": "npm run transpile && npm run dist",
20
+ "test:jest": "jest --config jest.config.js --verbose",
21
+ "test:jest-coverage": "jest --config jest.config.js --verbose --coverage",
22
+ "test": "npm run test:jest-coverage"
23
+ },
24
+ "author": {
25
+ "name": "Fahad Heylaal",
26
+ "url": "https://fahad19.com"
27
+ },
28
+ "homepage": "https://eventvisor.org",
29
+ "keywords": [],
30
+ "repository": {
31
+ "type": "git",
32
+ "url": "https://github.com/eventvisor/eventvisor.git"
33
+ },
34
+ "publishConfig": {
35
+ "access": "public",
36
+ "registry": "https://registry.npmjs.org/"
37
+ },
38
+ "bugs": {
39
+ "url": "https://github.com/eventvisor/eventvisor/issues"
40
+ },
41
+ "devDependencies": {
42
+ "@eventvisor/sdk": "0.3.0"
43
+ },
44
+ "license": "MIT",
45
+ "gitHead": "877802f58d745cfbfe815fbd2ec3cf54aaef4b24"
46
+ }
@@ -0,0 +1,27 @@
1
+ import { createTimestampModule } from "./index";
2
+ import { ModuleDependencies } from "@eventvisor/sdk";
3
+
4
+ describe("createTimestampModule", () => {
5
+ it("should create a module", async () => {
6
+ const module = createTimestampModule();
7
+ const dependencies = {} as ModuleDependencies; // it's fine because we're not using the dependencies in this module
8
+
9
+ expect(module.name).toEqual("timestamp");
10
+
11
+ // epoch
12
+ const epochTimestamp = await module.lookup?.({ key: "epoch" }, dependencies);
13
+ expect(epochTimestamp).toBeDefined();
14
+ expect(epochTimestamp).toBeGreaterThan(0);
15
+ expect(epochTimestamp).toBeLessThanOrEqual(Math.floor(Date.now() / 1000));
16
+
17
+ // epoch_ms
18
+ const epochMsTimestamp = await module.lookup?.({ key: "epoch_ms" }, dependencies);
19
+ expect(epochMsTimestamp).toBeDefined();
20
+ expect(epochMsTimestamp).toBeLessThanOrEqual(Date.now());
21
+
22
+ // default (iso 8601 with offset)
23
+ const defaultTimestamp = await module.lookup?.({ key: "" }, dependencies);
24
+ expect(defaultTimestamp).toBeDefined();
25
+ expect(defaultTimestamp).toMatch(/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}\+\d{2}:\d{2}$/);
26
+ });
27
+ });
package/src/index.ts ADDED
@@ -0,0 +1,44 @@
1
+ import { Module } from "@eventvisor/sdk";
2
+
3
+ export type TimestampModuleOptions = {
4
+ name?: string;
5
+ };
6
+
7
+ export function toLocalIsoOffset(d = new Date()) {
8
+ const pad = (n, len = 2) => String(n).padStart(len, "0");
9
+ const offMin = -d.getTimezoneOffset();
10
+ const sign = offMin >= 0 ? "+" : "-";
11
+ const hh = pad(Math.floor(Math.abs(offMin) / 60));
12
+ const mm = pad(Math.abs(offMin) % 60);
13
+
14
+ return (
15
+ `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())}` +
16
+ `T${pad(d.getHours())}:${pad(d.getMinutes())}:${pad(d.getSeconds())}` +
17
+ `.${pad(d.getMilliseconds(), 3)}${sign}${hh}:${mm}`
18
+ );
19
+ }
20
+
21
+ export function createTimestampModule(options: TimestampModuleOptions = {}): Module {
22
+ const { name = "timestamp" } = options;
23
+
24
+ return {
25
+ name,
26
+
27
+ lookup: async ({ key }) => {
28
+ if (key) {
29
+ if (key === "epoch") {
30
+ // seconds
31
+ return Math.floor(Date.now() / 1000);
32
+ }
33
+
34
+ if (key === "epoch_ms") {
35
+ // milliseconds
36
+ return Date.now();
37
+ }
38
+ }
39
+
40
+ // iso 8601 with offset
41
+ return toLocalIsoOffset();
42
+ },
43
+ };
44
+ }
@@ -0,0 +1,8 @@
1
+ {
2
+ "extends": "../../tsconfig.cjs.json",
3
+ "compilerOptions": {
4
+ "outDir": "./lib",
5
+ "lib": ["DOM"]
6
+ },
7
+ "include": ["./src/**/*.ts"]
8
+ }
@@ -0,0 +1,8 @@
1
+ {
2
+ "extends": "../../tsconfig.esm.json",
3
+ "compilerOptions": {
4
+ "outDir": "./lib",
5
+ "lib": ["DOM"]
6
+ },
7
+ "include": ["./src/**/*.ts"]
8
+ }
@@ -0,0 +1,80 @@
1
+ const path = require("path");
2
+
3
+ module.exports = [
4
+ // cjs
5
+ {
6
+ entry: {
7
+ "index.cjs": path.join(__dirname, "src", "index.ts"),
8
+ },
9
+ output: {
10
+ path: path.join(__dirname, "dist"),
11
+ filename: "index.js",
12
+ library: "EventvisorTimestampModule",
13
+ libraryTarget: "umd",
14
+ globalObject: "this",
15
+ },
16
+ mode: "production",
17
+ devtool: "source-map",
18
+ resolve: {
19
+ extensions: [".ts", ".tsx", ".js"],
20
+ },
21
+ module: {
22
+ rules: [
23
+ {
24
+ test: /\.(ts|tsx)$/,
25
+ exclude: /(node_modules)/,
26
+ use: [
27
+ {
28
+ loader: "ts-loader",
29
+ options: {
30
+ configFile: path.join(__dirname, "tsconfig.cjs.json"),
31
+ transpileOnly: true,
32
+ },
33
+ },
34
+ ],
35
+ },
36
+ ],
37
+ },
38
+ performance: {
39
+ hints: false,
40
+ },
41
+ optimization: {
42
+ minimize: true,
43
+ },
44
+ },
45
+
46
+ // esm
47
+ {
48
+ entry: path.join(__dirname, "src", "index.ts"),
49
+ output: {
50
+ path: path.join(__dirname, "dist"),
51
+ filename: "index.mjs",
52
+ library: {
53
+ type: "module",
54
+ },
55
+ },
56
+ experiments: {
57
+ outputModule: true,
58
+ },
59
+ mode: "production",
60
+ devtool: "source-map",
61
+ resolve: {
62
+ extensions: [".ts", ".tsx", ".js"],
63
+ },
64
+ module: {
65
+ rules: [
66
+ {
67
+ test: /\.(ts|tsx)$/,
68
+ exclude: /(node_modules)/,
69
+ loader: "ts-loader",
70
+ options: {
71
+ configFile: path.join(__dirname, "tsconfig.esm.json"),
72
+ },
73
+ },
74
+ ],
75
+ },
76
+ performance: {
77
+ hints: false,
78
+ },
79
+ },
80
+ ];