mm_expand 1.9.4 → 1.9.6
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 +65 -1
- package/README_EN.md +65 -1
- package/index.js +11 -28
- package/lib/array.js +1 -1
- package/lib/object.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -82,6 +82,70 @@ $.eventer.pause('user:*'); // 暂停所有用户相关事件
|
|
|
82
82
|
$.eventer.resume('user:*'); // 恢复所有用户相关事件
|
|
83
83
|
```
|
|
84
84
|
|
|
85
|
+
## 模块导出
|
|
86
|
+
|
|
87
|
+
本库提供多种导出方式,支持按需导入和使用:
|
|
88
|
+
|
|
89
|
+
### 全局对象方式(推荐)
|
|
90
|
+
```javascript
|
|
91
|
+
const $ = require('mm_expand');
|
|
92
|
+
// 使用全局对象调用所有功能
|
|
93
|
+
$.copy({ a: 1 }); // 对象深拷贝
|
|
94
|
+
$.eventer.on('event', handler); // 事件监听
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
### 按需导入方式
|
|
98
|
+
```javascript
|
|
99
|
+
// 导入核心类
|
|
100
|
+
const { Event, Eventer, Lang, Base, File, Dir } = require('mm_expand');
|
|
101
|
+
|
|
102
|
+
// 导入对象操作函数
|
|
103
|
+
const { as, push, clear, toJson, copy, get, set } = require('mm_expand/lib/object.js');
|
|
104
|
+
|
|
105
|
+
// 导入数组构造函数
|
|
106
|
+
const { Array } = require('mm_expand/lib/array.js');
|
|
107
|
+
|
|
108
|
+
// 导入其他功能模块
|
|
109
|
+
const { Log } = require('mm_expand/lib/log.js');
|
|
110
|
+
const { Timer } = require('mm_expand/lib/timer.js');
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
### 主要导出模块
|
|
114
|
+
|
|
115
|
+
#### 核心类(index.js导出)
|
|
116
|
+
- **Event**: 事件类,用于创建和管理事件实例
|
|
117
|
+
- **Eventer**: 事件驱动类,提供完整的事件系统功能
|
|
118
|
+
- **Lang**: 语言包类,支持多语言国际化
|
|
119
|
+
- **Base**: 基础类,提供类创建和继承功能
|
|
120
|
+
- **File**: 文件操作类,提供文件读写功能
|
|
121
|
+
- **Dir**: 目录操作类,提供目录管理功能
|
|
122
|
+
|
|
123
|
+
#### 对象操作函数(object.js导出)
|
|
124
|
+
- **as**: 判断对象是否相似
|
|
125
|
+
- **push**: 合并对象属性
|
|
126
|
+
- **clear**: 清空对象值
|
|
127
|
+
- **toJson**: 对象转JSON字符串
|
|
128
|
+
- **toXml**: 对象转XML字符串
|
|
129
|
+
- **toUrl**: 对象转URL参数字符串
|
|
130
|
+
- **saveJson**: 对象保存为JSON文件
|
|
131
|
+
- **saveXml**: 对象保存为XML文件
|
|
132
|
+
- **copy**: 深度拷贝对象
|
|
133
|
+
- **keys**: 获取对象属性名
|
|
134
|
+
- **getInfo**: 获取对象详细信息
|
|
135
|
+
- **add**: 添加对象属性
|
|
136
|
+
- **del**: 删除对象属性
|
|
137
|
+
- **set**: 修改对象属性
|
|
138
|
+
- **get**: 查询对象属性
|
|
139
|
+
- **prop**: 遍历读写对象属性
|
|
140
|
+
- **arrToObj**: 数组转对象
|
|
141
|
+
|
|
142
|
+
#### 数组构造函数(array.js导出)
|
|
143
|
+
- **Array**: 增强的数组构造函数,包含所有数组原型扩展方法
|
|
144
|
+
|
|
145
|
+
#### 其他功能模块
|
|
146
|
+
- **Log**: 日志类,提供日志记录功能
|
|
147
|
+
- **Timer**: 定时器类,提供定时任务功能
|
|
148
|
+
|
|
85
149
|
## API文档
|
|
86
150
|
|
|
87
151
|
### 全局工具函数
|
|
@@ -624,7 +688,7 @@ A: 目前提供基本的JavaScript支持,TypeScript类型定义正在规划中
|
|
|
624
688
|
## npm发布信息
|
|
625
689
|
|
|
626
690
|
### 发布状态
|
|
627
|
-
- **当前版本**: 1.9.
|
|
691
|
+
- **当前版本**: 1.9.6
|
|
628
692
|
- **npm包名**: mm_expand
|
|
629
693
|
- **发布状态**: 已准备发布
|
|
630
694
|
|
package/README_EN.md
CHANGED
|
@@ -108,6 +108,70 @@ $.eventer.pause('user:*'); // Pause all user-related events
|
|
|
108
108
|
$.eventer.resume('user:*'); // Resume all user-related events
|
|
109
109
|
```
|
|
110
110
|
|
|
111
|
+
## Module Exports
|
|
112
|
+
|
|
113
|
+
This library provides multiple export methods supporting on-demand import and usage:
|
|
114
|
+
|
|
115
|
+
### Global Object Method (Recommended)
|
|
116
|
+
```javascript
|
|
117
|
+
const $ = require('mm_expand');
|
|
118
|
+
// Use global object to access all functionality
|
|
119
|
+
$.copy({ a: 1 }); // Object deep copy
|
|
120
|
+
$.eventer.on('event', handler); // Event listening
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
### On-demand Import Method
|
|
124
|
+
```javascript
|
|
125
|
+
// Import core classes
|
|
126
|
+
const { Event, Eventer, Lang, Base, File, Dir } = require('mm_expand');
|
|
127
|
+
|
|
128
|
+
// Import object operation functions
|
|
129
|
+
const { as, push, clear, toJson, copy, get, set } = require('mm_expand/lib/object.js');
|
|
130
|
+
|
|
131
|
+
// Import array constructor
|
|
132
|
+
const { Array } = require('mm_expand/lib/array.js');
|
|
133
|
+
|
|
134
|
+
// Import other functional modules
|
|
135
|
+
const { Log } = require('mm_expand/lib/log.js');
|
|
136
|
+
const { Timer } = require('mm_expand/lib/timer.js');
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
### Main Export Modules
|
|
140
|
+
|
|
141
|
+
#### Core Classes (index.js exports)
|
|
142
|
+
- **Event**: Event class for creating and managing event instances
|
|
143
|
+
- **Eventer**: Event-driven class providing complete event system functionality
|
|
144
|
+
- **Lang**: Language pack class supporting multilingual internationalization
|
|
145
|
+
- **Base**: Base class providing class creation and inheritance functionality
|
|
146
|
+
- **File**: File operation class providing file read/write functionality
|
|
147
|
+
- **Dir**: Directory operation class providing directory management functionality
|
|
148
|
+
|
|
149
|
+
#### Object Operation Functions (object.js exports)
|
|
150
|
+
- **as**: Determine if objects are similar
|
|
151
|
+
- **push**: Merge object properties
|
|
152
|
+
- **clear**: Clear object values
|
|
153
|
+
- **toJson**: Convert object to JSON string
|
|
154
|
+
- **toXml**: Convert object to XML string
|
|
155
|
+
- **toUrl**: Convert object to URL parameter string
|
|
156
|
+
- **saveJson**: Save object as JSON file
|
|
157
|
+
- **saveXml**: Save object as XML file
|
|
158
|
+
- **copy**: Deep copy object
|
|
159
|
+
- **keys**: Get object property names
|
|
160
|
+
- **getInfo**: Get object detailed information
|
|
161
|
+
- **add**: Add object properties
|
|
162
|
+
- **del**: Delete object properties
|
|
163
|
+
- **set**: Modify object properties
|
|
164
|
+
- **get**: Query object properties
|
|
165
|
+
- **prop**: Traverse and read/write object properties
|
|
166
|
+
- **arrToObj**: Convert array to object
|
|
167
|
+
|
|
168
|
+
#### Array Constructor (array.js exports)
|
|
169
|
+
- **Array**: Enhanced array constructor containing all array prototype extension methods
|
|
170
|
+
|
|
171
|
+
#### Other Functional Modules
|
|
172
|
+
- **Log**: Log class providing logging functionality
|
|
173
|
+
- **Timer**: Timer class providing scheduled task functionality
|
|
174
|
+
|
|
111
175
|
## API Documentation
|
|
112
176
|
|
|
113
177
|
### Global Utility Functions
|
|
@@ -630,7 +694,7 @@ Welcome to submit Issues and Pull Requests! Please ensure your code follows thes
|
|
|
630
694
|
4. Run tests before submitting to ensure no new issues are introduced
|
|
631
695
|
|
|
632
696
|
## Release Status
|
|
633
|
-
- **Current Version**: 1.9.
|
|
697
|
+
- **Current Version**: 1.9.6
|
|
634
698
|
- **npm Package Name**: mm_expand
|
|
635
699
|
- **Release Status**: Ready for release
|
|
636
700
|
|
package/index.js
CHANGED
|
@@ -15,36 +15,17 @@ require('./lib/array.js');
|
|
|
15
15
|
// 日期原型函数
|
|
16
16
|
require('./lib/date.js');
|
|
17
17
|
|
|
18
|
-
// 确保原型方法被应用到全局原型
|
|
19
|
-
const numberModule = require('./lib/number.js');
|
|
20
|
-
const stringModule = require('./lib/string.js');
|
|
21
|
-
const arrayModule = require('./lib/array.js');
|
|
22
|
-
const dateModule = require('./lib/date.js');
|
|
23
|
-
|
|
24
|
-
// 应用原型方法到全局原型
|
|
25
|
-
if (global.Number && numberModule.Number) {
|
|
26
|
-
Object.assign(global.Number.prototype, numberModule.Number.prototype);
|
|
27
|
-
}
|
|
28
|
-
if (global.String && stringModule.String) {
|
|
29
|
-
Object.assign(global.String.prototype, stringModule.String.prototype);
|
|
30
|
-
}
|
|
31
|
-
if (global.Array && arrayModule.Array) {
|
|
32
|
-
Object.assign(global.Array.prototype, arrayModule.Array.prototype);
|
|
33
|
-
}
|
|
34
|
-
if (global.Date && dateModule.Date) {
|
|
35
|
-
Object.assign(global.Date.prototype, dateModule.Date.prototype);
|
|
36
|
-
}
|
|
37
|
-
|
|
38
18
|
var { File, Dir } = require('./lib/file.js');
|
|
39
|
-
var { Obj } = require('./lib/object.js');
|
|
40
19
|
var { Log } = require('./lib/log.js');
|
|
41
20
|
var { Eventer } = require('./lib/eventer.js');
|
|
42
21
|
var { Lang } = require('./lib/lang.js');
|
|
22
|
+
var { Event } = require('./lib/event.js');
|
|
43
23
|
var { Base } = require('./lib/base.js');
|
|
44
24
|
var { Timer } = require('./lib/timer.js');
|
|
45
25
|
|
|
26
|
+
|
|
46
27
|
if (global.$ && !$.is_init) {
|
|
47
|
-
Object.assign($,
|
|
28
|
+
Object.assign($, require('./lib/object.js'), {
|
|
48
29
|
// 基础类
|
|
49
30
|
Base,
|
|
50
31
|
// 文件类
|
|
@@ -70,9 +51,11 @@ if (global.$ && !$.is_init) {
|
|
|
70
51
|
$.is_init = true;
|
|
71
52
|
}
|
|
72
53
|
|
|
73
|
-
exports
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
54
|
+
module.exports = {
|
|
55
|
+
Event,
|
|
56
|
+
Eventer,
|
|
57
|
+
Lang,
|
|
58
|
+
Base,
|
|
59
|
+
File,
|
|
60
|
+
Dir
|
|
61
|
+
}
|
package/lib/array.js
CHANGED
package/lib/object.js
CHANGED