@xn-lib/core 0.0.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.
package/dist/index.cjs ADDED
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("@xn-lib/base");class r{constructor(t){this.state=t}getState(){return this.state}setState(t){o.isObject(t)&&(this.state={...this.state,...t})}}class a{constructor(){this.events=new Map}on(t,e){this.events.has(t)||this.events.set(t,[]),this.events.get(t).push(e)}off(t,e){const s=this.events.get(t);if(s){const i=s.indexOf(e);i>-1&&s.splice(i,1)}}emit(t,...e){const s=this.events.get(t);s&&s.forEach(i=>i(...e))}}exports.EventBus=a;exports.Store=r;
package/dist/index.mjs ADDED
@@ -0,0 +1,35 @@
1
+ import { isObject as h } from "@xn-lib/base";
2
+ class r {
3
+ constructor(t) {
4
+ this.state = t;
5
+ }
6
+ getState() {
7
+ return this.state;
8
+ }
9
+ setState(t) {
10
+ h(t) && (this.state = { ...this.state, ...t });
11
+ }
12
+ }
13
+ class a {
14
+ constructor() {
15
+ this.events = /* @__PURE__ */ new Map();
16
+ }
17
+ on(t, e) {
18
+ this.events.has(t) || this.events.set(t, []), this.events.get(t).push(e);
19
+ }
20
+ off(t, e) {
21
+ const s = this.events.get(t);
22
+ if (s) {
23
+ const i = s.indexOf(e);
24
+ i > -1 && s.splice(i, 1);
25
+ }
26
+ }
27
+ emit(t, ...e) {
28
+ const s = this.events.get(t);
29
+ s && s.forEach((i) => i(...e));
30
+ }
31
+ }
32
+ export {
33
+ a as EventBus,
34
+ r as Store
35
+ };
package/package.json ADDED
@@ -0,0 +1,35 @@
1
+ {
2
+ "name": "@xn-lib/core",
3
+ "version": "0.0.1",
4
+ "description": "XN core functionality",
5
+ "main": "./dist/index.cjs",
6
+ "module": "./dist/index.mjs",
7
+ "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.mjs",
12
+ "require": "./dist/index.cjs"
13
+ }
14
+ },
15
+ "files": [
16
+ "dist"
17
+ ],
18
+ "scripts": {
19
+ "build": "vite build",
20
+ "dev": "vite build --watch",
21
+ "clean": "rimraf dist"
22
+ },
23
+ "keywords": [
24
+ "xn",
25
+ "core"
26
+ ],
27
+ "author": "",
28
+ "license": "MIT",
29
+ "publishConfig": {
30
+ "access": "public"
31
+ },
32
+ "dependencies": {
33
+ "@xn-lib/base": "^0.0.1"
34
+ }
35
+ }