@mobilabs/es6lib 2.2.1 → 2.3.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.
@@ -9,10 +9,10 @@
9
9
  * Private Functions:
10
10
  * . _help displays the help message,
11
11
  * . _clean removes the previous js production files,
12
- * . _makeminifiedm builds and minifies the ES6 module production file,
13
- * . _makeminified builds and minifies the js production file,
14
- * . _copydevm builds the ES6 module production file,
15
12
  * . _copydev builds the js production file,
13
+ * . _copydevm builds the ES6 module production file,
14
+ * . _makeminified builds and minifies the js production file,
15
+ * . _makeminifiedm builds and minifies the ES6 module production file,
16
16
  * . _doLibs builds the js production libraries,
17
17
  *
18
18
  *
@@ -98,7 +98,7 @@ function _help() {
98
98
  * @function (arg1)
99
99
  * @private
100
100
  * @param {Function} the function to call at the completion,
101
- * @returns {} -,
101
+ * @returns {object} returns a promise,
102
102
  * @since 0.0.0
103
103
  */
104
104
  function _clean(done) {
@@ -122,7 +122,7 @@ function _clean(done) {
122
122
  }
123
123
 
124
124
  /**
125
- * Builds and minifies the ES6 module production file.
125
+ * Builds the js production file.
126
126
  *
127
127
  * @function (arg1)
128
128
  * @private
@@ -130,26 +130,50 @@ function _clean(done) {
130
130
  * @returns {} -,
131
131
  * @since 0.0.0
132
132
  */
133
- function _makeminifiedm(done) {
133
+ function _copydev(done) {
134
134
  const d1 = new Date();
135
- process.stdout.write('Starting \'\x1b[36mmake:minified:es6\x1b[89m\x1b[0m\'...\n');
135
+ process.stdout.write("Starting '\x1b[36mcopy:umd\x1b[89m\x1b[0m'...\n");
136
136
 
137
- fs.readFile(`${libdir}/${name}.mjs`, 'utf8', (err1, data) => {
137
+ fs.readFile(`${libdir}/${name}.js`, 'utf8', (err1, data) => {
138
138
  if (err1) throw new Error(err1);
139
139
 
140
140
  let content = license;
141
- content += data.replace(/\/\*! \*\*\*/g, '/** ***');
141
+ content += data;
142
+ fs.writeFile(`${dist}/lib/${name}.js`, content, { encoding: 'utf8' }, (err2) => {
143
+ if (err2) throw new Error(err2);
142
144
 
143
- minify(content, {})
144
- .then((result) => {
145
- fs.writeFile(`${dist}/lib/${name}.min.mjs`, result.code, { encoding: 'utf8' }, (err2) => {
146
- if (err2) throw new Error(err2);
145
+ const d2 = new Date() - d1;
146
+ process.stdout.write(`Finished '\x1b[36mcopy:umd\x1b[89m\x1b[0m' after \x1b[35m${d2} ms\x1b[89m\x1b[0m\n`);
147
+ done();
148
+ });
149
+ });
150
+ }
147
151
 
148
- const d2 = new Date() - d1;
149
- process.stdout.write(`Finished '\x1b[36mmake:minified:es6\x1b[89m\x1b[0m' after \x1b[35m${d2} ms\x1b[89m\x1b[0m\n`);
150
- done();
151
- });
152
- });
152
+ /**
153
+ * Builds the ES6 module production file.
154
+ *
155
+ * @function (arg1)
156
+ * @private
157
+ * @param {Function} the function to call at the completion,
158
+ * @returns {} -,
159
+ * @since 0.0.0
160
+ */
161
+ function _copydevm(done) {
162
+ const d1 = new Date();
163
+ process.stdout.write("Starting '\x1b[36mcopy:es6\x1b[89m\x1b[0m'...\n");
164
+
165
+ fs.readFile(`${libdir}/${name}.mjs`, 'utf8', (err1, data) => {
166
+ if (err1) throw new Error(err1);
167
+
168
+ let content = license;
169
+ content += data;
170
+ fs.writeFile(`${dist}/lib/${name}.mjs`, content, { encoding: 'utf8' }, (err2) => {
171
+ if (err2) throw new Error(err2);
172
+
173
+ const d2 = new Date() - d1;
174
+ process.stdout.write(`Finished '\x1b[36mcopy:es6\x1b[89m\x1b[0m' after \x1b[35m${d2} ms\x1b[89m\x1b[0m\n`);
175
+ done();
176
+ });
153
177
  });
154
178
  }
155
179
 
@@ -186,7 +210,7 @@ function _makeminified(done) {
186
210
  }
187
211
 
188
212
  /**
189
- * Builds the ES6 module production file.
213
+ * Builds and minifies the ES6 module production file.
190
214
  *
191
215
  * @function (arg1)
192
216
  * @private
@@ -194,50 +218,26 @@ function _makeminified(done) {
194
218
  * @returns {} -,
195
219
  * @since 0.0.0
196
220
  */
197
- function _copydevm(done) {
221
+ function _makeminifiedm(done) {
198
222
  const d1 = new Date();
199
- process.stdout.write("Starting '\x1b[36mcopy:es6\x1b[89m\x1b[0m'...\n");
223
+ process.stdout.write('Starting \'\x1b[36mmake:minified:es6\x1b[89m\x1b[0m\'...\n');
200
224
 
201
225
  fs.readFile(`${libdir}/${name}.mjs`, 'utf8', (err1, data) => {
202
226
  if (err1) throw new Error(err1);
203
227
 
204
228
  let content = license;
205
- content += data;
206
- fs.writeFile(`${dist}/lib/${name}.mjs`, content, { encoding: 'utf8' }, (err2) => {
207
- if (err2) throw new Error(err2);
208
-
209
- const d2 = new Date() - d1;
210
- process.stdout.write(`Finished '\x1b[36mcopy:es6\x1b[89m\x1b[0m' after \x1b[35m${d2} ms\x1b[89m\x1b[0m\n`);
211
- done();
212
- });
213
- });
214
- }
215
-
216
- /**
217
- * Builds the js production file.
218
- *
219
- * @function (arg1)
220
- * @private
221
- * @param {Function} the function to call at the completion,
222
- * @returns {} -,
223
- * @since 0.0.0
224
- */
225
- function _copydev(done) {
226
- const d1 = new Date();
227
- process.stdout.write("Starting '\x1b[36mcopy:umd\x1b[89m\x1b[0m'...\n");
228
-
229
- fs.readFile(`${libdir}/${name}.js`, 'utf8', (err1, data) => {
230
- if (err1) throw new Error(err1);
229
+ content += data.replace(/\/\*! \*\*\*/g, '/** ***');
231
230
 
232
- let content = license;
233
- content += data;
234
- fs.writeFile(`${dist}/lib/${name}.js`, content, { encoding: 'utf8' }, (err2) => {
235
- if (err2) throw new Error(err2);
231
+ minify(content, {})
232
+ .then((result) => {
233
+ fs.writeFile(`${dist}/lib/${name}.min.mjs`, result.code, { encoding: 'utf8' }, (err2) => {
234
+ if (err2) throw new Error(err2);
236
235
 
237
- const d2 = new Date() - d1;
238
- process.stdout.write(`Finished '\x1b[36mcopy:umd\x1b[89m\x1b[0m' after \x1b[35m${d2} ms\x1b[89m\x1b[0m\n`);
239
- done();
240
- });
236
+ const d2 = new Date() - d1;
237
+ process.stdout.write(`Finished '\x1b[36mmake:minified:es6\x1b[89m\x1b[0m' after \x1b[35m${d2} ms\x1b[89m\x1b[0m\n`);
238
+ done();
239
+ });
240
+ });
241
241
  });
242
242
  }
243
243
 
@@ -269,52 +269,55 @@ function _doLibs(done) {
269
269
  }
270
270
 
271
271
 
272
- // -- Main ---------------------------------------------------------------------
272
+ // -- Public Static Methods ----------------------------------------------------
273
273
 
274
- /**
275
- * Executes the script.
276
- *
277
- * @function ()
278
- * @public
279
- * @param {} -,
280
- * @returns {} -,
281
- * @since 0.0.0
282
- */
283
- async function run() {
284
- const PENDING = 1;
274
+ const Lib = {
285
275
 
286
- if (parsed.help) {
287
- _help();
288
- return;
289
- }
276
+ /**
277
+ * Executes the script.
278
+ *
279
+ * @method ()
280
+ * @public
281
+ * @param {} -,
282
+ * @returns {} -,
283
+ * @since 0.0.0
284
+ */
285
+ async run() {
286
+ const PENDING = 1;
287
+
288
+ if (parsed.help) {
289
+ _help();
290
+ return;
291
+ }
290
292
 
291
- if (parsed.version) {
292
- process.stdout.write(`version: ${parsed.version}\n`);
293
- return;
294
- }
293
+ if (parsed.version) {
294
+ process.stdout.write(`version: ${parsed.version}\n`);
295
+ return;
296
+ }
295
297
 
296
- const d1 = new Date();
297
- process.stdout.write('Starting \'\x1b[36mbuild:js:prod\x1b[89m\x1b[0m\'...\n');
298
+ const d1 = new Date();
299
+ process.stdout.write('Starting \'\x1b[36mbuild:js:prod\x1b[89m\x1b[0m\'...\n');
298
300
 
299
- let pending = PENDING;
300
- /**
301
- * Executes done until completion.
302
- */
303
- function done() {
304
- pending -= 1;
305
- if (!pending) {
306
- const d2 = new Date() - d1;
307
- process.stdout.write(`Finished '\x1b[36mbuild:js:prod\x1b[89m\x1b[0m' after \x1b[35m${d2} ms\x1b[89m\x1b[0m\n`);
301
+ let pending = PENDING;
302
+ /**
303
+ * Executes done until completion.
304
+ */
305
+ function done() {
306
+ pending -= 1;
307
+ if (!pending) {
308
+ const d2 = new Date() - d1;
309
+ process.stdout.write(`Finished '\x1b[36mbuild:js:prod\x1b[89m\x1b[0m' after \x1b[35m${d2} ms\x1b[89m\x1b[0m\n`);
310
+ }
308
311
  }
309
- }
310
312
 
311
- await _clean();
312
- _doLibs(done);
313
- }
313
+ await _clean();
314
+ _doLibs(done);
315
+ },
316
+ };
314
317
 
315
318
 
316
- // Start script.
317
- run();
319
+ // -- Where the script starts --------------------------------------------------
320
+ Lib.run();
318
321
 
319
322
 
320
323
  // -- oOo --
@@ -8,7 +8,7 @@
8
8
  *
9
9
  * Private Functions:
10
10
  * . _help displays the help message,
11
- * . _clean removes the previous production folder,
11
+ * . _clean removes the previous production build,
12
12
  * . _doskeleton creates the production folder and copies files,
13
13
  *
14
14
  *
@@ -87,15 +87,15 @@ function _help() {
87
87
  }
88
88
 
89
89
  /**
90
- * Removes the previous production folder,
90
+ * Removes the previous production build.
91
91
  *
92
- * @function ()
92
+ * @function ([arg1])
93
93
  * @private
94
- * @param {} -,
94
+ * @param {Function} the function to call at the completion,
95
95
  * @returns {Object} returns a promise,
96
96
  * @since 0.0.0
97
97
  */
98
- function _clean() {
98
+ function _clean(done) {
99
99
  const d1 = new Date();
100
100
  process.stdout.write('Starting \'\x1b[36mclean\x1b[89m\x1b[0m\'...\n');
101
101
 
@@ -106,6 +106,7 @@ function _clean() {
106
106
  const d2 = new Date() - d1;
107
107
  process.stdout.write(`Finished '\x1b[36mclean\x1b[89m\x1b[0m' after \x1b[35m${d2} ms\x1b[89m\x1b[0m\n`);
108
108
  resolve();
109
+ if (done) done();
109
110
  });
110
111
  });
111
112
  }
@@ -121,7 +122,7 @@ function _clean() {
121
122
  */
122
123
  function _doskeleton(done) {
123
124
  const d1 = new Date();
124
- process.stdout.write('Starting \'\x1b[36mdoskeleton\x1b[89m\x1b[0m\'...\n');
125
+ process.stdout.write('Starting \'\x1b[36mdo:skeleton\x1b[89m\x1b[0m\'...\n');
125
126
 
126
127
  /**
127
128
  * Wait all processes completed;
@@ -131,7 +132,7 @@ function _doskeleton(done) {
131
132
  pending -= 1;
132
133
  if (!pending) {
133
134
  const d2 = new Date() - d1;
134
- process.stdout.write(`Finished '\x1b[36mdoskeleton\x1b[89m\x1b[0m' after \x1b[35m${d2} ms\x1b[89m\x1b[0m\n`);
135
+ process.stdout.write(`Finished '\x1b[36mdo:skeleton\x1b[89m\x1b[0m' after \x1b[35m${d2} ms\x1b[89m\x1b[0m\n`);
135
136
  done();
136
137
  }
137
138
  }
@@ -147,52 +148,55 @@ function _doskeleton(done) {
147
148
  }
148
149
 
149
150
 
150
- // -- Main ---------------------------------------------------------------------
151
-
152
- /**
153
- * Executes the script.
154
- *
155
- * @function ()
156
- * @public
157
- * @param {} -,
158
- * @returns {} -,
159
- * @since 0.0.0
160
- */
161
- async function run() {
162
- const PENDING = 1;
151
+ // -- Public Static Methods ----------------------------------------------------
163
152
 
164
- if (parsed.help) {
165
- _help();
166
- return;
167
- }
153
+ const Lib = {
168
154
 
169
- if (parsed.version) {
170
- process.stdout.write(`version: ${parsed.version}\n`);
171
- return;
172
- }
155
+ /**
156
+ * Executes the script.
157
+ *
158
+ * @method ()
159
+ * @public
160
+ * @param {} -,
161
+ * @returns {} -,
162
+ * @since 0.0.0
163
+ */
164
+ async run() {
165
+ const PENDING = 1;
166
+
167
+ if (parsed.help) {
168
+ _help();
169
+ return;
170
+ }
173
171
 
174
- const d1 = new Date();
175
- process.stdout.write('Starting \'\x1b[36mbuild:skeleton:prod\x1b[89m\x1b[0m\'...\n');
172
+ if (parsed.version) {
173
+ process.stdout.write(`version: ${parsed.version}\n`);
174
+ return;
175
+ }
176
176
 
177
- let pending = PENDING;
178
- /**
179
- * Executes done until completion.
180
- */
181
- function done() {
182
- pending -= 1;
183
- if (!pending) {
184
- const d2 = new Date() - d1;
185
- process.stdout.write(`Finished '\x1b[36mbuild:skeleton:prod\x1b[89m\x1b[0m' after \x1b[35m${d2} ms\x1b[89m\x1b[0m\n`);
177
+ const d1 = new Date();
178
+ process.stdout.write('Starting \'\x1b[36mbuild:skeleton:prod\x1b[89m\x1b[0m\'...\n');
179
+
180
+ let pending = PENDING;
181
+ /**
182
+ * Executes done until completion.
183
+ */
184
+ function done() {
185
+ pending -= 1;
186
+ if (!pending) {
187
+ const d2 = new Date() - d1;
188
+ process.stdout.write(`Finished '\x1b[36mbuild:skeleton:prod\x1b[89m\x1b[0m' after \x1b[35m${d2} ms\x1b[89m\x1b[0m\n`);
189
+ }
186
190
  }
187
- }
188
191
 
189
- await _clean();
190
- _doskeleton(done);
191
- }
192
+ await _clean();
193
+ _doskeleton(done);
194
+ },
195
+ };
192
196
 
193
197
 
194
- // Start script.
195
- run();
198
+ // -- Where the script starts --------------------------------------------------
199
+ Lib.run();
196
200
 
197
201
 
198
202
  // -- oOo --
@@ -39,3 +39,6 @@ cd ${NPM}/${name}/${VERSION}
39
39
  tar zcvf ${name}.tgz ${name}/
40
40
  rm -rf ${name}
41
41
  echo 'Done!'
42
+
43
+
44
+ # -- oOo --
package/scripts/config.js CHANGED
@@ -1,3 +1,16 @@
1
+ /** ************************************************************************
2
+ *
3
+ * Configuration file.
4
+ *
5
+ *
6
+ *
7
+ * @namespace -
8
+ * @dependencies none
9
+ * @exports -
10
+ * @author -
11
+ * @since 0.0.0
12
+ * @version -
13
+ * ********************************************************************** */
1
14
  /* eslint one-var: 0, semi-style: 0 */
2
15
 
3
16
  'use strict';
@@ -92,13 +92,13 @@ function _help() {
92
92
  /**
93
93
  * Removes the previous build.
94
94
  *
95
- * @function ()
95
+ * @function ([arg1])
96
96
  * @private
97
- * @param {} -,
97
+ * @param {Function} the function to call at the completion,
98
98
  * @returns {Object} returns a promise,
99
99
  * @since 0.0.0
100
100
  */
101
- function _clean() {
101
+ function _clean(done) {
102
102
  const d1 = new Date();
103
103
  process.stdout.write('Starting \'\x1b[36mclean\x1b[89m\x1b[0m\'...\n');
104
104
 
@@ -112,6 +112,7 @@ function _clean() {
112
112
  const d2 = new Date() - d1;
113
113
  process.stdout.write(`Finished '\x1b[36mclean\x1b[89m\x1b[0m' after \x1b[35m${d2} ms\x1b[89m\x1b[0m\n`);
114
114
  resolve();
115
+ if (done) done();
115
116
  });
116
117
  });
117
118
  });
@@ -128,7 +129,7 @@ function _clean() {
128
129
  */
129
130
  function _copyindex(done) {
130
131
  const d1 = new Date();
131
- process.stdout.write('Starting \'\x1b[36mcopyindex\x1b[89m\x1b[0m\'...\n');
132
+ process.stdout.write('Starting \'\x1b[36mcopy:index\x1b[89m\x1b[0m\'...\n');
132
133
 
133
134
  fs.readFile(index, 'utf8', (err1, data) => {
134
135
  if (err1) throw new Error(err1);
@@ -138,7 +139,7 @@ function _copyindex(done) {
138
139
  if (err2) throw new Error(err2);
139
140
 
140
141
  const d2 = new Date() - d1;
141
- process.stdout.write(`Finished '\x1b[36mcopyindex\x1b[89m\x1b[0m' after \x1b[35m${d2} ms\x1b[89m\x1b[0m\n`);
142
+ process.stdout.write(`Finished '\x1b[36mcopy:index\x1b[89m\x1b[0m' after \x1b[35m${d2} ms\x1b[89m\x1b[0m\n`);
142
143
  done();
143
144
  });
144
145
  });
@@ -155,7 +156,7 @@ function _copyindex(done) {
155
156
  */
156
157
  function _copypackagejson(done) {
157
158
  const d1 = new Date();
158
- process.stdout.write('Starting \'\x1b[36mcopypackagejson\x1b[89m\x1b[0m\'...\n');
159
+ process.stdout.write('Starting \'\x1b[36mcopy:package:json\x1b[89m\x1b[0m\'...\n');
159
160
 
160
161
  fs.readFile('./package.json', 'utf8', (err1, data) => {
161
162
  if (err1) throw new Error(err1);
@@ -173,60 +174,63 @@ function _copypackagejson(done) {
173
174
  if (err2) throw new Error(err2);
174
175
 
175
176
  const d2 = new Date() - d1;
176
- process.stdout.write(`Finished '\x1b[36mcopypackagejson\x1b[89m\x1b[0m' after \x1b[35m${d2} ms\x1b[89m\x1b[0m\n`);
177
+ process.stdout.write(`Finished '\x1b[36mcopy:package:json\x1b[89m\x1b[0m' after \x1b[35m${d2} ms\x1b[89m\x1b[0m\n`);
177
178
  done();
178
179
  });
179
180
  });
180
181
  }
181
182
 
182
183
 
183
- // -- Main ---------------------------------------------------------------------
184
+ // -- Public Static Methods ----------------------------------------------------
184
185
 
185
- /**
186
- * Executes the script.
187
- *
188
- * @function ()
189
- * @public
190
- * @param {} -,
191
- * @returns {} -,
192
- * @since 0.0.0
193
- */
194
- async function run() {
195
- const PENDING = 2;
186
+ const Lib = {
196
187
 
197
- if (parsed.help) {
198
- _help();
199
- return;
200
- }
188
+ /**
189
+ * Executes the script.
190
+ *
191
+ * @method ()
192
+ * @public
193
+ * @param {} -,
194
+ * @returns {} -,
195
+ * @since 0.0.0
196
+ */
197
+ async run() {
198
+ const PENDING = 2;
199
+
200
+ if (parsed.help) {
201
+ _help();
202
+ return;
203
+ }
201
204
 
202
- if (parsed.version) {
203
- process.stdout.write(`version: ${parsed.version}\n`);
204
- return;
205
- }
205
+ if (parsed.version) {
206
+ process.stdout.write(`version: ${parsed.version}\n`);
207
+ return;
208
+ }
206
209
 
207
- const d1 = new Date();
208
- process.stdout.write('Starting \'\x1b[36mdep:private\x1b[89m\x1b[0m\'...\n');
210
+ const d1 = new Date();
211
+ process.stdout.write('Starting \'\x1b[36mdep:private\x1b[89m\x1b[0m\'...\n');
209
212
 
210
- let pending = PENDING;
211
- /**
212
- * Executes done until completion.
213
- */
214
- function done() {
215
- pending -= 1;
216
- if (!pending) {
217
- const d2 = new Date() - d1;
218
- process.stdout.write(`Finished '\x1b[36mdep:private\x1b[89m\x1b[0m' after \x1b[35m${d2} ms\x1b[89m\x1b[0m\n`);
213
+ let pending = PENDING;
214
+ /**
215
+ * Executes done until completion.
216
+ */
217
+ function done() {
218
+ pending -= 1;
219
+ if (!pending) {
220
+ const d2 = new Date() - d1;
221
+ process.stdout.write(`Finished '\x1b[36mdep:private\x1b[89m\x1b[0m' after \x1b[35m${d2} ms\x1b[89m\x1b[0m\n`);
222
+ }
219
223
  }
220
- }
221
224
 
222
- await _clean();
223
- _copyindex(done);
224
- _copypackagejson(done);
225
- }
225
+ await _clean();
226
+ _copyindex(done);
227
+ _copypackagejson(done);
228
+ },
229
+ };
226
230
 
227
231
 
228
- // Start script.
229
- run();
232
+ // -- Where the script starts --------------------------------------------------
233
+ Lib.run();
230
234
 
231
235
 
232
236
  // -- oOo --
package/test/index.html CHANGED
@@ -39,7 +39,7 @@
39
39
  console.log(lib.getArray());
40
40
 
41
41
  const el = document.getElementById('app');
42
- el.append(`Es6lib v${ES6lib.VERSION}`);
42
+ el.append(`ES6lib v${ES6lib.VERSION}`);
43
43
  el.append(` ... ${lib.getString()}`);
44
44
  el.append(` ... ${lib.getArray()}`);
45
45
  </script>
@@ -133,3 +133,6 @@ module.exports = function(ES6lib, libname, version) {
133
133
  });
134
134
  });
135
135
  };
136
+
137
+
138
+ // - oOo --
@@ -174,3 +174,6 @@ module.exports = function(ES6lib, libname, version) {
174
174
  });
175
175
  });
176
176
  };
177
+
178
+
179
+ // - oOo --
@@ -210,3 +210,6 @@ module.exports = function(ES6lib, libname, version, type) {
210
210
  });
211
211
  });
212
212
  };
213
+
214
+
215
+ // - oOo --
package/test/main.js CHANGED
@@ -25,3 +25,6 @@ const libname = 'ES6lib';
25
25
  describe('Test ES6lib:', () => {
26
26
  testlib(ES6lib, libname, pack.version, 'without new');
27
27
  });
28
+
29
+
30
+ // - oOo --