@kosatyi/ejs 0.0.97 → 0.0.98

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.
@@ -1,10 +1,10 @@
1
- import { promises } from 'fs';
1
+ import { promises } from 'node:fs';
2
+ import { join, dirname } from 'node:path';
2
3
  import { glob } from 'glob';
3
4
  import watch from 'glob-watcher';
4
- import { join, dirname } from 'path';
5
5
  import { create } from './index.js';
6
6
 
7
- const isPlainObject = function(obj) {
7
+ const isPlainObject = function (obj) {
8
8
  return Object.prototype.toString.call(obj) === '[object Object]'
9
9
  };
10
10
 
@@ -19,7 +19,7 @@ class Bundler {
19
19
  options = {
20
20
  target: [],
21
21
  umd: true,
22
- minify: true
22
+ minify: true,
23
23
  }
24
24
  /**
25
25
  * @type {EjsConfig}
@@ -55,10 +55,16 @@ class Bundler {
55
55
  const out = [];
56
56
  if (umd) {
57
57
  out.push('(function(global,factory){');
58
- out.push('typeof exports === "object" && typeof module !== "undefined" ?');
58
+ out.push(
59
+ 'typeof exports === "object" && typeof module !== "undefined" ?'
60
+ );
59
61
  out.push('module.exports = factory():');
60
- out.push('typeof define === "function" && define.amd ? define(factory):');
61
- out.push('(global = typeof globalThis !== "undefined" ? globalThis:');
62
+ out.push(
63
+ 'typeof define === "function" && define.amd ? define(factory):'
64
+ );
65
+ out.push(
66
+ '(global = typeof globalThis !== "undefined" ? globalThis:'
67
+ );
62
68
  out.push(`global || self,global["${module}"] = factory())`);
63
69
  out.push('})(this,(function(){');
64
70
  }
@@ -82,16 +88,16 @@ class Bundler {
82
88
  const watcher = watch(pattern, { cwd: this.config.path });
83
89
  const state = { build: null };
84
90
  watcher.on('change', (path) => {
85
- if(state.build) return;
86
- console.log('⟳','file change:',path);
87
- state.build = this.build().then(()=>{
91
+ if (state.build) return
92
+ console.log('⟳', 'file change:', path);
93
+ state.build = this.build().then(() => {
88
94
  state.build = null;
89
95
  });
90
96
  });
91
97
  watcher.on('add', (path) => {
92
- if(state.build) return;
93
- console.log('+','file added:',path);
94
- state.build = this.build().then(()=>{
98
+ if (state.build) return
99
+ console.log('+', 'file added:', path);
100
+ state.build = this.build().then(() => {
95
101
  state.build = null;
96
102
  });
97
103
  });
@@ -102,7 +108,7 @@ class Bundler {
102
108
  this.buildInProgress = true;
103
109
  await this.concat().catch(console.error);
104
110
  await this.output().catch(console.error);
105
- console.log('✅','bundle complete:',this.options.target);
111
+ console.log('✅', 'bundle complete:', this.options.target);
106
112
  this.buildInProgress = false;
107
113
  }
108
114
 
@@ -142,7 +148,7 @@ const ejsBundler = (options, config) => {
142
148
  },
143
149
  async buildEnd() {
144
150
  await bundler.output();
145
- }
151
+ },
146
152
  }
147
153
  };
148
154
 
@@ -38,7 +38,11 @@ const entities = (string = '') => {
38
38
 
39
39
  const safeValue = (value, escape) => {
40
40
  const check = value;
41
- return check == null ? '' : Boolean(escape) === true ? entities(check) : check
41
+ return check == null
42
+ ? ''
43
+ : Boolean(escape) === true
44
+ ? entities(check)
45
+ : check
42
46
  };
43
47
 
44
48
  const each = (object, callback) => {
@@ -63,6 +67,12 @@ const map = (object, callback, context) => {
63
67
  return result
64
68
  };
65
69
 
70
+ /**
71
+ *
72
+ * @param object
73
+ * @param prop
74
+ * @return {boolean}
75
+ */
66
76
  const hasProp = (object, prop) => {
67
77
  return object && object.hasOwnProperty(prop)
68
78
  };