@planet-matrix/mobius-model 0.3.0 → 0.5.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.
Files changed (91) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/README.md +30 -1
  3. package/dist/index.js +4 -2
  4. package/dist/index.js.map +22 -4
  5. package/package.json +3 -3
  6. package/scripts/build.ts +4 -4
  7. package/src/basic/README.md +144 -0
  8. package/src/basic/array.ts +872 -0
  9. package/src/basic/bigint.ts +114 -0
  10. package/src/basic/boolean.ts +180 -0
  11. package/src/basic/enhance.ts +10 -0
  12. package/src/basic/error.ts +51 -0
  13. package/src/basic/function.ts +453 -0
  14. package/src/basic/helper.ts +276 -0
  15. package/src/basic/index.ts +17 -0
  16. package/src/basic/is.ts +320 -0
  17. package/src/basic/number.ts +178 -0
  18. package/src/basic/object.ts +140 -0
  19. package/src/basic/promise.ts +464 -0
  20. package/src/basic/regexp.ts +7 -0
  21. package/src/basic/stream.ts +140 -0
  22. package/src/basic/string.ts +308 -0
  23. package/src/basic/symbol.ts +164 -0
  24. package/src/basic/temporal.ts +224 -0
  25. package/src/encoding/README.md +105 -0
  26. package/src/encoding/base64.ts +98 -0
  27. package/src/encoding/index.ts +1 -0
  28. package/src/index.ts +4 -0
  29. package/src/random/README.md +109 -0
  30. package/src/random/index.ts +1 -0
  31. package/src/random/uuid.ts +103 -0
  32. package/src/type/README.md +330 -0
  33. package/src/type/array.ts +5 -0
  34. package/src/type/boolean.ts +471 -0
  35. package/src/type/class.ts +419 -0
  36. package/src/type/function.ts +1519 -0
  37. package/src/type/helper.ts +135 -0
  38. package/src/type/index.ts +14 -0
  39. package/src/type/intersection.ts +93 -0
  40. package/src/type/is.ts +247 -0
  41. package/src/type/iteration.ts +233 -0
  42. package/src/type/number.ts +732 -0
  43. package/src/type/object.ts +788 -0
  44. package/src/type/path.ts +73 -0
  45. package/src/type/string.ts +1004 -0
  46. package/src/type/tuple.ts +2424 -0
  47. package/src/type/union.ts +108 -0
  48. package/tests/unit/basic/array.spec.ts +290 -0
  49. package/tests/unit/basic/bigint.spec.ts +50 -0
  50. package/tests/unit/basic/boolean.spec.ts +74 -0
  51. package/tests/unit/basic/error.spec.ts +32 -0
  52. package/tests/unit/basic/function.spec.ts +175 -0
  53. package/tests/unit/basic/helper.spec.ts +118 -0
  54. package/tests/unit/basic/number.spec.ts +74 -0
  55. package/tests/unit/basic/object.spec.ts +46 -0
  56. package/tests/unit/basic/promise.spec.ts +232 -0
  57. package/tests/unit/basic/regexp.spec.ts +11 -0
  58. package/tests/unit/basic/stream.spec.ts +120 -0
  59. package/tests/unit/basic/string.spec.ts +74 -0
  60. package/tests/unit/basic/symbol.spec.ts +72 -0
  61. package/tests/unit/basic/temporal.spec.ts +78 -0
  62. package/tests/unit/encoding/base64.spec.ts +40 -0
  63. package/tests/unit/random/uuid.spec.ts +37 -0
  64. package/dist/index.d.ts +0 -2
  65. package/dist/index.d.ts.map +0 -1
  66. package/dist/reactor/index.d.ts +0 -3
  67. package/dist/reactor/index.d.ts.map +0 -1
  68. package/dist/reactor/reactor-core/flags.d.ts +0 -99
  69. package/dist/reactor/reactor-core/flags.d.ts.map +0 -1
  70. package/dist/reactor/reactor-core/index.d.ts +0 -4
  71. package/dist/reactor/reactor-core/index.d.ts.map +0 -1
  72. package/dist/reactor/reactor-core/primitive.d.ts +0 -276
  73. package/dist/reactor/reactor-core/primitive.d.ts.map +0 -1
  74. package/dist/reactor/reactor-core/reactive-system.d.ts +0 -241
  75. package/dist/reactor/reactor-core/reactive-system.d.ts.map +0 -1
  76. package/dist/reactor/reactor-operators/branch.d.ts +0 -19
  77. package/dist/reactor/reactor-operators/branch.d.ts.map +0 -1
  78. package/dist/reactor/reactor-operators/convert.d.ts +0 -30
  79. package/dist/reactor/reactor-operators/convert.d.ts.map +0 -1
  80. package/dist/reactor/reactor-operators/create.d.ts +0 -26
  81. package/dist/reactor/reactor-operators/create.d.ts.map +0 -1
  82. package/dist/reactor/reactor-operators/filter.d.ts +0 -269
  83. package/dist/reactor/reactor-operators/filter.d.ts.map +0 -1
  84. package/dist/reactor/reactor-operators/index.d.ts +0 -8
  85. package/dist/reactor/reactor-operators/index.d.ts.map +0 -1
  86. package/dist/reactor/reactor-operators/join.d.ts +0 -48
  87. package/dist/reactor/reactor-operators/join.d.ts.map +0 -1
  88. package/dist/reactor/reactor-operators/map.d.ts +0 -165
  89. package/dist/reactor/reactor-operators/map.d.ts.map +0 -1
  90. package/dist/reactor/reactor-operators/utility.d.ts +0 -48
  91. package/dist/reactor/reactor-operators/utility.d.ts.map +0 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@planet-matrix/mobius-model",
