script.io.js 1.0.1248 → 1.0.1611

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.
@@ -121,6 +121,64 @@ Define (Date, "time", function () { return Date.now (); });
121
121
  Define (Date, "timeout", function (context, second = 1) { return setTimeout (context, (second * 1000)); });
122
122
  Define (Date.timeout, "clear", function (context) { return clearTimeout (context); });
123
123
 
124
+ /**
125
+ * event
126
+ *
127
+ * title
128
+ * description
129
+ * sub description
130
+ *
131
+ * xxx://xxx.xxx.xxx/xxx
132
+ */
133
+
134
+ Define (Event, "io", class {
135
+ constructor () {
136
+ this.data = {}
137
+ }
138
+ on (key, value) {
139
+ if (this.data [key]) this.data [key].push (value);
140
+ else this.data [key] = [value];
141
+ }
142
+ emit (key, ... value) {
143
+ var e;
144
+ for (var i in this.data [key]) {
145
+ e = this.data [key][i] (... value);
146
+ }
147
+ return e;
148
+ }
149
+ });
150
+
151
+ Define (Event, "proto", function (proto) {
152
+ proto.event = proto.event || Object.create (null);
153
+ proto.on = function (key, value) {
154
+ if (proto.event [key]) proto.event [key].push (value);
155
+ else proto.event [key] = [value];
156
+ }
157
+ proto.emit = function (key, ... value) {
158
+ var e;
159
+ for (var i in proto.event [key]) {
160
+ e = proto.event [key][i] (... value);
161
+ }
162
+ return e;
163
+ }
164
+ });
165
+
166
+ /**
167
+ * promise
168
+ *
169
+ * title
170
+ * description
171
+ * sub description
172
+ *
173
+ * xxx://xxx.xxx.xxx/xxx
174
+ */
175
+
176
+ Define (Promise, "io", function (context) {
177
+ return new Promise (function (resolve, reject) {
178
+ context (function (value = true) { resolve (value); }, function (error = "") { reject (error); });
179
+ });
180
+ });
181
+
124
182
  /**
125
183
  * url
126
184
  *
@@ -431,7 +489,8 @@ Define (Function.html, "markup", class {
431
489
  Symbol.export = {
432
490
  define: Object.define,
433
491
  object: Object, array: Array, string: String, number: Number, function: Function,
434
- date: Date, time: Date.time, url: URL, json: JSON,
492
+ date: Date, time: Date.time, event: Event, promise: Promise,
493
+ url: URL, json: JSON,
435
494
  path: Function.path, file: Function.file, dir: Function.dir,
436
495
  html: Function.html,
437
496
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "script.io.js",
3
3
  "description": "Hello World",
4
- "version": "1.0.1248",
4
+ "version": "1.0.1611",
5
5
  "author": "Seindi Rahmat Barus <xseindi@gmail.com>",
6
6
  "contributors": [
7
7
  "Seindi Rahmat Barus <xseindi@gmail.com>"