asljs-eventful 0.4.6 → 0.4.9

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/README.md CHANGED
@@ -13,8 +13,48 @@ npm install asljs-eventful
13
13
 
14
14
  NPM Package: [asljs-eventful](https://www.npmjs.com/package/asljs-eventful)
15
15
 
16
+ ## Public Exports
17
+
18
+ The package-root export surface includes:
19
+
20
+ - `eventful`
21
+ - `EventfulBase`
22
+ - `isEventfulLike`
23
+ - `asEventfulLike`
24
+ - `ListenerError`
25
+ - TypeScript types including `EventfulLike`, `EventName`, `EventMap`,
26
+ `Eventful`, `EventfulFactory`, `EventfulOptions`, `Listener`, and `TraceFn`
27
+
16
28
  ## Usage
17
29
 
30
+ ### Special Behavior
31
+
32
+ `eventful` is not only an object enhancer. The package-level `eventful`
33
+ function also acts as a global emitter for lifecycle and error events.
34
+
35
+ If you change lifecycle, tracing, or listener-error behavior, then preserve
36
+ that package-level emitter contract.
37
+
38
+ ### Stable Behavior
39
+
40
+ These behaviors are part of the supported contract, not just current examples:
41
+
42
+ - `eventful` adds `on`, `once`, `off`, `emit`, `emitAsync`, and `has`
43
+ - `eventful` also acts as a package-level global emitter
44
+ - strict mode propagates listener errors
45
+ - non-strict mode isolates listener failures through the configured error path
46
+ - `ListenerError` protects against recursive failures in global error handling
47
+
48
+ ### Preferred Patterns
49
+
50
+ - If you are enhancing a plain object, then use `eventful(target)`.
51
+ - If you are enhancing an existing class instance and cannot change
52
+ inheritance, then call `eventful(this)` in the constructor.
53
+ - If you control a new class hierarchy and event support is part of the type
54
+ design, then extend `EventfulBase`.
55
+ - If you are writing TypeScript and want typed listener signatures, then
56
+ declare an event map and use the exported `Eventful<...>` types.
57
+
18
58
  ### Basic (JavaScript)
19
59
 
20
60
  Adding events to an object, add listeners, and emit events:
@@ -320,4 +360,10 @@ console.log(obj.has('e')); // false
320
360
 
321
361
  MIT License. See [LICENSE](LICENSE.md) for details.
322
362
 
363
+ ## Related Packages
364
+
365
+ - If you need property change tracking, see `asljs-observable`.
366
+ - If you need DOM binding built on observable state, see
367
+ `asljs-data-binding`.
368
+
323
369
  [#1]: https://github.com/AlexandriteSoftware/asljs
@@ -0,0 +1,4 @@
1
+ export { eventful } from './eventful.js';
2
+ export { type EventfulLike, isEventfulLike, asEventfulLike, } from './eventful-like.js';
3
+ export { EventfulBase } from './eventful-base.js';
4
+ export { type EventName, type EventMap, type Eventful, type EventfulFactory, type EventfulOptions, type Listener, ListenerError, type TraceFn } from './types.js';
package/dist/index.js ADDED
@@ -0,0 +1,4 @@
1
+ export { eventful } from './eventful.js';
2
+ export { isEventfulLike, asEventfulLike, } from './eventful-like.js';
3
+ export { EventfulBase } from './eventful-base.js';
4
+ export { ListenerError } from './types.js';
package/package.json CHANGED
@@ -1,11 +1,9 @@
1
1
  {
2
2
  "name": "asljs-eventful",
3
- "version": "0.4.6",
3
+ "version": "0.4.9",
4
4
  "description": "Lightweight event helper adding on/off/emit to any object.",
5
5
  "files": [
6
6
  "dist/**",
7
- "eventful.js",
8
- "eventful.d.ts",
9
7
  "README.md",
10
8
  "LICENSE.md"
11
9
  ],
@@ -25,12 +23,12 @@
25
23
  "license": "MIT",
26
24
  "author": "\"Alex Netkachov\" <alex.netkachov@gmail.com>",
27
25
  "type": "module",
28
- "main": "eventful.js",
29
- "types": "eventful.d.ts",
26
+ "main": "dist/index.js",
27
+ "types": "dist/index.d.ts",
30
28
  "exports": {
31
29
  ".": {
32
- "types": "./eventful.d.ts",
33
- "default": "./eventful.js"
30
+ "types": "./dist/index.d.ts",
31
+ "default": "./dist/index.js"
34
32
  }
35
33
  },
36
34
  "directories": {
@@ -40,14 +38,16 @@
40
38
  "clean": "node ../toolkit.js clean-dist",
41
39
  "build": "npx tsc -p tsconfig.build.json",
42
40
  "build:test": "npx tsc -p tsconfig.test.json",
41
+ "typecheck": "npx tsc -p tsconfig.build.json --noEmit",
43
42
  "lint": "npx eslint .",
44
43
  "lint:fix": "npx eslint . --fix",
45
44
  "guard:clean-git": "node ../toolkit.js ensure-clean-working-folder",
46
45
  "prepack": "npm run clean && npm run build",
47
- "prepublishOnly": "npm run guard:clean-git && npm run prepack",
46
+ "prepublishOnly": "npm run prepack",
48
47
  "postpublish": "node ../toolkit.js tag-commit-with-release-id",
49
48
  "test": "npm run build:test && node --test dist/*.test.js",
50
49
  "test:watch": "npm run build:test && node --watch --test dist/*.test.js",
51
- "coverage": "npm run build:test && NODE_V8_COVERAGE=.coverage node --test dist/*.test.js && node -e \"console.log('Coverage in .coverage (use c8/istanbul if you want reports)')\""
50
+ "coverage": "npm run build:test && NODE_V8_COVERAGE=.coverage node --test dist/*.test.js && node -e \"console.log('Coverage in .coverage (use c8/istanbul if you want reports)')\"",
51
+ "release:patch": "node ../toolkit.js release-patch"
52
52
  }
53
53
  }
package/eventful.d.ts DELETED
@@ -1,24 +0,0 @@
1
- export {
2
- eventful,
3
- isEventfulLike,
4
- asEventfulLike
5
- } from './dist/eventful.js';
6
-
7
- export {
8
- EventfulBase
9
- } from './dist/eventful-base.js';
10
-
11
- export type {
12
- EventfulLike
13
- } from './dist/eventful-like.js';
14
-
15
- export {
16
- type EventName,
17
- type EventMap,
18
- type Eventful,
19
- type EventfulFactory,
20
- type EventfulOptions,
21
- type Listener,
22
- ListenerError,
23
- type TraceFn
24
- } from './dist/types.js';
package/eventful.js DELETED
@@ -1,13 +0,0 @@
1
- export {
2
- eventful,
3
- isEventfulLike,
4
- asEventfulLike,
5
- } from './dist/eventful.js';
6
-
7
- export {
8
- EventfulBase,
9
- } from './dist/eventful-base.js';
10
-
11
- export {
12
- ListenerError
13
- } from './dist/types.js';