3
- "version": "0.3.0",
3
+ "version": "0.5.0",
4
4
  "description": "Mobius model.",
5
5
  "keywords": [
6
6
  "mobius",
@@ -60,10 +60,10 @@
60
60
  },
61
61
  "dependencies": {},
62
62
  "devDependencies": {
63
- "@planet-matrix/mobius-mono": "0.6.0",
63
+ "@planet-matrix/mobius-mono": "0.7.0",
64
64
  "@types/bun": "^1.3.8",
65
65
  "oxlint": "^1.42.0",
66
- "oxlint-tsgolint": "^0.11.4",
66
+ "oxlint-tsgolint": "^0.13.0",
67
67
  "typescript": "^5.9.3",
68
68
  "@typescript/native-preview": "^7.0.0-dev.20260130.1",
69
69
  "vite": "^7.3.1",
package/scripts/build.ts CHANGED
@@ -4,8 +4,8 @@ import { $, build } from "bun"
4
4
  console.log("Cleaning and preparing ./dist directory...")
5
5
  await $`rm -rf dist`
6
6
 
7
- console.log("Building TypeScript declarations...")
8
- await $`bun run tsgo --noEmit false`
7
+ // console.log("Building TypeScript declarations...")
8
+ // await $`bun run tsgo --noEmit false`
9
9
 
10
10
  console.log("Building the library with Bun...")
11
11
  const builtOutput = await build({
@@ -36,8 +36,8 @@ const builtOutput = await build({
36
36
  outdir: "./dist",
37
37
  packages: "bundle",
38
38
  plugins: [],
39
- publicPath: undefined,
40
- root: undefined,
39
+ // publicPath: undefined,
40
+ // root: undefined,
41
41
  sourcemap: "linked",
42
42
  splitting: true,
43
43
  target: "bun",
@@ -0,0 +1,144 @@
1
+ # Basic
2
+
3
+ Runtime utilities for JavaScript primitives and built-in objects. This module focuses on safe, predictable helpers and type guards that you can use in everyday code.
4
+
5
+ ## For Users
6
+
7
+ This module provides runtime utilities organized by domain so you can quickly locate the right tool for a specific problem.
8
+
9
+ ### 1. Domain Areas
10
+
11
+ 1. Helper: Shared runtime helpers used across other domains.
12
+ 2. Is: Runtime predicates and type guards (primitives, objects, iterables, DOM/browser targets, and more).
13
+ 3. String: String generation, casing conversion, slicing, splitting, and truncation helpers.
14
+ 4. Number: Numeric normalization, range constraint, parity checks, and randomization helpers.
15
+ 5. Boolean: Boolean conversion and logical operation helpers.
16
+ 6. BigInt: BigInt-oriented helpers.
17
+ 7. Symbol: Symbol creation, inspection, and conversion helpers.
18
+ 8. Array: Array-oriented helpers and transformations.
19
+ 9. Object: Object field selection/exclusion, Date-field timestamp conversion, and object utility helpers.
20
+ 10. Function: Function composition and execution-control helpers (once, debounce, throttle, memoize, etc.).
21
+ 11. Temporal: Date/time formatting, relative-time, and humanization helpers.
22
+ 12. Error: Error detection and exception-stringify helpers.
23
+ 13. RegExp: RegExp-based validation helpers.
24
+ 14. Promise: Promise control-flow, queueing, retry, interval, and forever-loop helpers.
25
+ 15. Stream: ReadableStream construction, consumption, and transform helpers.
26
+ 16. Enhance: Runtime enhancement helpers (for example, BigInt JSON serialization support).
27
+
28
+ For a full list of exports, see the domain files (Helper, Is, String, Number, Boolean, BigInt, Symbol, Array, Object, Function, Temporal, Error, RegExp, Promise, Stream, Enhance).
29
+
30
+ ## For Contributors
31
+
32
+ This guide documents the conventions and best practices for implementing runtime utilities in this module. All implementations should follow these patterns for consistency and maintainability.
33
+
34
+ ### 1. Documentation and Comments
35
+
36
+ #### 1.1 JSDoc Comment Format
37
+
38
+ Every exported function should have a JSDoc comment following this structure:
39
+
40
+ ```typescript
41
+ /**
42
+ * Brief one-line description of what the function does.
43
+ *
44
+ * @example
45
+ * ```
46
+ * // Expect: true
47
+ * const example1 = isString("hello")
48
+ * // Expect: false
49
+ * const example2 = isString(123)
50
+ * ```
51
+ *
52
+ * @see {@link https://……}
53
+ */
54
+ export const isString = (value: unknown): value is string => {
55
+ ...
56
+ }
57
+ ```
58
+
59
+ **Documentation Rules:**
60
+ - First line: Clear, concise description starting with a verb (Check, Get, Convert, etc.)
61
+ - Add a blank line after the description
62
+ - Use `@example` tag followed by triple backticks
63
+ - Include multiple cases showing different scenarios
64
+ - Use comment format: `// Expect: <result>`
65
+ - Assign example results to variables like `example1`, `example2` to keep examples readable
66
+ - Place `@see`(if has) after the `@example` block, separated by a blank line
67
+ - Prefer deterministic examples; avoid randomness or time-dependent output in docs
68
+ - If a function returns a non-scalar, show the expected shape or key properties
69
+
70
+ ### 2. Runtime Implementation Patterns
71
+
72
+ #### 2.1 Prefer Type Predicates
73
+
74
+ Use type predicates for validation functions to maximize type safety:
75
+
76
+ ```typescript
77
+ export const isDate = (value: unknown): value is Date => {
78
+ return Object.prototype.toString.call(value) === "[object Date]"
79
+ }
80
+ ```
81
+
82
+ #### 2.2 Accept `unknown`
83
+
84
+ Public utilities should accept `unknown` unless there is a strong reason to require a narrower input type.
85
+
86
+ #### 2.3 Avoid Side Effects
87
+
88
+ Helpers should be deterministic and should not mutate input values unless explicitly documented.
89
+
90
+ #### 2.4 Helper Placement
91
+
92
+ - If a utility function uses helper variables or helper functions, place those helpers immediately before the utility function.
93
+ - Do not add blank lines between a helper and the utility function it supports.
94
+ - Helper variables and functions must be prefixed with `internal`.
95
+ - Helper variables and functions must never be exported.
96
+
97
+ #### 2.5 Spacing
98
+
99
+ - Separate different utility functions with a single blank line.
100
+
101
+ ### 3. Naming Conventions
102
+
103
+ #### 3.1 Function Name Format
104
+
105
+ All functions should follow a consistent naming pattern:
106
+
107
+ **Format:** `<domain><Operation><Qualifier>`
108
+
109
+ - `is*` for predicates and checks (for example, `isPlainObject`, `isFiniteNumber`)
110
+ - `string*` for string utilities (`stringRandom`, `stringTruncate`)
111
+ - `number*` for number utilities (`numberClamp`, `numberInRange`)
112
+ - `boolean*`, `date*`, `regexp*`, `error*`, `symbol*`, `bigint*` for other domains
113
+
114
+ #### 3.2 Common Verb Prefixes
115
+
116
+ - `is*` - Returns boolean for validation
117
+ - `has*` - Returns boolean for existence checks
118
+ - `get*` / `extract*` - Returns a value
119
+ - `to*` - Conversion operations
120
+
121
+ ### 4. Export Strategy
122
+
123
+ ```typescript
124
+ // Always export public functions
125
+ export const publicFunction = () => {}
126
+
127
+ // Never export internal helpers
128
+ const internalHelper = () => {}
129
+ ```
130
+
131
+ Keep domain exports in their files and re-export them via the barrel in `index.ts`.
132
+
133
+ ### 5. Common Pitfalls to Avoid
134
+
135
+ 1. Do not rely on `typeof` alone for objects (for example, `typeof null === "object"`).
136
+ 2. Do not confuse `NaN` with numbers that cannot be parsed.
137
+ 3. Do not treat boxed objects (`new String("x")`) as primitives without checks.
138
+ 4. Do not mutate inputs unless the function name and docs make it explicit.
139
+ 5. Do not introduce locale-dependent behavior without documenting it.
140
+
141
+ ### 6. Testing Requirements
142
+
143
+ - Write one test per function.
144
+ - If multiple cases are needed, include them within the same test.