protobufjs 8.0.3-experimental → 8.0.3
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/LICENSE +39 -39
- package/README.md +727 -727
- package/dist/light/protobuf.js +7724 -7352
- package/dist/light/protobuf.js.map +1 -1
- package/dist/light/protobuf.min.js +3 -3
- package/dist/light/protobuf.min.js.map +1 -1
- package/dist/minimal/protobuf.js +2606 -2546
- package/dist/minimal/protobuf.js.map +1 -1
- package/dist/minimal/protobuf.min.js +3 -3
- package/dist/minimal/protobuf.min.js.map +1 -1
- package/dist/protobuf.js +9588 -9131
- package/dist/protobuf.js.map +1 -1
- package/dist/protobuf.min.js +3 -3
- package/dist/protobuf.min.js.map +1 -1
- package/ext/debug/README.md +4 -4
- package/ext/debug/index.js +71 -71
- package/ext/descriptor/README.md +72 -72
- package/ext/descriptor/index.d.ts +195 -191
- package/ext/descriptor/index.js +1181 -1052
- package/ext/descriptor/test.js +54 -54
- package/google/LICENSE +27 -27
- package/google/README.md +1 -1
- package/google/api/annotations.json +82 -82
- package/google/api/annotations.proto +10 -10
- package/google/api/http.json +85 -85
- package/google/api/http.proto +30 -30
- package/google/protobuf/api.json +117 -117
- package/google/protobuf/api.proto +33 -33
- package/google/protobuf/descriptor.json +1381 -738
- package/google/protobuf/descriptor.proto +535 -286
- package/google/protobuf/source_context.json +19 -19
- package/google/protobuf/source_context.proto +7 -7
- package/google/protobuf/type.json +201 -201
- package/google/protobuf/type.proto +89 -89
- package/index.d.ts +2817 -2792
- package/index.js +4 -4
- package/light.d.ts +2 -2
- package/light.js +3 -3
- package/minimal.d.ts +2 -2
- package/minimal.js +4 -4
- package/package.json +96 -112
- package/scripts/postinstall.js +32 -32
- package/src/common.js +399 -399
- package/src/converter.js +310 -301
- package/src/decoder.js +135 -127
- package/src/encoder.js +100 -100
- package/src/enum.js +226 -241
- package/src/field.js +453 -432
- package/src/index-light.js +104 -104
- package/src/index-minimal.js +36 -36
- package/src/index.js +12 -12
- package/src/mapfield.js +126 -126
- package/src/message.js +139 -139
- package/src/method.js +160 -160
- package/src/namespace.js +550 -434
- package/src/object.js +385 -330
- package/src/oneof.js +222 -222
- package/src/parse.js +1024 -944
- package/src/reader.js +426 -416
- package/src/reader_buffer.js +51 -51
- package/src/root.js +404 -384
- package/src/roots.js +17 -17
- package/src/rpc/service.js +142 -142
- package/src/rpc.js +36 -36
- package/src/service.js +193 -168
- package/src/tokenize.js +421 -416
- package/src/type.js +625 -590
- package/src/types.js +196 -196
- package/src/typescript.jsdoc +15 -15
- package/src/util/aspromise.d.ts +13 -0
- package/src/util/aspromise.js +52 -0
- package/src/util/base64.d.ts +32 -0
- package/src/util/base64.js +139 -0
- package/src/util/codegen.d.ts +31 -0
- package/src/util/codegen.js +113 -0
- package/src/util/eventemitter.d.ts +45 -0
- package/src/util/eventemitter.js +84 -0
- package/src/util/fetch.d.ts +56 -0
- package/src/util/fetch.js +114 -0
- package/src/util/float.d.ts +83 -0
- package/src/util/float.js +335 -0
- package/src/util/inquire.d.ts +9 -0
- package/src/util/inquire.js +37 -0
- package/src/util/longbits.js +200 -200
- package/src/util/minimal.js +461 -438
- package/src/util/path.d.ts +22 -0
- package/src/util/path.js +72 -0
- package/src/util/patterns.js +8 -0
- package/src/util/pool.d.ts +32 -0
- package/src/util/pool.js +48 -0
- package/src/util/utf8.d.ts +24 -0
- package/src/util/utf8.js +104 -0
- package/src/util.js +215 -213
- package/src/verifier.js +180 -177
- package/src/wrappers.js +103 -102
- package/src/writer.js +465 -465
- package/src/writer_buffer.js +85 -85
- package/tsconfig.json +8 -8
|
@@ -0,0 +1,335 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
module.exports = factory(factory);
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Reads / writes floats / doubles from / to buffers.
|
|
7
|
+
* @name util.float
|
|
8
|
+
* @namespace
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Writes a 32 bit float to a buffer using little endian byte order.
|
|
13
|
+
* @name util.float.writeFloatLE
|
|
14
|
+
* @function
|
|
15
|
+
* @param {number} val Value to write
|
|
16
|
+
* @param {Uint8Array} buf Target buffer
|
|
17
|
+
* @param {number} pos Target buffer offset
|
|
18
|
+
* @returns {undefined}
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Writes a 32 bit float to a buffer using big endian byte order.
|
|
23
|
+
* @name util.float.writeFloatBE
|
|
24
|
+
* @function
|
|
25
|
+
* @param {number} val Value to write
|
|
26
|
+
* @param {Uint8Array} buf Target buffer
|
|
27
|
+
* @param {number} pos Target buffer offset
|
|
28
|
+
* @returns {undefined}
|
|
29
|
+
*/
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Reads a 32 bit float from a buffer using little endian byte order.
|
|
33
|
+
* @name util.float.readFloatLE
|
|
34
|
+
* @function
|
|
35
|
+
* @param {Uint8Array} buf Source buffer
|
|
36
|
+
* @param {number} pos Source buffer offset
|
|
37
|
+
* @returns {number} Value read
|
|
38
|
+
*/
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Reads a 32 bit float from a buffer using big endian byte order.
|
|
42
|
+
* @name util.float.readFloatBE
|
|
43
|
+
* @function
|
|
44
|
+
* @param {Uint8Array} buf Source buffer
|
|
45
|
+
* @param {number} pos Source buffer offset
|
|
46
|
+
* @returns {number} Value read
|
|
47
|
+
*/
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Writes a 64 bit double to a buffer using little endian byte order.
|
|
51
|
+
* @name util.float.writeDoubleLE
|
|
52
|
+
* @function
|
|
53
|
+
* @param {number} val Value to write
|
|
54
|
+
* @param {Uint8Array} buf Target buffer
|
|
55
|
+
* @param {number} pos Target buffer offset
|
|
56
|
+
* @returns {undefined}
|
|
57
|
+
*/
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Writes a 64 bit double to a buffer using big endian byte order.
|
|
61
|
+
* @name util.float.writeDoubleBE
|
|
62
|
+
* @function
|
|
63
|
+
* @param {number} val Value to write
|
|
64
|
+
* @param {Uint8Array} buf Target buffer
|
|
65
|
+
* @param {number} pos Target buffer offset
|
|
66
|
+
* @returns {undefined}
|
|
67
|
+
*/
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Reads a 64 bit double from a buffer using little endian byte order.
|
|
71
|
+
* @name util.float.readDoubleLE
|
|
72
|
+
* @function
|
|
73
|
+
* @param {Uint8Array} buf Source buffer
|
|
74
|
+
* @param {number} pos Source buffer offset
|
|
75
|
+
* @returns {number} Value read
|
|
76
|
+
*/
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Reads a 64 bit double from a buffer using big endian byte order.
|
|
80
|
+
* @name util.float.readDoubleBE
|
|
81
|
+
* @function
|
|
82
|
+
* @param {Uint8Array} buf Source buffer
|
|
83
|
+
* @param {number} pos Source buffer offset
|
|
84
|
+
* @returns {number} Value read
|
|
85
|
+
*/
|
|
86
|
+
|
|
87
|
+
// Factory function for the purpose of node-based testing in modified global environments
|
|
88
|
+
function factory(exports) {
|
|
89
|
+
|
|
90
|
+
// float: typed array
|
|
91
|
+
if (typeof Float32Array !== "undefined") (function() {
|
|
92
|
+
|
|
93
|
+
var f32 = new Float32Array([ -0 ]),
|
|
94
|
+
f8b = new Uint8Array(f32.buffer),
|
|
95
|
+
le = f8b[3] === 128;
|
|
96
|
+
|
|
97
|
+
function writeFloat_f32_cpy(val, buf, pos) {
|
|
98
|
+
f32[0] = val;
|
|
99
|
+
buf[pos ] = f8b[0];
|
|
100
|
+
buf[pos + 1] = f8b[1];
|
|
101
|
+
buf[pos + 2] = f8b[2];
|
|
102
|
+
buf[pos + 3] = f8b[3];
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
function writeFloat_f32_rev(val, buf, pos) {
|
|
106
|
+
f32[0] = val;
|
|
107
|
+
buf[pos ] = f8b[3];
|
|
108
|
+
buf[pos + 1] = f8b[2];
|
|
109
|
+
buf[pos + 2] = f8b[1];
|
|
110
|
+
buf[pos + 3] = f8b[0];
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/* istanbul ignore next */
|
|
114
|
+
exports.writeFloatLE = le ? writeFloat_f32_cpy : writeFloat_f32_rev;
|
|
115
|
+
/* istanbul ignore next */
|
|
116
|
+
exports.writeFloatBE = le ? writeFloat_f32_rev : writeFloat_f32_cpy;
|
|
117
|
+
|
|
118
|
+
function readFloat_f32_cpy(buf, pos) {
|
|
119
|
+
f8b[0] = buf[pos ];
|
|
120
|
+
f8b[1] = buf[pos + 1];
|
|
121
|
+
f8b[2] = buf[pos + 2];
|
|
122
|
+
f8b[3] = buf[pos + 3];
|
|
123
|
+
return f32[0];
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
function readFloat_f32_rev(buf, pos) {
|
|
127
|
+
f8b[3] = buf[pos ];
|
|
128
|
+
f8b[2] = buf[pos + 1];
|
|
129
|
+
f8b[1] = buf[pos + 2];
|
|
130
|
+
f8b[0] = buf[pos + 3];
|
|
131
|
+
return f32[0];
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/* istanbul ignore next */
|
|
135
|
+
exports.readFloatLE = le ? readFloat_f32_cpy : readFloat_f32_rev;
|
|
136
|
+
/* istanbul ignore next */
|
|
137
|
+
exports.readFloatBE = le ? readFloat_f32_rev : readFloat_f32_cpy;
|
|
138
|
+
|
|
139
|
+
// float: ieee754
|
|
140
|
+
})(); else (function() {
|
|
141
|
+
|
|
142
|
+
function writeFloat_ieee754(writeUint, val, buf, pos) {
|
|
143
|
+
var sign = val < 0 ? 1 : 0;
|
|
144
|
+
if (sign)
|
|
145
|
+
val = -val;
|
|
146
|
+
if (val === 0)
|
|
147
|
+
writeUint(1 / val > 0 ? /* positive */ 0 : /* negative 0 */ 2147483648, buf, pos);
|
|
148
|
+
else if (isNaN(val))
|
|
149
|
+
writeUint(2143289344, buf, pos);
|
|
150
|
+
else if (val > 3.4028234663852886e+38) // +-Infinity
|
|
151
|
+
writeUint((sign << 31 | 2139095040) >>> 0, buf, pos);
|
|
152
|
+
else if (val < 1.1754943508222875e-38) // denormal
|
|
153
|
+
writeUint((sign << 31 | Math.round(val / 1.401298464324817e-45)) >>> 0, buf, pos);
|
|
154
|
+
else {
|
|
155
|
+
var exponent = Math.floor(Math.log(val) / Math.LN2),
|
|
156
|
+
mantissa = Math.round(val * Math.pow(2, -exponent) * 8388608) & 8388607;
|
|
157
|
+
writeUint((sign << 31 | exponent + 127 << 23 | mantissa) >>> 0, buf, pos);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
exports.writeFloatLE = writeFloat_ieee754.bind(null, writeUintLE);
|
|
162
|
+
exports.writeFloatBE = writeFloat_ieee754.bind(null, writeUintBE);
|
|
163
|
+
|
|
164
|
+
function readFloat_ieee754(readUint, buf, pos) {
|
|
165
|
+
var uint = readUint(buf, pos),
|
|
166
|
+
sign = (uint >> 31) * 2 + 1,
|
|
167
|
+
exponent = uint >>> 23 & 255,
|
|
168
|
+
mantissa = uint & 8388607;
|
|
169
|
+
return exponent === 255
|
|
170
|
+
? mantissa
|
|
171
|
+
? NaN
|
|
172
|
+
: sign * Infinity
|
|
173
|
+
: exponent === 0 // denormal
|
|
174
|
+
? sign * 1.401298464324817e-45 * mantissa
|
|
175
|
+
: sign * Math.pow(2, exponent - 150) * (mantissa + 8388608);
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
exports.readFloatLE = readFloat_ieee754.bind(null, readUintLE);
|
|
179
|
+
exports.readFloatBE = readFloat_ieee754.bind(null, readUintBE);
|
|
180
|
+
|
|
181
|
+
})();
|
|
182
|
+
|
|
183
|
+
// double: typed array
|
|
184
|
+
if (typeof Float64Array !== "undefined") (function() {
|
|
185
|
+
|
|
186
|
+
var f64 = new Float64Array([-0]),
|
|
187
|
+
f8b = new Uint8Array(f64.buffer),
|
|
188
|
+
le = f8b[7] === 128;
|
|
189
|
+
|
|
190
|
+
function writeDouble_f64_cpy(val, buf, pos) {
|
|
191
|
+
f64[0] = val;
|
|
192
|
+
buf[pos ] = f8b[0];
|
|
193
|
+
buf[pos + 1] = f8b[1];
|
|
194
|
+
buf[pos + 2] = f8b[2];
|
|
195
|
+
buf[pos + 3] = f8b[3];
|
|
196
|
+
buf[pos + 4] = f8b[4];
|
|
197
|
+
buf[pos + 5] = f8b[5];
|
|
198
|
+
buf[pos + 6] = f8b[6];
|
|
199
|
+
buf[pos + 7] = f8b[7];
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
function writeDouble_f64_rev(val, buf, pos) {
|
|
203
|
+
f64[0] = val;
|
|
204
|
+
buf[pos ] = f8b[7];
|
|
205
|
+
buf[pos + 1] = f8b[6];
|
|
206
|
+
buf[pos + 2] = f8b[5];
|
|
207
|
+
buf[pos + 3] = f8b[4];
|
|
208
|
+
buf[pos + 4] = f8b[3];
|
|
209
|
+
buf[pos + 5] = f8b[2];
|
|
210
|
+
buf[pos + 6] = f8b[1];
|
|
211
|
+
buf[pos + 7] = f8b[0];
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
/* istanbul ignore next */
|
|
215
|
+
exports.writeDoubleLE = le ? writeDouble_f64_cpy : writeDouble_f64_rev;
|
|
216
|
+
/* istanbul ignore next */
|
|
217
|
+
exports.writeDoubleBE = le ? writeDouble_f64_rev : writeDouble_f64_cpy;
|
|
218
|
+
|
|
219
|
+
function readDouble_f64_cpy(buf, pos) {
|
|
220
|
+
f8b[0] = buf[pos ];
|
|
221
|
+
f8b[1] = buf[pos + 1];
|
|
222
|
+
f8b[2] = buf[pos + 2];
|
|
223
|
+
f8b[3] = buf[pos + 3];
|
|
224
|
+
f8b[4] = buf[pos + 4];
|
|
225
|
+
f8b[5] = buf[pos + 5];
|
|
226
|
+
f8b[6] = buf[pos + 6];
|
|
227
|
+
f8b[7] = buf[pos + 7];
|
|
228
|
+
return f64[0];
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
function readDouble_f64_rev(buf, pos) {
|
|
232
|
+
f8b[7] = buf[pos ];
|
|
233
|
+
f8b[6] = buf[pos + 1];
|
|
234
|
+
f8b[5] = buf[pos + 2];
|
|
235
|
+
f8b[4] = buf[pos + 3];
|
|
236
|
+
f8b[3] = buf[pos + 4];
|
|
237
|
+
f8b[2] = buf[pos + 5];
|
|
238
|
+
f8b[1] = buf[pos + 6];
|
|
239
|
+
f8b[0] = buf[pos + 7];
|
|
240
|
+
return f64[0];
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
/* istanbul ignore next */
|
|
244
|
+
exports.readDoubleLE = le ? readDouble_f64_cpy : readDouble_f64_rev;
|
|
245
|
+
/* istanbul ignore next */
|
|
246
|
+
exports.readDoubleBE = le ? readDouble_f64_rev : readDouble_f64_cpy;
|
|
247
|
+
|
|
248
|
+
// double: ieee754
|
|
249
|
+
})(); else (function() {
|
|
250
|
+
|
|
251
|
+
function writeDouble_ieee754(writeUint, off0, off1, val, buf, pos) {
|
|
252
|
+
var sign = val < 0 ? 1 : 0;
|
|
253
|
+
if (sign)
|
|
254
|
+
val = -val;
|
|
255
|
+
if (val === 0) {
|
|
256
|
+
writeUint(0, buf, pos + off0);
|
|
257
|
+
writeUint(1 / val > 0 ? /* positive */ 0 : /* negative 0 */ 2147483648, buf, pos + off1);
|
|
258
|
+
} else if (isNaN(val)) {
|
|
259
|
+
writeUint(0, buf, pos + off0);
|
|
260
|
+
writeUint(2146959360, buf, pos + off1);
|
|
261
|
+
} else if (val > 1.7976931348623157e+308) { // +-Infinity
|
|
262
|
+
writeUint(0, buf, pos + off0);
|
|
263
|
+
writeUint((sign << 31 | 2146435072) >>> 0, buf, pos + off1);
|
|
264
|
+
} else {
|
|
265
|
+
var mantissa;
|
|
266
|
+
if (val < 2.2250738585072014e-308) { // denormal
|
|
267
|
+
mantissa = val / 5e-324;
|
|
268
|
+
writeUint(mantissa >>> 0, buf, pos + off0);
|
|
269
|
+
writeUint((sign << 31 | mantissa / 4294967296) >>> 0, buf, pos + off1);
|
|
270
|
+
} else {
|
|
271
|
+
var exponent = Math.floor(Math.log(val) / Math.LN2);
|
|
272
|
+
if (exponent === 1024)
|
|
273
|
+
exponent = 1023;
|
|
274
|
+
mantissa = val * Math.pow(2, -exponent);
|
|
275
|
+
writeUint(mantissa * 4503599627370496 >>> 0, buf, pos + off0);
|
|
276
|
+
writeUint((sign << 31 | exponent + 1023 << 20 | mantissa * 1048576 & 1048575) >>> 0, buf, pos + off1);
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
exports.writeDoubleLE = writeDouble_ieee754.bind(null, writeUintLE, 0, 4);
|
|
282
|
+
exports.writeDoubleBE = writeDouble_ieee754.bind(null, writeUintBE, 4, 0);
|
|
283
|
+
|
|
284
|
+
function readDouble_ieee754(readUint, off0, off1, buf, pos) {
|
|
285
|
+
var lo = readUint(buf, pos + off0),
|
|
286
|
+
hi = readUint(buf, pos + off1);
|
|
287
|
+
var sign = (hi >> 31) * 2 + 1,
|
|
288
|
+
exponent = hi >>> 20 & 2047,
|
|
289
|
+
mantissa = 4294967296 * (hi & 1048575) + lo;
|
|
290
|
+
return exponent === 2047
|
|
291
|
+
? mantissa
|
|
292
|
+
? NaN
|
|
293
|
+
: sign * Infinity
|
|
294
|
+
: exponent === 0 // denormal
|
|
295
|
+
? sign * 5e-324 * mantissa
|
|
296
|
+
: sign * Math.pow(2, exponent - 1075) * (mantissa + 4503599627370496);
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
exports.readDoubleLE = readDouble_ieee754.bind(null, readUintLE, 0, 4);
|
|
300
|
+
exports.readDoubleBE = readDouble_ieee754.bind(null, readUintBE, 4, 0);
|
|
301
|
+
|
|
302
|
+
})();
|
|
303
|
+
|
|
304
|
+
return exports;
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
// uint helpers
|
|
308
|
+
|
|
309
|
+
function writeUintLE(val, buf, pos) {
|
|
310
|
+
buf[pos ] = val & 255;
|
|
311
|
+
buf[pos + 1] = val >>> 8 & 255;
|
|
312
|
+
buf[pos + 2] = val >>> 16 & 255;
|
|
313
|
+
buf[pos + 3] = val >>> 24;
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
function writeUintBE(val, buf, pos) {
|
|
317
|
+
buf[pos ] = val >>> 24;
|
|
318
|
+
buf[pos + 1] = val >>> 16 & 255;
|
|
319
|
+
buf[pos + 2] = val >>> 8 & 255;
|
|
320
|
+
buf[pos + 3] = val & 255;
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
function readUintLE(buf, pos) {
|
|
324
|
+
return (buf[pos ]
|
|
325
|
+
| buf[pos + 1] << 8
|
|
326
|
+
| buf[pos + 2] << 16
|
|
327
|
+
| buf[pos + 3] << 24) >>> 0;
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
function readUintBE(buf, pos) {
|
|
331
|
+
return (buf[pos ] << 24
|
|
332
|
+
| buf[pos + 1] << 16
|
|
333
|
+
| buf[pos + 2] << 8
|
|
334
|
+
| buf[pos + 3]) >>> 0;
|
|
335
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export = inquire;
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Requires a module only if available.
|
|
5
|
+
* @memberof util
|
|
6
|
+
* @param {string} moduleName Module to require
|
|
7
|
+
* @returns {?Object} Required module if available and not empty, otherwise `null`
|
|
8
|
+
*/
|
|
9
|
+
declare function inquire(moduleName: string): object;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
module.exports = inquire;
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Requires a module only if available.
|
|
6
|
+
* @memberof util
|
|
7
|
+
* @param {string} moduleName Module to require
|
|
8
|
+
* @returns {?Object} Required module if available and not empty, otherwise `null`
|
|
9
|
+
*/
|
|
10
|
+
function inquire(moduleName) {
|
|
11
|
+
try {
|
|
12
|
+
if (typeof require !== "function") {
|
|
13
|
+
return null;
|
|
14
|
+
}
|
|
15
|
+
var mod = require(moduleName);
|
|
16
|
+
if (mod && (mod.length || Object.keys(mod).length)) return mod;
|
|
17
|
+
return null;
|
|
18
|
+
} catch (err) {
|
|
19
|
+
// ignore
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/*
|
|
25
|
+
// maybe worth a shot to prevent renaming issues:
|
|
26
|
+
// see: https://github.com/webpack/webpack/blob/master/lib/dependencies/CommonJsRequireDependencyParserPlugin.js
|
|
27
|
+
// triggers on:
|
|
28
|
+
// - expression require.cache
|
|
29
|
+
// - expression require (???)
|
|
30
|
+
// - call require
|
|
31
|
+
// - call require:commonjs:item
|
|
32
|
+
// - call require:commonjs:context
|
|
33
|
+
|
|
34
|
+
Object.defineProperty(Function.prototype, "__self", { get: function() { return this; } });
|
|
35
|
+
var r = require.__self;
|
|
36
|
+
delete Function.prototype.__self;
|
|
37
|
+
*/
|