Leon4gr45 commited on
Commit
598f7cd
·
verified ·
1 Parent(s): 63ff9a5

Upload folder using huggingface_hub (part 16)

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. node_modules/express/lib/response.js +1053 -0
  2. node_modules/express/lib/utils.js +271 -0
  3. node_modules/express/lib/view.js +205 -0
  4. node_modules/express/package.json +99 -0
  5. node_modules/ext/CHANGELOG.md +89 -0
  6. node_modules/ext/LICENSE +15 -0
  7. node_modules/ext/README.md +46 -0
  8. node_modules/ext/docs/function/identity.md +9 -0
  9. node_modules/ext/docs/global-this.md +9 -0
  10. node_modules/ext/docs/math/ceil-10.md +10 -0
  11. node_modules/ext/docs/math/floor-10.md +10 -0
  12. node_modules/ext/docs/math/round-10.md +10 -0
  13. node_modules/ext/docs/object/clear.md +12 -0
  14. node_modules/ext/docs/object/entries.md +11 -0
  15. node_modules/ext/docs/promise/limit.md +13 -0
  16. node_modules/ext/docs/string/random.md +31 -0
  17. node_modules/ext/docs/string_/camel-to-hyphen.md +9 -0
  18. node_modules/ext/docs/string_/capitalize.md +9 -0
  19. node_modules/ext/docs/string_/includes.md +10 -0
  20. node_modules/ext/docs/thenable_/finally.md +9 -0
  21. node_modules/ext/function/identity.js +3 -0
  22. node_modules/ext/global-this/implementation.js +31 -0
  23. node_modules/ext/global-this/index.js +3 -0
  24. node_modules/ext/global-this/is-implemented.js +7 -0
  25. node_modules/ext/lib/private/decimal-adjust.js +29 -0
  26. node_modules/ext/lib/private/define-function-length.js +56 -0
  27. node_modules/ext/math/ceil-10.js +3 -0
  28. node_modules/ext/math/floor-10.js +3 -0
  29. node_modules/ext/math/round-10.js +3 -0
  30. node_modules/ext/object/clear.js +15 -0
  31. node_modules/ext/object/entries/implement.js +10 -0
  32. node_modules/ext/object/entries/implementation.js +15 -0
  33. node_modules/ext/object/entries/index.js +3 -0
  34. node_modules/ext/object/entries/is-implemented.js +6 -0
  35. node_modules/ext/package.json +152 -0
  36. node_modules/ext/promise/limit.js +62 -0
  37. node_modules/ext/string/random.js +50 -0
  38. node_modules/ext/string_/camel-to-hyphen.js +49 -0
  39. node_modules/ext/string_/capitalize.js +9 -0
  40. node_modules/ext/string_/includes/implementation.js +7 -0
  41. node_modules/ext/string_/includes/index.js +5 -0
  42. node_modules/ext/string_/includes/is-implemented.js +8 -0
  43. node_modules/ext/thenable_/finally.js +24 -0
  44. node_modules/falafel/.github/workflows/ci.yml +42 -0
  45. node_modules/falafel/LICENSE +21 -0
  46. node_modules/falafel/example/array.js +14 -0
  47. node_modules/falafel/example/keyword.js +16 -0
  48. node_modules/falafel/example/prompt.js +49 -0
  49. node_modules/falafel/falafel.png +0 -0
  50. node_modules/falafel/index.js +85 -0
node_modules/express/lib/response.js ADDED
@@ -0,0 +1,1053 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*!
2
+ * express
3
+ * Copyright(c) 2009-2013 TJ Holowaychuk
4
+ * Copyright(c) 2014-2015 Douglas Christopher Wilson
5
+ * MIT Licensed
6
+ */
7
+
8
+ 'use strict';
9
+
10
+ /**
11
+ * Module dependencies.
12
+ * @private
13
+ */
14
+
15
+ var contentDisposition = require('content-disposition');
16
+ var createError = require('http-errors')
17
+ var deprecate = require('depd')('express');
18
+ var encodeUrl = require('encodeurl');
19
+ var escapeHtml = require('escape-html');
20
+ var http = require('node:http');
21
+ var onFinished = require('on-finished');
22
+ var mime = require('mime-types')
23
+ var path = require('node:path');
24
+ var pathIsAbsolute = require('node:path').isAbsolute;
25
+ var statuses = require('statuses')
26
+ var sign = require('cookie-signature').sign;
27
+ var normalizeType = require('./utils').normalizeType;
28
+ var normalizeTypes = require('./utils').normalizeTypes;
29
+ var setCharset = require('./utils').setCharset;
30
+ var cookie = require('cookie');
31
+ var send = require('send');
32
+ var extname = path.extname;
33
+ var resolve = path.resolve;
34
+ var vary = require('vary');
35
+ const { Buffer } = require('node:buffer');
36
+
37
+ /**
38
+ * Response prototype.
39
+ * @public
40
+ */
41
+
42
+ var res = Object.create(http.ServerResponse.prototype)
43
+
44
+ /**
45
+ * Module exports.
46
+ * @public
47
+ */
48
+
49
+ module.exports = res
50
+
51
+ /**
52
+ * Set the HTTP status code for the response.
53
+ *
54
+ * Expects an integer value between 100 and 999 inclusive.
55
+ * Throws an error if the provided status code is not an integer or if it's outside the allowable range.
56
+ *
57
+ * @param {number} code - The HTTP status code to set.
58
+ * @return {ServerResponse} - Returns itself for chaining methods.
59
+ * @throws {TypeError} If `code` is not an integer.
60
+ * @throws {RangeError} If `code` is outside the range 100 to 999.
61
+ * @public
62
+ */
63
+
64
+ res.status = function status(code) {
65
+ // Check if the status code is not an integer
66
+ if (!Number.isInteger(code)) {
67
+ throw new TypeError(`Invalid status code: ${JSON.stringify(code)}. Status code must be an integer.`);
68
+ }
69
+ // Check if the status code is outside of Node's valid range
70
+ if (code < 100 || code > 999) {
71
+ throw new RangeError(`Invalid status code: ${JSON.stringify(code)}. Status code must be greater than 99 and less than 1000.`);
72
+ }
73
+
74
+ this.statusCode = code;
75
+ return this;
76
+ };
77
+
78
+ /**
79
+ * Set Link header field with the given `links`.
80
+ *
81
+ * Examples:
82
+ *
83
+ * res.links({
84
+ * next: 'http://api.example.com/users?page=2',
85
+ * last: 'http://api.example.com/users?page=5',
86
+ * pages: [
87
+ * 'http://api.example.com/users?page=1',
88
+ * 'http://api.example.com/users?page=2'
89
+ * ]
90
+ * });
91
+ *
92
+ * @param {Object} links
93
+ * @return {ServerResponse}
94
+ * @public
95
+ */
96
+
97
+ res.links = function(links) {
98
+ var link = this.get('Link') || '';
99
+ if (link) link += ', ';
100
+ return this.set('Link', link + Object.keys(links).map(function(rel) {
101
+ // Allow multiple links if links[rel] is an array
102
+ if (Array.isArray(links[rel])) {
103
+ return links[rel].map(function (singleLink) {
104
+ return `<${singleLink}>; rel="${rel}"`;
105
+ }).join(', ');
106
+ } else {
107
+ return `<${links[rel]}>; rel="${rel}"`;
108
+ }
109
+ }).join(', '));
110
+ };
111
+
112
+ /**
113
+ * Send a response.
114
+ *
115
+ * Examples:
116
+ *
117
+ * res.send(Buffer.from('wahoo'));
118
+ * res.send({ some: 'json' });
119
+ * res.send('<p>some html</p>');
120
+ *
121
+ * @param {string|number|boolean|object|Buffer} body
122
+ * @public
123
+ */
124
+
125
+ res.send = function send(body) {
126
+ var chunk = body;
127
+ var encoding;
128
+ var req = this.req;
129
+ var type;
130
+
131
+ // settings
132
+ var app = this.app;
133
+
134
+ switch (typeof chunk) {
135
+ // string defaulting to html
136
+ case 'string':
137
+ if (!this.get('Content-Type')) {
138
+ this.type('html');
139
+ }
140
+ break;
141
+ case 'boolean':
142
+ case 'number':
143
+ case 'object':
144
+ if (chunk === null) {
145
+ chunk = '';
146
+ } else if (ArrayBuffer.isView(chunk)) {
147
+ if (!this.get('Content-Type')) {
148
+ this.type('bin');
149
+ }
150
+ } else {
151
+ return this.json(chunk);
152
+ }
153
+ break;
154
+ }
155
+
156
+ // write strings in utf-8
157
+ if (typeof chunk === 'string') {
158
+ encoding = 'utf8';
159
+ type = this.get('Content-Type');
160
+
161
+ // reflect this in content-type
162
+ if (typeof type === 'string') {
163
+ this.set('Content-Type', setCharset(type, 'utf-8'));
164
+ }
165
+ }
166
+
167
+ // determine if ETag should be generated
168
+ var etagFn = app.get('etag fn')
169
+ var generateETag = !this.get('ETag') && typeof etagFn === 'function'
170
+
171
+ // populate Content-Length
172
+ var len
173
+ if (chunk !== undefined) {
174
+ if (Buffer.isBuffer(chunk)) {
175
+ // get length of Buffer
176
+ len = chunk.length
177
+ } else if (!generateETag && chunk.length < 1000) {
178
+ // just calculate length when no ETag + small chunk
179
+ len = Buffer.byteLength(chunk, encoding)
180
+ } else {
181
+ // convert chunk to Buffer and calculate
182
+ chunk = Buffer.from(chunk, encoding)
183
+ encoding = undefined;
184
+ len = chunk.length
185
+ }
186
+
187
+ this.set('Content-Length', len);
188
+ }
189
+
190
+ // populate ETag
191
+ var etag;
192
+ if (generateETag && len !== undefined) {
193
+ if ((etag = etagFn(chunk, encoding))) {
194
+ this.set('ETag', etag);
195
+ }
196
+ }
197
+
198
+ // freshness
199
+ if (req.fresh) this.status(304);
200
+
201
+ // strip irrelevant headers
202
+ if (204 === this.statusCode || 304 === this.statusCode) {
203
+ this.removeHeader('Content-Type');
204
+ this.removeHeader('Content-Length');
205
+ this.removeHeader('Transfer-Encoding');
206
+ chunk = '';
207
+ }
208
+
209
+ // alter headers for 205
210
+ if (this.statusCode === 205) {
211
+ this.set('Content-Length', '0')
212
+ this.removeHeader('Transfer-Encoding')
213
+ chunk = ''
214
+ }
215
+
216
+ if (req.method === 'HEAD') {
217
+ // skip body for HEAD
218
+ this.end();
219
+ } else {
220
+ // respond
221
+ this.end(chunk, encoding);
222
+ }
223
+
224
+ return this;
225
+ };
226
+
227
+ /**
228
+ * Send JSON response.
229
+ *
230
+ * Examples:
231
+ *
232
+ * res.json(null);
233
+ * res.json({ user: 'tj' });
234
+ *
235
+ * @param {string|number|boolean|object} obj
236
+ * @public
237
+ */
238
+
239
+ res.json = function json(obj) {
240
+ // settings
241
+ var app = this.app;
242
+ var escape = app.get('json escape')
243
+ var replacer = app.get('json replacer');
244
+ var spaces = app.get('json spaces');
245
+ var body = stringify(obj, replacer, spaces, escape)
246
+
247
+ // content-type
248
+ if (!this.get('Content-Type')) {
249
+ this.set('Content-Type', 'application/json');
250
+ }
251
+
252
+ return this.send(body);
253
+ };
254
+
255
+ /**
256
+ * Send JSON response with JSONP callback support.
257
+ *
258
+ * Examples:
259
+ *
260
+ * res.jsonp(null);
261
+ * res.jsonp({ user: 'tj' });
262
+ *
263
+ * @param {string|number|boolean|object} obj
264
+ * @public
265
+ */
266
+
267
+ res.jsonp = function jsonp(obj) {
268
+ // settings
269
+ var app = this.app;
270
+ var escape = app.get('json escape')
271
+ var replacer = app.get('json replacer');
272
+ var spaces = app.get('json spaces');
273
+ var body = stringify(obj, replacer, spaces, escape)
274
+ var callback = this.req.query[app.get('jsonp callback name')];
275
+
276
+ // content-type
277
+ if (!this.get('Content-Type')) {
278
+ this.set('X-Content-Type-Options', 'nosniff');
279
+ this.set('Content-Type', 'application/json');
280
+ }
281
+
282
+ // fixup callback
283
+ if (Array.isArray(callback)) {
284
+ callback = callback[0];
285
+ }
286
+
287
+ // jsonp
288
+ if (typeof callback === 'string' && callback.length !== 0) {
289
+ this.set('X-Content-Type-Options', 'nosniff');
290
+ this.set('Content-Type', 'text/javascript');
291
+
292
+ // restrict callback charset
293
+ callback = callback.replace(/[^\[\]\w$.]/g, '');
294
+
295
+ if (body === undefined) {
296
+ // empty argument
297
+ body = ''
298
+ } else if (typeof body === 'string') {
299
+ // replace chars not allowed in JavaScript that are in JSON
300
+ body = body
301
+ .replace(/\u2028/g, '\\u2028')
302
+ .replace(/\u2029/g, '\\u2029')
303
+ }
304
+
305
+ // the /**/ is a specific security mitigation for "Rosetta Flash JSONP abuse"
306
+ // the typeof check is just to reduce client error noise
307
+ body = '/**/ typeof ' + callback + ' === \'function\' && ' + callback + '(' + body + ');';
308
+ }
309
+
310
+ return this.send(body);
311
+ };
312
+
313
+ /**
314
+ * Send given HTTP status code.
315
+ *
316
+ * Sets the response status to `statusCode` and the body of the
317
+ * response to the standard description from node's http.STATUS_CODES
318
+ * or the statusCode number if no description.
319
+ *
320
+ * Examples:
321
+ *
322
+ * res.sendStatus(200);
323
+ *
324
+ * @param {number} statusCode
325
+ * @public
326
+ */
327
+
328
+ res.sendStatus = function sendStatus(statusCode) {
329
+ var body = statuses.message[statusCode] || String(statusCode)
330
+
331
+ this.status(statusCode);
332
+ this.type('txt');
333
+
334
+ return this.send(body);
335
+ };
336
+
337
+ /**
338
+ * Transfer the file at the given `path`.
339
+ *
340
+ * Automatically sets the _Content-Type_ response header field.
341
+ * The callback `callback(err)` is invoked when the transfer is complete
342
+ * or when an error occurs. Be sure to check `res.headersSent`
343
+ * if you wish to attempt responding, as the header and some data
344
+ * may have already been transferred.
345
+ *
346
+ * Options:
347
+ *
348
+ * - `maxAge` defaulting to 0 (can be string converted by `ms`)
349
+ * - `root` root directory for relative filenames
350
+ * - `headers` object of headers to serve with file
351
+ * - `dotfiles` serve dotfiles, defaulting to false; can be `"allow"` to send them
352
+ *
353
+ * Other options are passed along to `send`.
354
+ *
355
+ * Examples:
356
+ *
357
+ * The following example illustrates how `res.sendFile()` may
358
+ * be used as an alternative for the `static()` middleware for
359
+ * dynamic situations. The code backing `res.sendFile()` is actually
360
+ * the same code, so HTTP cache support etc is identical.
361
+ *
362
+ * app.get('/user/:uid/photos/:file', function(req, res){
363
+ * var uid = req.params.uid
364
+ * , file = req.params.file;
365
+ *
366
+ * req.user.mayViewFilesFrom(uid, function(yes){
367
+ * if (yes) {
368
+ * res.sendFile('/uploads/' + uid + '/' + file);
369
+ * } else {
370
+ * res.send(403, 'Sorry! you cant see that.');
371
+ * }
372
+ * });
373
+ * });
374
+ *
375
+ * @public
376
+ */
377
+
378
+ res.sendFile = function sendFile(path, options, callback) {
379
+ var done = callback;
380
+ var req = this.req;
381
+ var res = this;
382
+ var next = req.next;
383
+ var opts = options || {};
384
+
385
+ if (!path) {
386
+ throw new TypeError('path argument is required to res.sendFile');
387
+ }
388
+
389
+ if (typeof path !== 'string') {
390
+ throw new TypeError('path must be a string to res.sendFile')
391
+ }
392
+
393
+ // support function as second arg
394
+ if (typeof options === 'function') {
395
+ done = options;
396
+ opts = {};
397
+ }
398
+
399
+ if (!opts.root && !pathIsAbsolute(path)) {
400
+ throw new TypeError('path must be absolute or specify root to res.sendFile');
401
+ }
402
+
403
+ // create file stream
404
+ var pathname = encodeURI(path);
405
+
406
+ // wire application etag option to send
407
+ opts.etag = this.app.enabled('etag');
408
+ var file = send(req, pathname, opts);
409
+
410
+ // transfer
411
+ sendfile(res, file, opts, function (err) {
412
+ if (done) return done(err);
413
+ if (err && err.code === 'EISDIR') return next();
414
+
415
+ // next() all but write errors
416
+ if (err && err.code !== 'ECONNABORTED' && err.syscall !== 'write') {
417
+ next(err);
418
+ }
419
+ });
420
+ };
421
+
422
+ /**
423
+ * Transfer the file at the given `path` as an attachment.
424
+ *
425
+ * Optionally providing an alternate attachment `filename`,
426
+ * and optional callback `callback(err)`. The callback is invoked
427
+ * when the data transfer is complete, or when an error has
428
+ * occurred. Be sure to check `res.headersSent` if you plan to respond.
429
+ *
430
+ * Optionally providing an `options` object to use with `res.sendFile()`.
431
+ * This function will set the `Content-Disposition` header, overriding
432
+ * any `Content-Disposition` header passed as header options in order
433
+ * to set the attachment and filename.
434
+ *
435
+ * This method uses `res.sendFile()`.
436
+ *
437
+ * @public
438
+ */
439
+
440
+ res.download = function download (path, filename, options, callback) {
441
+ var done = callback;
442
+ var name = filename;
443
+ var opts = options || null
444
+
445
+ // support function as second or third arg
446
+ if (typeof filename === 'function') {
447
+ done = filename;
448
+ name = null;
449
+ opts = null
450
+ } else if (typeof options === 'function') {
451
+ done = options
452
+ opts = null
453
+ }
454
+
455
+ // support optional filename, where options may be in it's place
456
+ if (typeof filename === 'object' &&
457
+ (typeof options === 'function' || options === undefined)) {
458
+ name = null
459
+ opts = filename
460
+ }
461
+
462
+ // set Content-Disposition when file is sent
463
+ var headers = {
464
+ 'Content-Disposition': contentDisposition(name || path)
465
+ };
466
+
467
+ // merge user-provided headers
468
+ if (opts && opts.headers) {
469
+ var keys = Object.keys(opts.headers)
470
+ for (var i = 0; i < keys.length; i++) {
471
+ var key = keys[i]
472
+ if (key.toLowerCase() !== 'content-disposition') {
473
+ headers[key] = opts.headers[key]
474
+ }
475
+ }
476
+ }
477
+
478
+ // merge user-provided options
479
+ opts = Object.create(opts)
480
+ opts.headers = headers
481
+
482
+ // Resolve the full path for sendFile
483
+ var fullPath = !opts.root
484
+ ? resolve(path)
485
+ : path
486
+
487
+ // send file
488
+ return this.sendFile(fullPath, opts, done)
489
+ };
490
+
491
+ /**
492
+ * Set _Content-Type_ response header with `type` through `mime.contentType()`
493
+ * when it does not contain "/", or set the Content-Type to `type` otherwise.
494
+ * When no mapping is found though `mime.contentType()`, the type is set to
495
+ * "application/octet-stream".
496
+ *
497
+ * Examples:
498
+ *
499
+ * res.type('.html');
500
+ * res.type('html');
501
+ * res.type('json');
502
+ * res.type('application/json');
503
+ * res.type('png');
504
+ *
505
+ * @param {String} type
506
+ * @return {ServerResponse} for chaining
507
+ * @public
508
+ */
509
+
510
+ res.contentType =
511
+ res.type = function contentType(type) {
512
+ var ct = type.indexOf('/') === -1
513
+ ? (mime.contentType(type) || 'application/octet-stream')
514
+ : type;
515
+
516
+ return this.set('Content-Type', ct);
517
+ };
518
+
519
+ /**
520
+ * Respond to the Acceptable formats using an `obj`
521
+ * of mime-type callbacks.
522
+ *
523
+ * This method uses `req.accepted`, an array of
524
+ * acceptable types ordered by their quality values.
525
+ * When "Accept" is not present the _first_ callback
526
+ * is invoked, otherwise the first match is used. When
527
+ * no match is performed the server responds with
528
+ * 406 "Not Acceptable".
529
+ *
530
+ * Content-Type is set for you, however if you choose
531
+ * you may alter this within the callback using `res.type()`
532
+ * or `res.set('Content-Type', ...)`.
533
+ *
534
+ * res.format({
535
+ * 'text/plain': function(){
536
+ * res.send('hey');
537
+ * },
538
+ *
539
+ * 'text/html': function(){
540
+ * res.send('<p>hey</p>');
541
+ * },
542
+ *
543
+ * 'application/json': function () {
544
+ * res.send({ message: 'hey' });
545
+ * }
546
+ * });
547
+ *
548
+ * In addition to canonicalized MIME types you may
549
+ * also use extnames mapped to these types:
550
+ *
551
+ * res.format({
552
+ * text: function(){
553
+ * res.send('hey');
554
+ * },
555
+ *
556
+ * html: function(){
557
+ * res.send('<p>hey</p>');
558
+ * },
559
+ *
560
+ * json: function(){
561
+ * res.send({ message: 'hey' });
562
+ * }
563
+ * });
564
+ *
565
+ * By default Express passes an `Error`
566
+ * with a `.status` of 406 to `next(err)`
567
+ * if a match is not made. If you provide
568
+ * a `.default` callback it will be invoked
569
+ * instead.
570
+ *
571
+ * @param {Object} obj
572
+ * @return {ServerResponse} for chaining
573
+ * @public
574
+ */
575
+
576
+ res.format = function(obj){
577
+ var req = this.req;
578
+ var next = req.next;
579
+
580
+ var keys = Object.keys(obj)
581
+ .filter(function (v) { return v !== 'default' })
582
+
583
+ var key = keys.length > 0
584
+ ? req.accepts(keys)
585
+ : false;
586
+
587
+ this.vary("Accept");
588
+
589
+ if (key) {
590
+ this.set('Content-Type', normalizeType(key).value);
591
+ obj[key](req, this, next);
592
+ } else if (obj.default) {
593
+ obj.default(req, this, next)
594
+ } else {
595
+ next(createError(406, {
596
+ types: normalizeTypes(keys).map(function (o) { return o.value })
597
+ }))
598
+ }
599
+
600
+ return this;
601
+ };
602
+
603
+ /**
604
+ * Set _Content-Disposition_ header to _attachment_ with optional `filename`.
605
+ *
606
+ * @param {String} filename
607
+ * @return {ServerResponse}
608
+ * @public
609
+ */
610
+
611
+ res.attachment = function attachment(filename) {
612
+ if (filename) {
613
+ this.type(extname(filename));
614
+ }
615
+
616
+ this.set('Content-Disposition', contentDisposition(filename));
617
+
618
+ return this;
619
+ };
620
+
621
+ /**
622
+ * Append additional header `field` with value `val`.
623
+ *
624
+ * Example:
625
+ *
626
+ * res.append('Link', ['<http://localhost/>', '<http://localhost:3000/>']);
627
+ * res.append('Set-Cookie', 'foo=bar; Path=/; HttpOnly');
628
+ * res.append('Warning', '199 Miscellaneous warning');
629
+ *
630
+ * @param {String} field
631
+ * @param {String|Array} val
632
+ * @return {ServerResponse} for chaining
633
+ * @public
634
+ */
635
+
636
+ res.append = function append(field, val) {
637
+ var prev = this.get(field);
638
+ var value = val;
639
+
640
+ if (prev) {
641
+ // concat the new and prev vals
642
+ value = Array.isArray(prev) ? prev.concat(val)
643
+ : Array.isArray(val) ? [prev].concat(val)
644
+ : [prev, val]
645
+ }
646
+
647
+ return this.set(field, value);
648
+ };
649
+
650
+ /**
651
+ * Set header `field` to `val`, or pass
652
+ * an object of header fields.
653
+ *
654
+ * Examples:
655
+ *
656
+ * res.set('Foo', ['bar', 'baz']);
657
+ * res.set('Accept', 'application/json');
658
+ * res.set({ Accept: 'text/plain', 'X-API-Key': 'tobi' });
659
+ *
660
+ * Aliased as `res.header()`.
661
+ *
662
+ * When the set header is "Content-Type", the type is expanded to include
663
+ * the charset if not present using `mime.contentType()`.
664
+ *
665
+ * @param {String|Object} field
666
+ * @param {String|Array} val
667
+ * @return {ServerResponse} for chaining
668
+ * @public
669
+ */
670
+
671
+ res.set =
672
+ res.header = function header(field, val) {
673
+ if (arguments.length === 2) {
674
+ var value = Array.isArray(val)
675
+ ? val.map(String)
676
+ : String(val);
677
+
678
+ // add charset to content-type
679
+ if (field.toLowerCase() === 'content-type') {
680
+ if (Array.isArray(value)) {
681
+ throw new TypeError('Content-Type cannot be set to an Array');
682
+ }
683
+ value = mime.contentType(value)
684
+ }
685
+
686
+ this.setHeader(field, value);
687
+ } else {
688
+ for (var key in field) {
689
+ this.set(key, field[key]);
690
+ }
691
+ }
692
+ return this;
693
+ };
694
+
695
+ /**
696
+ * Get value for header `field`.
697
+ *
698
+ * @param {String} field
699
+ * @return {String}
700
+ * @public
701
+ */
702
+
703
+ res.get = function(field){
704
+ return this.getHeader(field);
705
+ };
706
+
707
+ /**
708
+ * Clear cookie `name`.
709
+ *
710
+ * @param {String} name
711
+ * @param {Object} [options]
712
+ * @return {ServerResponse} for chaining
713
+ * @public
714
+ */
715
+
716
+ res.clearCookie = function clearCookie(name, options) {
717
+ // Force cookie expiration by setting expires to the past
718
+ const opts = { path: '/', ...options, expires: new Date(1)};
719
+ // ensure maxAge is not passed
720
+ delete opts.maxAge
721
+
722
+ return this.cookie(name, '', opts);
723
+ };
724
+
725
+ /**
726
+ * Set cookie `name` to `value`, with the given `options`.
727
+ *
728
+ * Options:
729
+ *
730
+ * - `maxAge` max-age in milliseconds, converted to `expires`
731
+ * - `signed` sign the cookie
732
+ * - `path` defaults to "/"
733
+ *
734
+ * Examples:
735
+ *
736
+ * // "Remember Me" for 15 minutes
737
+ * res.cookie('rememberme', '1', { expires: new Date(Date.now() + 900000), httpOnly: true });
738
+ *
739
+ * // same as above
740
+ * res.cookie('rememberme', '1', { maxAge: 900000, httpOnly: true })
741
+ *
742
+ * @param {String} name
743
+ * @param {String|Object} value
744
+ * @param {Object} [options]
745
+ * @return {ServerResponse} for chaining
746
+ * @public
747
+ */
748
+
749
+ res.cookie = function (name, value, options) {
750
+ var opts = { ...options };
751
+ var secret = this.req.secret;
752
+ var signed = opts.signed;
753
+
754
+ if (signed && !secret) {
755
+ throw new Error('cookieParser("secret") required for signed cookies');
756
+ }
757
+
758
+ var val = typeof value === 'object'
759
+ ? 'j:' + JSON.stringify(value)
760
+ : String(value);
761
+
762
+ if (signed) {
763
+ val = 's:' + sign(val, secret);
764
+ }
765
+
766
+ if (opts.maxAge != null) {
767
+ var maxAge = opts.maxAge - 0
768
+
769
+ if (!isNaN(maxAge)) {
770
+ opts.expires = new Date(Date.now() + maxAge)
771
+ opts.maxAge = Math.floor(maxAge / 1000)
772
+ }
773
+ }
774
+
775
+ if (opts.path == null) {
776
+ opts.path = '/';
777
+ }
778
+
779
+ this.append('Set-Cookie', cookie.serialize(name, String(val), opts));
780
+
781
+ return this;
782
+ };
783
+
784
+ /**
785
+ * Set the location header to `url`.
786
+ *
787
+ * The given `url` can also be "back", which redirects
788
+ * to the _Referrer_ or _Referer_ headers or "/".
789
+ *
790
+ * Examples:
791
+ *
792
+ * res.location('/foo/bar').;
793
+ * res.location('http://example.com');
794
+ * res.location('../login');
795
+ *
796
+ * @param {String} url
797
+ * @return {ServerResponse} for chaining
798
+ * @public
799
+ */
800
+
801
+ res.location = function location(url) {
802
+ return this.set('Location', encodeUrl(url));
803
+ };
804
+
805
+ /**
806
+ * Redirect to the given `url` with optional response `status`
807
+ * defaulting to 302.
808
+ *
809
+ * Examples:
810
+ *
811
+ * res.redirect('/foo/bar');
812
+ * res.redirect('http://example.com');
813
+ * res.redirect(301, 'http://example.com');
814
+ * res.redirect('../login'); // /blog/post/1 -> /blog/login
815
+ *
816
+ * @public
817
+ */
818
+
819
+ res.redirect = function redirect(url) {
820
+ var address = url;
821
+ var body;
822
+ var status = 302;
823
+
824
+ // allow status / url
825
+ if (arguments.length === 2) {
826
+ status = arguments[0]
827
+ address = arguments[1]
828
+ }
829
+
830
+ if (!address) {
831
+ deprecate('Provide a url argument');
832
+ }
833
+
834
+ if (typeof address !== 'string') {
835
+ deprecate('Url must be a string');
836
+ }
837
+
838
+ if (typeof status !== 'number') {
839
+ deprecate('Status must be a number');
840
+ }
841
+
842
+ // Set location header
843
+ address = this.location(address).get('Location');
844
+
845
+ // Support text/{plain,html} by default
846
+ this.format({
847
+ text: function(){
848
+ body = statuses.message[status] + '. Redirecting to ' + address
849
+ },
850
+
851
+ html: function(){
852
+ var u = escapeHtml(address);
853
+ body = '<p>' + statuses.message[status] + '. Redirecting to ' + u + '</p>'
854
+ },
855
+
856
+ default: function(){
857
+ body = '';
858
+ }
859
+ });
860
+
861
+ // Respond
862
+ this.status(status);
863
+ this.set('Content-Length', Buffer.byteLength(body));
864
+
865
+ if (this.req.method === 'HEAD') {
866
+ this.end();
867
+ } else {
868
+ this.end(body);
869
+ }
870
+ };
871
+
872
+ /**
873
+ * Add `field` to Vary. If already present in the Vary set, then
874
+ * this call is simply ignored.
875
+ *
876
+ * @param {Array|String} field
877
+ * @return {ServerResponse} for chaining
878
+ * @public
879
+ */
880
+
881
+ res.vary = function(field){
882
+ vary(this, field);
883
+
884
+ return this;
885
+ };
886
+
887
+ /**
888
+ * Render `view` with the given `options` and optional callback `fn`.
889
+ * When a callback function is given a response will _not_ be made
890
+ * automatically, otherwise a response of _200_ and _text/html_ is given.
891
+ *
892
+ * Options:
893
+ *
894
+ * - `cache` boolean hinting to the engine it should cache
895
+ * - `filename` filename of the view being rendered
896
+ *
897
+ * @public
898
+ */
899
+
900
+ res.render = function render(view, options, callback) {
901
+ var app = this.req.app;
902
+ var done = callback;
903
+ var opts = options || {};
904
+ var req = this.req;
905
+ var self = this;
906
+
907
+ // support callback function as second arg
908
+ if (typeof options === 'function') {
909
+ done = options;
910
+ opts = {};
911
+ }
912
+
913
+ // merge res.locals
914
+ opts._locals = self.locals;
915
+
916
+ // default callback to respond
917
+ done = done || function (err, str) {
918
+ if (err) return req.next(err);
919
+ self.send(str);
920
+ };
921
+
922
+ // render
923
+ app.render(view, opts, done);
924
+ };
925
+
926
+ // pipe the send file stream
927
+ function sendfile(res, file, options, callback) {
928
+ var done = false;
929
+ var streaming;
930
+
931
+ // request aborted
932
+ function onaborted() {
933
+ if (done) return;
934
+ done = true;
935
+
936
+ var err = new Error('Request aborted');
937
+ err.code = 'ECONNABORTED';
938
+ callback(err);
939
+ }
940
+
941
+ // directory
942
+ function ondirectory() {
943
+ if (done) return;
944
+ done = true;
945
+
946
+ var err = new Error('EISDIR, read');
947
+ err.code = 'EISDIR';
948
+ callback(err);
949
+ }
950
+
951
+ // errors
952
+ function onerror(err) {
953
+ if (done) return;
954
+ done = true;
955
+ callback(err);
956
+ }
957
+
958
+ // ended
959
+ function onend() {
960
+ if (done) return;
961
+ done = true;
962
+ callback();
963
+ }
964
+
965
+ // file
966
+ function onfile() {
967
+ streaming = false;
968
+ }
969
+
970
+ // finished
971
+ function onfinish(err) {
972
+ if (err && err.code === 'ECONNRESET') return onaborted();
973
+ if (err) return onerror(err);
974
+ if (done) return;
975
+
976
+ setImmediate(function () {
977
+ if (streaming !== false && !done) {
978
+ onaborted();
979
+ return;
980
+ }
981
+
982
+ if (done) return;
983
+ done = true;
984
+ callback();
985
+ });
986
+ }
987
+
988
+ // streaming
989
+ function onstream() {
990
+ streaming = true;
991
+ }
992
+
993
+ file.on('directory', ondirectory);
994
+ file.on('end', onend);
995
+ file.on('error', onerror);
996
+ file.on('file', onfile);
997
+ file.on('stream', onstream);
998
+ onFinished(res, onfinish);
999
+
1000
+ if (options.headers) {
1001
+ // set headers on successful transfer
1002
+ file.on('headers', function headers(res) {
1003
+ var obj = options.headers;
1004
+ var keys = Object.keys(obj);
1005
+
1006
+ for (var i = 0; i < keys.length; i++) {
1007
+ var k = keys[i];
1008
+ res.setHeader(k, obj[k]);
1009
+ }
1010
+ });
1011
+ }
1012
+
1013
+ // pipe
1014
+ file.pipe(res);
1015
+ }
1016
+
1017
+ /**
1018
+ * Stringify JSON, like JSON.stringify, but v8 optimized, with the
1019
+ * ability to escape characters that can trigger HTML sniffing.
1020
+ *
1021
+ * @param {*} value
1022
+ * @param {function} replacer
1023
+ * @param {number} spaces
1024
+ * @param {boolean} escape
1025
+ * @returns {string}
1026
+ * @private
1027
+ */
1028
+
1029
+ function stringify (value, replacer, spaces, escape) {
1030
+ // v8 checks arguments.length for optimizing simple call
1031
+ // https://bugs.chromium.org/p/v8/issues/detail?id=4730
1032
+ var json = replacer || spaces
1033
+ ? JSON.stringify(value, replacer, spaces)
1034
+ : JSON.stringify(value);
1035
+
1036
+ if (escape && typeof json === 'string') {
1037
+ json = json.replace(/[<>&]/g, function (c) {
1038
+ switch (c.charCodeAt(0)) {
1039
+ case 0x3c:
1040
+ return '\\u003c'
1041
+ case 0x3e:
1042
+ return '\\u003e'
1043
+ case 0x26:
1044
+ return '\\u0026'
1045
+ /* istanbul ignore next: unreachable default */
1046
+ default:
1047
+ return c
1048
+ }
1049
+ })
1050
+ }
1051
+
1052
+ return json
1053
+ }
node_modules/express/lib/utils.js ADDED
@@ -0,0 +1,271 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*!
2
+ * express
3
+ * Copyright(c) 2009-2013 TJ Holowaychuk
4
+ * Copyright(c) 2014-2015 Douglas Christopher Wilson
5
+ * MIT Licensed
6
+ */
7
+
8
+ 'use strict';
9
+
10
+ /**
11
+ * Module dependencies.
12
+ * @api private
13
+ */
14
+
15
+ var { METHODS } = require('node:http');
16
+ var contentType = require('content-type');
17
+ var etag = require('etag');
18
+ var mime = require('mime-types')
19
+ var proxyaddr = require('proxy-addr');
20
+ var qs = require('qs');
21
+ var querystring = require('node:querystring');
22
+ const { Buffer } = require('node:buffer');
23
+
24
+
25
+ /**
26
+ * A list of lowercased HTTP methods that are supported by Node.js.
27
+ * @api private
28
+ */
29
+ exports.methods = METHODS.map((method) => method.toLowerCase());
30
+
31
+ /**
32
+ * Return strong ETag for `body`.
33
+ *
34
+ * @param {String|Buffer} body
35
+ * @param {String} [encoding]
36
+ * @return {String}
37
+ * @api private
38
+ */
39
+
40
+ exports.etag = createETagGenerator({ weak: false })
41
+
42
+ /**
43
+ * Return weak ETag for `body`.
44
+ *
45
+ * @param {String|Buffer} body
46
+ * @param {String} [encoding]
47
+ * @return {String}
48
+ * @api private
49
+ */
50
+
51
+ exports.wetag = createETagGenerator({ weak: true })
52
+
53
+ /**
54
+ * Normalize the given `type`, for example "html" becomes "text/html".
55
+ *
56
+ * @param {String} type
57
+ * @return {Object}
58
+ * @api private
59
+ */
60
+
61
+ exports.normalizeType = function(type){
62
+ return ~type.indexOf('/')
63
+ ? acceptParams(type)
64
+ : { value: (mime.lookup(type) || 'application/octet-stream'), params: {} }
65
+ };
66
+
67
+ /**
68
+ * Normalize `types`, for example "html" becomes "text/html".
69
+ *
70
+ * @param {Array} types
71
+ * @return {Array}
72
+ * @api private
73
+ */
74
+
75
+ exports.normalizeTypes = function(types) {
76
+ return types.map(exports.normalizeType);
77
+ };
78
+
79
+
80
+ /**
81
+ * Parse accept params `str` returning an
82
+ * object with `.value`, `.quality` and `.params`.
83
+ *
84
+ * @param {String} str
85
+ * @return {Object}
86
+ * @api private
87
+ */
88
+
89
+ function acceptParams (str) {
90
+ var length = str.length;
91
+ var colonIndex = str.indexOf(';');
92
+ var index = colonIndex === -1 ? length : colonIndex;
93
+ var ret = { value: str.slice(0, index).trim(), quality: 1, params: {} };
94
+
95
+ while (index < length) {
96
+ var splitIndex = str.indexOf('=', index);
97
+ if (splitIndex === -1) break;
98
+
99
+ var colonIndex = str.indexOf(';', index);
100
+ var endIndex = colonIndex === -1 ? length : colonIndex;
101
+
102
+ if (splitIndex > endIndex) {
103
+ index = str.lastIndexOf(';', splitIndex - 1) + 1;
104
+ continue;
105
+ }
106
+
107
+ var key = str.slice(index, splitIndex).trim();
108
+ var value = str.slice(splitIndex + 1, endIndex).trim();
109
+
110
+ if (key === 'q') {
111
+ ret.quality = parseFloat(value);
112
+ } else {
113
+ ret.params[key] = value;
114
+ }
115
+
116
+ index = endIndex + 1;
117
+ }
118
+
119
+ return ret;
120
+ }
121
+
122
+ /**
123
+ * Compile "etag" value to function.
124
+ *
125
+ * @param {Boolean|String|Function} val
126
+ * @return {Function}
127
+ * @api private
128
+ */
129
+
130
+ exports.compileETag = function(val) {
131
+ var fn;
132
+
133
+ if (typeof val === 'function') {
134
+ return val;
135
+ }
136
+
137
+ switch (val) {
138
+ case true:
139
+ case 'weak':
140
+ fn = exports.wetag;
141
+ break;
142
+ case false:
143
+ break;
144
+ case 'strong':
145
+ fn = exports.etag;
146
+ break;
147
+ default:
148
+ throw new TypeError('unknown value for etag function: ' + val);
149
+ }
150
+
151
+ return fn;
152
+ }
153
+
154
+ /**
155
+ * Compile "query parser" value to function.
156
+ *
157
+ * @param {String|Function} val
158
+ * @return {Function}
159
+ * @api private
160
+ */
161
+
162
+ exports.compileQueryParser = function compileQueryParser(val) {
163
+ var fn;
164
+
165
+ if (typeof val === 'function') {
166
+ return val;
167
+ }
168
+
169
+ switch (val) {
170
+ case true:
171
+ case 'simple':
172
+ fn = querystring.parse;
173
+ break;
174
+ case false:
175
+ break;
176
+ case 'extended':
177
+ fn = parseExtendedQueryString;
178
+ break;
179
+ default:
180
+ throw new TypeError('unknown value for query parser function: ' + val);
181
+ }
182
+
183
+ return fn;
184
+ }
185
+
186
+ /**
187
+ * Compile "proxy trust" value to function.
188
+ *
189
+ * @param {Boolean|String|Number|Array|Function} val
190
+ * @return {Function}
191
+ * @api private
192
+ */
193
+
194
+ exports.compileTrust = function(val) {
195
+ if (typeof val === 'function') return val;
196
+
197
+ if (val === true) {
198
+ // Support plain true/false
199
+ return function(){ return true };
200
+ }
201
+
202
+ if (typeof val === 'number') {
203
+ // Support trusting hop count
204
+ return function(a, i){ return i < val };
205
+ }
206
+
207
+ if (typeof val === 'string') {
208
+ // Support comma-separated values
209
+ val = val.split(',')
210
+ .map(function (v) { return v.trim() })
211
+ }
212
+
213
+ return proxyaddr.compile(val || []);
214
+ }
215
+
216
+ /**
217
+ * Set the charset in a given Content-Type string.
218
+ *
219
+ * @param {String} type
220
+ * @param {String} charset
221
+ * @return {String}
222
+ * @api private
223
+ */
224
+
225
+ exports.setCharset = function setCharset(type, charset) {
226
+ if (!type || !charset) {
227
+ return type;
228
+ }
229
+
230
+ // parse type
231
+ var parsed = contentType.parse(type);
232
+
233
+ // set charset
234
+ parsed.parameters.charset = charset;
235
+
236
+ // format type
237
+ return contentType.format(parsed);
238
+ };
239
+
240
+ /**
241
+ * Create an ETag generator function, generating ETags with
242
+ * the given options.
243
+ *
244
+ * @param {object} options
245
+ * @return {function}
246
+ * @private
247
+ */
248
+
249
+ function createETagGenerator (options) {
250
+ return function generateETag (body, encoding) {
251
+ var buf = !Buffer.isBuffer(body)
252
+ ? Buffer.from(body, encoding)
253
+ : body
254
+
255
+ return etag(buf, options)
256
+ }
257
+ }
258
+
259
+ /**
260
+ * Parse an extended query string with qs.
261
+ *
262
+ * @param {String} str
263
+ * @return {Object}
264
+ * @private
265
+ */
266
+
267
+ function parseExtendedQueryString(str) {
268
+ return qs.parse(str, {
269
+ allowPrototypes: true
270
+ });
271
+ }
node_modules/express/lib/view.js ADDED
@@ -0,0 +1,205 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*!
2
+ * express
3
+ * Copyright(c) 2009-2013 TJ Holowaychuk
4
+ * Copyright(c) 2013 Roman Shtylman
5
+ * Copyright(c) 2014-2015 Douglas Christopher Wilson
6
+ * MIT Licensed
7
+ */
8
+
9
+ 'use strict';
10
+
11
+ /**
12
+ * Module dependencies.
13
+ * @private
14
+ */
15
+
16
+ var debug = require('debug')('express:view');
17
+ var path = require('node:path');
18
+ var fs = require('node:fs');
19
+
20
+ /**
21
+ * Module variables.
22
+ * @private
23
+ */
24
+
25
+ var dirname = path.dirname;
26
+ var basename = path.basename;
27
+ var extname = path.extname;
28
+ var join = path.join;
29
+ var resolve = path.resolve;
30
+
31
+ /**
32
+ * Module exports.
33
+ * @public
34
+ */
35
+
36
+ module.exports = View;
37
+
38
+ /**
39
+ * Initialize a new `View` with the given `name`.
40
+ *
41
+ * Options:
42
+ *
43
+ * - `defaultEngine` the default template engine name
44
+ * - `engines` template engine require() cache
45
+ * - `root` root path for view lookup
46
+ *
47
+ * @param {string} name
48
+ * @param {object} options
49
+ * @public
50
+ */
51
+
52
+ function View(name, options) {
53
+ var opts = options || {};
54
+
55
+ this.defaultEngine = opts.defaultEngine;
56
+ this.ext = extname(name);
57
+ this.name = name;
58
+ this.root = opts.root;
59
+
60
+ if (!this.ext && !this.defaultEngine) {
61
+ throw new Error('No default engine was specified and no extension was provided.');
62
+ }
63
+
64
+ var fileName = name;
65
+
66
+ if (!this.ext) {
67
+ // get extension from default engine name
68
+ this.ext = this.defaultEngine[0] !== '.'
69
+ ? '.' + this.defaultEngine
70
+ : this.defaultEngine;
71
+
72
+ fileName += this.ext;
73
+ }
74
+
75
+ if (!opts.engines[this.ext]) {
76
+ // load engine
77
+ var mod = this.ext.slice(1)
78
+ debug('require "%s"', mod)
79
+
80
+ // default engine export
81
+ var fn = require(mod).__express
82
+
83
+ if (typeof fn !== 'function') {
84
+ throw new Error('Module "' + mod + '" does not provide a view engine.')
85
+ }
86
+
87
+ opts.engines[this.ext] = fn
88
+ }
89
+
90
+ // store loaded engine
91
+ this.engine = opts.engines[this.ext];
92
+
93
+ // lookup path
94
+ this.path = this.lookup(fileName);
95
+ }
96
+
97
+ /**
98
+ * Lookup view by the given `name`
99
+ *
100
+ * @param {string} name
101
+ * @private
102
+ */
103
+
104
+ View.prototype.lookup = function lookup(name) {
105
+ var path;
106
+ var roots = [].concat(this.root);
107
+
108
+ debug('lookup "%s"', name);
109
+
110
+ for (var i = 0; i < roots.length && !path; i++) {
111
+ var root = roots[i];
112
+
113
+ // resolve the path
114
+ var loc = resolve(root, name);
115
+ var dir = dirname(loc);
116
+ var file = basename(loc);
117
+
118
+ // resolve the file
119
+ path = this.resolve(dir, file);
120
+ }
121
+
122
+ return path;
123
+ };
124
+
125
+ /**
126
+ * Render with the given options.
127
+ *
128
+ * @param {object} options
129
+ * @param {function} callback
130
+ * @private
131
+ */
132
+
133
+ View.prototype.render = function render(options, callback) {
134
+ var sync = true;
135
+
136
+ debug('render "%s"', this.path);
137
+
138
+ // render, normalizing sync callbacks
139
+ this.engine(this.path, options, function onRender() {
140
+ if (!sync) {
141
+ return callback.apply(this, arguments);
142
+ }
143
+
144
+ // copy arguments
145
+ var args = new Array(arguments.length);
146
+ var cntx = this;
147
+
148
+ for (var i = 0; i < arguments.length; i++) {
149
+ args[i] = arguments[i];
150
+ }
151
+
152
+ // force callback to be async
153
+ return process.nextTick(function renderTick() {
154
+ return callback.apply(cntx, args);
155
+ });
156
+ });
157
+
158
+ sync = false;
159
+ };
160
+
161
+ /**
162
+ * Resolve the file within the given directory.
163
+ *
164
+ * @param {string} dir
165
+ * @param {string} file
166
+ * @private
167
+ */
168
+
169
+ View.prototype.resolve = function resolve(dir, file) {
170
+ var ext = this.ext;
171
+
172
+ // <path>.<ext>
173
+ var path = join(dir, file);
174
+ var stat = tryStat(path);
175
+
176
+ if (stat && stat.isFile()) {
177
+ return path;
178
+ }
179
+
180
+ // <path>/index.<ext>
181
+ path = join(dir, basename(file, ext), 'index' + ext);
182
+ stat = tryStat(path);
183
+
184
+ if (stat && stat.isFile()) {
185
+ return path;
186
+ }
187
+ };
188
+
189
+ /**
190
+ * Return a stat, maybe.
191
+ *
192
+ * @param {string} path
193
+ * @return {fs.Stats}
194
+ * @private
195
+ */
196
+
197
+ function tryStat(path) {
198
+ debug('stat "%s"', path);
199
+
200
+ try {
201
+ return fs.statSync(path);
202
+ } catch (e) {
203
+ return undefined;
204
+ }
205
+ }
node_modules/express/package.json ADDED
@@ -0,0 +1,99 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "express",
3
+ "description": "Fast, unopinionated, minimalist web framework",
4
+ "version": "5.2.1",
5
+ "author": "TJ Holowaychuk <tj@vision-media.ca>",
6
+ "contributors": [
7
+ "Aaron Heckmann <aaron.heckmann+github@gmail.com>",
8
+ "Ciaran Jessup <ciaranj@gmail.com>",
9
+ "Douglas Christopher Wilson <doug@somethingdoug.com>",
10
+ "Guillermo Rauch <rauchg@gmail.com>",
11
+ "Jonathan Ong <me@jongleberry.com>",
12
+ "Roman Shtylman <shtylman+expressjs@gmail.com>",
13
+ "Young Jae Sim <hanul@hanul.me>"
14
+ ],
15
+ "license": "MIT",
16
+ "repository": "expressjs/express",
17
+ "homepage": "https://expressjs.com/",
18
+ "funding": {
19
+ "type": "opencollective",
20
+ "url": "https://opencollective.com/express"
21
+ },
22
+ "keywords": [
23
+ "express",
24
+ "framework",
25
+ "sinatra",
26
+ "web",
27
+ "http",
28
+ "rest",
29
+ "restful",
30
+ "router",
31
+ "app",
32
+ "api"
33
+ ],
34
+ "dependencies": {
35
+ "accepts": "^2.0.0",
36
+ "body-parser": "^2.2.1",
37
+ "content-disposition": "^1.0.0",
38
+ "content-type": "^1.0.5",
39
+ "cookie": "^0.7.1",
40
+ "cookie-signature": "^1.2.1",
41
+ "debug": "^4.4.0",
42
+ "depd": "^2.0.0",
43
+ "encodeurl": "^2.0.0",
44
+ "escape-html": "^1.0.3",
45
+ "etag": "^1.8.1",
46
+ "finalhandler": "^2.1.0",
47
+ "fresh": "^2.0.0",
48
+ "http-errors": "^2.0.0",
49
+ "merge-descriptors": "^2.0.0",
50
+ "mime-types": "^3.0.0",
51
+ "on-finished": "^2.4.1",
52
+ "once": "^1.4.0",
53
+ "parseurl": "^1.3.3",
54
+ "proxy-addr": "^2.0.7",
55
+ "qs": "^6.14.0",
56
+ "range-parser": "^1.2.1",
57
+ "router": "^2.2.0",
58
+ "send": "^1.1.0",
59
+ "serve-static": "^2.2.0",
60
+ "statuses": "^2.0.1",
61
+ "type-is": "^2.0.1",
62
+ "vary": "^1.1.2"
63
+ },
64
+ "devDependencies": {
65
+ "after": "0.8.2",
66
+ "connect-redis": "^8.0.1",
67
+ "cookie-parser": "1.4.7",
68
+ "cookie-session": "2.1.1",
69
+ "ejs": "^3.1.10",
70
+ "eslint": "8.47.0",
71
+ "express-session": "^1.18.1",
72
+ "hbs": "4.2.0",
73
+ "marked": "^15.0.3",
74
+ "method-override": "3.0.0",
75
+ "mocha": "^10.7.3",
76
+ "morgan": "1.10.1",
77
+ "nyc": "^17.1.0",
78
+ "pbkdf2-password": "1.2.1",
79
+ "supertest": "^6.3.0",
80
+ "vhost": "~3.0.2"
81
+ },
82
+ "engines": {
83
+ "node": ">= 18"
84
+ },
85
+ "files": [
86
+ "LICENSE",
87
+ "Readme.md",
88
+ "index.js",
89
+ "lib/"
90
+ ],
91
+ "scripts": {
92
+ "lint": "eslint .",
93
+ "lint:fix": "eslint . --fix",
94
+ "test": "mocha --require test/support/env --reporter spec --check-leaks test/ test/acceptance/",
95
+ "test-ci": "nyc --exclude examples --exclude test --exclude benchmarks --reporter=lcovonly --reporter=text npm test",
96
+ "test-cov": "nyc --exclude examples --exclude test --exclude benchmarks --reporter=html --reporter=text npm test",
97
+ "test-tap": "mocha --require test/support/env --reporter tap --check-leaks test/ test/acceptance/"
98
+ }
99
+ }
node_modules/ext/CHANGELOG.md ADDED
@@ -0,0 +1,89 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
+
5
+ ## [1.7.0](https://github.com/medikoo/es5-ext/compare/v1.6.0...v1.7.0) (2022-08-31)
6
+
7
+ ### Features
8
+
9
+ - `string.camelToHyphen` method ([b8ea4ab](https://github.com/medikoo/es5-ext/commit/b8ea4ab6c8b920ecdff224f9c92092e1c7f8cdfc))
10
+ - `string.capitalize` method ([32e7360](https://github.com/medikoo/es5-ext/commit/32e736034bd27ed25d4566b22aa93aa66c7901cf))
11
+
12
+ ## [1.6.0](https://github.com/medikoo/es5-ext/compare/v1.5.0...v1.6.0) (2021-09-24)
13
+
14
+ ### Features
15
+
16
+ - `Object.clear` util ([a955da4](https://github.com/medikoo/es5-ext/commit/a955da41e65a25ad87a46234bae065f096abd1d2))
17
+
18
+ ### Bug Fixes
19
+
20
+ - Fix `Object.entries` to not return non enumerable properties ([44fb872](https://github.com/medikoo/es5-ext/commit/44fb87266617378d2f47a1a5baad6280bf6298a8))
21
+
22
+ ## [1.5.0](https://github.com/medikoo/es5-ext/compare/v1.3.0...v1.5.0) (2021-08-23)
23
+
24
+ ### Features
25
+
26
+ - `Promise.limit` ([060a05d](https://github.com/medikoo/es5-ext/commit/060a05d4751cd291c6dd7641f5a73ba9338ea7ab))
27
+ - `String.prototype.includes` ([ceebe8d](https://github.com/medikoo/es5-ext/commit/ceebe8dfd6f479d6a7e7b6cd79369291869ee2dd))
28
+ - `charset` option for `String.random` ([2a20eeb](https://github.com/medikoo/es5-ext/commit/2a20eebc5ae784e5c1aacd2c54433fe92a9464c9))
29
+
30
+ ## [1.4.0](https://github.com///compare/v1.3.0...v1.4.0) (2019-11-29)
31
+
32
+ ### Features
33
+
34
+ - `charset` option for `String.random` ([2a20eeb](https://github.com///commit/2a20eebc5ae784e5c1aacd2c54433fe92a9464c9))
35
+ - `String.prototype.includes` implementation ([ceebe8d](https://github.com///commit/ceebe8dfd6f479d6a7e7b6cd79369291869ee2dd))
36
+
37
+ ## [1.3.0](https://github.com///compare/v1.2.1...v1.3.0) (2019-11-28)
38
+
39
+ ### Features
40
+
41
+ - `String.random` util ([5b5860a](https://github.com///commit/5b5860ac545b05f00527e00295fdb4f97e4a4e5b))
42
+
43
+ ### [1.2.1](https://github.com///compare/v1.2.0...v1.2.1) (2019-11-26)
44
+
45
+ ## [1.2.0](https://github.com/medikoo/ext/compare/v1.1.2...v1.2.0) (2019-11-07)
46
+
47
+ ### Features
48
+
49
+ - ceil10, floor10 and round10 for Math ([6a2bc4b](https://github.com/medikoo/ext/commit/6a2bc4b))
50
+
51
+ ### [1.1.2](https://github.com/medikoo/ext/compare/v1.1.1...v1.1.2) (2019-10-29)
52
+
53
+ ### Bug Fixes
54
+
55
+ - Improve globalThis detection ([470862d](https://github.com/medikoo/ext/commit/470862d))
56
+
57
+ ### [1.1.1](https://github.com/medikoo/ext/compare/v1.1.0...v1.1.1) (2019-10-29)
58
+
59
+ ### Bug Fixes
60
+
61
+ - Provide naive fallback for sealed Object.prototype case ([a8d528b](https://github.com/medikoo/ext/commit/a8d528b))
62
+ - Workaournd Safari incompatibility case ([0b051e6](https://github.com/medikoo/ext/commit/0b051e6))
63
+
64
+ ## [1.1.0](https://github.com/medikoo/ext/compare/v1.0.3...v1.1.0) (2019-10-21)
65
+
66
+ ### Features
67
+
68
+ - Object.entries implementation ([cf51e45](https://github.com/medikoo/ext/commit/cf51e45))
69
+
70
+ ### [1.0.3](https://github.com/medikoo/ext/compare/v1.0.1...v1.0.3) (2019-07-03)
71
+
72
+ Remove obsolete files from publication
73
+
74
+ ### [1.0.2](https://github.com/medikoo/ext/compare/v1.0.1...v1.0.2) (2019-07-03)
75
+
76
+ (no changes)
77
+
78
+ ### [1.0.1](https://github.com/medikoo/ext/compare/v1.0.0...v1.0.1) (2019-07-03)
79
+
80
+ Prettify
81
+
82
+ ## 1.0.0 (2019-07-03)
83
+
84
+ ### Features
85
+
86
+ - `function/identity` (adapted from `es5-ext`) ([f0102af](https://github.com/medikoo/ext/commit/f0102af))
87
+ - `thenable/finally` (adapted from `es5-ext`) ([a8494ac](https://github.com/medikoo/ext/commit/a8494ac))
88
+ - `global-this/is-implemented` ([3a80904](https://github.com/medikoo/ext/commit/3a80904))
89
+ - `globalThis` (mostly adapted from `es5-ext`) ([6559bd3](https://github.com/medikoo/ext/commit/6559bd3))
node_modules/ext/LICENSE ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ISC License
2
+
3
+ Copyright (c) 2011-2022, Mariusz Nowak, @medikoo, medikoo.com
4
+
5
+ Permission to use, copy, modify, and/or distribute this software for any
6
+ purpose with or without fee is hereby granted, provided that the above
7
+ copyright notice and this permission notice appear in all copies.
8
+
9
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
10
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
11
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
12
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
13
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
14
+ OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
15
+ PERFORMANCE OF THIS SOFTWARE.
node_modules/ext/README.md ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [![Build status][build-image]][build-url]
2
+ [![npm version][npm-image]][npm-url]
3
+
4
+ # ext
5
+
6
+ _(Previously known as `es5-ext`)_
7
+
8
+ ## JavaScript language extensions (with respect to evolving standard)
9
+
10
+ Non-standard or soon to be standard language utilities in a future proof, non-invasive form.
11
+
12
+ Doesn't enforce transpilation step. Where it's applicable utilities/extensions are safe to use in all ES3+ implementations.
13
+
14
+ ### Installation
15
+
16
+ ```bash
17
+ npm install ext
18
+ ```
19
+
20
+ ### Utilities
21
+
22
+ - [`globalThis`](docs/global-this.md)
23
+ - `Function`
24
+ - [`identity`](docs/function/identity.md)
25
+ - `Math`
26
+ - [`ceil10`](docs/math/ceil-10.md)
27
+ - [`floor10`](docs/math/floor-10.md)
28
+ - [`round10`](docs/math/round-10.md)
29
+ - `Object`
30
+ - [`clear`](docs/object/clear.md)
31
+ - [`entries`](docs/object/entries.md)
32
+ - `Promise`
33
+ - [`limit`](docs/promise/limit.md)
34
+ - `String`
35
+ - [`random`](docs/string/random.md)
36
+ - `String.prototype`
37
+ - [`campelToHyphen`](docs/string_/camel-to-hyphen.md)
38
+ - [`capitalize`](docs/string_/capitalize.md)
39
+ - [`includes`](docs/string_/includes.md)
40
+ - `Thenable.prototype`
41
+ - [`finally`](docs/thenable_/finally.md)
42
+
43
+ [build-image]: https://github.com/medikoo/es5-ext/workflows/Integrate%20[ext]/badge.svg
44
+ [build-url]: https://github.com/medikoo/es5-ext/actions?query=workflow%3AIntegrate%20[ext]
45
+ [npm-image]: https://img.shields.io/npm/v/ext.svg
46
+ [npm-url]: https://www.npmjs.com/package/ext
node_modules/ext/docs/function/identity.md ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ # `Function.identity` _(ext/function/identity)_
2
+
3
+ Returns input argument.
4
+
5
+ ```javascript
6
+ const identity = require("ext/function/identity");
7
+
8
+ identity("foo"); // "foo"
9
+ ```
node_modules/ext/docs/global-this.md ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ # `globalThis` _(ext/global-this)_
2
+
3
+ Returns global object. Resolve native [globalThis](https://github.com/tc39/proposal-global) if implemented, otherwise fallback to internal resolution of a global object.
4
+
5
+ ```javascript
6
+ const globalThis = require("ext/global-this");
7
+
8
+ globalThis.Array === Array; // true
9
+ ```
node_modules/ext/docs/math/ceil-10.md ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ # `Math.ceil10` _(ext/math/ceil-10)_
2
+
3
+ Decimal ceil
4
+
5
+ ```javascript
6
+ const ceil10 = require("ext/math/ceil-10");
7
+
8
+ ceil10(55.51, -1); // 55.6
9
+ ceil10(-59, 1); // -50;
10
+ ```
node_modules/ext/docs/math/floor-10.md ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ # `Math.floor10` _(ext/math/floor-10)_
2
+
3
+ Decimal floor
4
+
5
+ ```javascript
6
+ const floor10 = require("ext/math/floor-10");
7
+
8
+ floor10(55.59, -1); // 55.5
9
+ floor10(59, 1); // 50
10
+ ```
node_modules/ext/docs/math/round-10.md ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ # `Math.round10` _(ext/math/round-10)_
2
+
3
+ Decimal round
4
+
5
+ ```javascript
6
+ const round10 = require("ext/math/round-10");
7
+
8
+ round10(55.549, -1); // 55.5
9
+ round10(1.005, -2); // 1.01
10
+ ```
node_modules/ext/docs/object/clear.md ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # `Object.clear` _(ext/object/clear)_
2
+
3
+ Deletes all own, enumerable, non-symbol properties in the object
4
+
5
+ ```javascript
6
+ const clear = require("ext/object/clear");
7
+
8
+ const obj = { foo: "bar" };
9
+
10
+ clear(obj);
11
+ Object.keys(obj); // []
12
+ ```
node_modules/ext/docs/object/entries.md ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # `Object.entries` _(ext/object/entries)_
2
+
3
+ [Object.entries](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/entries) implementation.
4
+
5
+ Returns native `Object.entries` if it's implemented, otherwise library implementation is returned
6
+
7
+ ```javascript
8
+ const entries = require("ext/object/entries");
9
+
10
+ entries({ foo: "bar" }); // [["foo", "bar"]]
11
+ ```
node_modules/ext/docs/promise/limit.md ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # `Promise.limit` _(ext/promise/limit)_
2
+
3
+ Helps to limit concurrency of asynchronous operations.
4
+
5
+ ```javascript
6
+ const limit = require("ext/promise/limit").bind(Promise);
7
+
8
+ const limittedAsyncFunction = limit(2, asyncFunction);
9
+
10
+ imittedAsyncFunction(); // Async operation started
11
+ imittedAsyncFunction(); // Async operation started
12
+ imittedAsyncFunction(); // On hold until one of previously started finalizes
13
+ ```
node_modules/ext/docs/string/random.md ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # `String.random(options = { ... })` _(ext/string/random)_
2
+
3
+ Returns generated random string, contained only of ascii cars `a-z` and `0-1`.
4
+ By default returns string of length `10`.
5
+
6
+ ```javascript
7
+ const random = require("ext/string/random");
8
+
9
+ random(); // "upcfns0i4t"
10
+ random({ length: 3 }); // "5tw"
11
+ ```
12
+
13
+ ## Supported options:
14
+
15
+ ### `isUnique: false`
16
+
17
+ Ensures generated string is unique among ones already returned.
18
+
19
+ _Note: When not applying this setting, accidental generation of same string is still highly unlikely. Provided option is just to provide a mean to eliminate possibility of an edge case of duplicate string being returned_
20
+
21
+ ### `length: 10`
22
+
23
+ Desired length of result string
24
+
25
+ ### `charset: null`
26
+
27
+ Fixed list of possible characters
28
+
29
+ ```javascript
30
+ random({ charset: "abc" }); // "bacbccbbac"
31
+ ```
node_modules/ext/docs/string_/camel-to-hyphen.md ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ # `string.camelToHyphen()` _(ext/string\_/camel-to-hyphen)_
2
+
3
+ Convert camelCase string to hyphen separated, e.g. `oneTwoThree` into `one-to-three`. Useful when converting names from js property convention into filename convention.
4
+
5
+ ```javascript
6
+ const camelToHyphen = require("ext/string_/camelToHyphen");
7
+
8
+ camelToHyphen.call("razDwaTrzy"); // raz-dwa-trzy
9
+ ```
node_modules/ext/docs/string_/capitalize.md ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ # `string.capitalize()` _(ext/string\_/capitalize)_
2
+
3
+ Capitalize input string, e.g. convert `this is a test` into `This is a test`.
4
+
5
+ ```javascript
6
+ const capitalize = require("ext/string_/capitalize");
7
+
8
+ capitalize.call("this is a test"); // This is a test
9
+ ```
node_modules/ext/docs/string_/includes.md ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ # `string.includes(position = 0)` _(ext/string\_/includes)_
2
+
3
+ `includes` method for strings. Resolve native [includes](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/includes) if implemented, otherwise fallback to shim implementation.
4
+
5
+ ```javascript
6
+ const includes = require("ext/string_/includes");
7
+
8
+ includes.call("razdwa", "raz"); // true
9
+ includes.call("razdwa", "trzy"); // false
10
+ ```
node_modules/ext/docs/thenable_/finally.md ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ # `thenable.finally` _(ext/thenable\_/finally)_
2
+
3
+ `finally` method for any _thenable_ input
4
+
5
+ ```javascript
6
+ const finally = require("ext/thenable_/finally");
7
+
8
+ finally.call(thenable, () => console.log("Thenable resolved"));
9
+ ```
node_modules/ext/function/identity.js ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ "use strict";
2
+
3
+ module.exports = function (value) { return value; };
node_modules/ext/global-this/implementation.js ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ var naiveFallback = function () {
2
+ if (typeof self === "object" && self) return self;
3
+ if (typeof window === "object" && window) return window;
4
+ throw new Error("Unable to resolve global `this`");
5
+ };
6
+
7
+ module.exports = (function () {
8
+ if (this) return this;
9
+
10
+ // Unexpected strict mode (may happen if e.g. bundled into ESM module)
11
+
12
+ // Thanks @mathiasbynens -> https://mathiasbynens.be/notes/globalthis
13
+ // In all ES5+ engines global object inherits from Object.prototype
14
+ // (if you approached one that doesn't please report)
15
+ try {
16
+ Object.defineProperty(Object.prototype, "__global__", {
17
+ get: function () { return this; },
18
+ configurable: true
19
+ });
20
+ } catch (error) {
21
+ // Unfortunate case of Object.prototype being sealed (via preventExtensions, seal or freeze)
22
+ return naiveFallback();
23
+ }
24
+ try {
25
+ // Safari case (window.__global__ is resolved with global context, but __global__ does not)
26
+ if (!__global__) return naiveFallback();
27
+ return __global__;
28
+ } finally {
29
+ delete Object.prototype.__global__;
30
+ }
31
+ })();
node_modules/ext/global-this/index.js ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ "use strict";
2
+
3
+ module.exports = require("./is-implemented")() ? globalThis : require("./implementation");
node_modules/ext/global-this/is-implemented.js ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ "use strict";
2
+
3
+ module.exports = function () {
4
+ if (typeof globalThis !== "object") return false;
5
+ if (!globalThis) return false;
6
+ return globalThis.Array === Array;
7
+ };
node_modules/ext/lib/private/decimal-adjust.js ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // Credit:
2
+ // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/round
3
+ // #Decimal_rounding
4
+
5
+ "use strict";
6
+
7
+ var isValue = require("type/object/is")
8
+ , ensureInteger = require("type/integer/ensure");
9
+
10
+ var split = String.prototype.split;
11
+
12
+ module.exports = function (type) {
13
+ return function (value/*, exp*/) {
14
+ value = Number(value);
15
+ var exp = arguments[1];
16
+ if (isValue(exp)) exp = ensureInteger(exp);
17
+ if (!value) return value;
18
+ if (!exp) return Math[type](value);
19
+ if (!isFinite(value)) return value;
20
+
21
+ // Shift
22
+ var tokens = split.call(value, "e");
23
+ value = Math[type](tokens[0] + "e" + ((tokens[1] || 0) - exp));
24
+
25
+ // Shift back
26
+ tokens = value.toString().split("e");
27
+ return Number(tokens[0] + "e" + (Number(tokens[1] || 0) + exp));
28
+ };
29
+ };
node_modules/ext/lib/private/define-function-length.js ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "use strict";
2
+
3
+ var test = function (arg1, arg2) { return arg2; };
4
+
5
+ try {
6
+ Object.defineProperty(test, "length", {
7
+ configurable: true,
8
+ writable: false,
9
+ enumerable: false,
10
+ value: 1
11
+ });
12
+ }
13
+ catch (ignore) {}
14
+
15
+ if (test.length === 1) {
16
+ // ES2015+
17
+ var desc = { configurable: true, writable: false, enumerable: false };
18
+ module.exports = function (length, fn) {
19
+ if (fn.length === length) return fn;
20
+ desc.value = length;
21
+ return Object.defineProperty(fn, "length", desc);
22
+ };
23
+ return;
24
+ }
25
+
26
+ module.exports = function (length, fn) {
27
+ if (fn.length === length) return fn;
28
+ switch (length) {
29
+ case 0:
30
+ return function () { return fn.apply(this, arguments); };
31
+ case 1:
32
+ return function (ignored1) { return fn.apply(this, arguments); };
33
+ case 2:
34
+ return function (ignored1, ignored2) { return fn.apply(this, arguments); };
35
+ case 3:
36
+ return function (ignored1, ignored2, ignored3) { return fn.apply(this, arguments); };
37
+ case 4:
38
+ return function (ignored1, ignored2, ignored3, ignored4) {
39
+ return fn.apply(this, arguments);
40
+ };
41
+ case 5:
42
+ return function (ignored1, ignored2, ignored3, ignored4, ignored5) {
43
+ return fn.apply(this, arguments);
44
+ };
45
+ case 6:
46
+ return function (ignored1, ignored2, ignored3, ignored4, ignored5, ignored6) {
47
+ return fn.apply(this, arguments);
48
+ };
49
+ case 7:
50
+ return function (ignored1, ignored2, ignored3, ignored4, ignored5, ignored6, ignored7) {
51
+ return fn.apply(this, arguments);
52
+ };
53
+ default:
54
+ throw new Error("Usupported function length");
55
+ }
56
+ };
node_modules/ext/math/ceil-10.js ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ "use strict";
2
+
3
+ module.exports = require("../lib/private/decimal-adjust")("ceil");
node_modules/ext/math/floor-10.js ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ "use strict";
2
+
3
+ module.exports = require("../lib/private/decimal-adjust")("floor");
node_modules/ext/math/round-10.js ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ "use strict";
2
+
3
+ module.exports = require("../lib/private/decimal-adjust")("round");
node_modules/ext/object/clear.js ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "use strict";
2
+
3
+ var ensureObject = require("type/object/ensure")
4
+ , ensure = require("type/ensure");
5
+
6
+ var objPropertyIsEnumerable = Object.prototype.propertyIsEnumerable;
7
+
8
+ module.exports = function (object) {
9
+ ensure(["object", object, ensureObject]);
10
+ for (var key in object) {
11
+ if (!objPropertyIsEnumerable.call(object, key)) continue;
12
+ delete object[key];
13
+ }
14
+ return object;
15
+ };
node_modules/ext/object/entries/implement.js ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ "use strict";
2
+
3
+ if (!require("./is-implemented")()) {
4
+ Object.defineProperty(Object, "entries", {
5
+ value: require("./implementation"),
6
+ configurable: true,
7
+ enumerable: false,
8
+ writable: true
9
+ });
10
+ }
node_modules/ext/object/entries/implementation.js ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "use strict";
2
+
3
+ var ensureValue = require("type/value/ensure");
4
+
5
+ var objPropertyIsEnumerable = Object.prototype.propertyIsEnumerable;
6
+
7
+ module.exports = function (object) {
8
+ object = Object(ensureValue(object));
9
+ var result = [];
10
+ for (var key in object) {
11
+ if (!objPropertyIsEnumerable.call(object, key)) continue;
12
+ result.push([key, object[key]]);
13
+ }
14
+ return result;
15
+ };
node_modules/ext/object/entries/index.js ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ "use strict";
2
+
3
+ module.exports = require("./is-implemented")() ? Object.entries : require("./implementation");
node_modules/ext/object/entries/is-implemented.js ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ "use strict";
2
+
3
+ module.exports = function () {
4
+ try { return Object.entries({ foo: 12 })[0][0] === "foo"; }
5
+ catch (e) { return false; }
6
+ };
node_modules/ext/package.json ADDED
@@ -0,0 +1,152 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "ext",
3
+ "version": "1.7.0",
4
+ "description": "JavaScript utilities with respect to emerging standard",
5
+ "author": "Mariusz Nowak <medyk@medikoo.com> (http://www.medikoo.com/)",
6
+ "keywords": [
7
+ "ecmascript",
8
+ "es",
9
+ "es6",
10
+ "extensions",
11
+ "ext",
12
+ "addons",
13
+ "lodash",
14
+ "extras",
15
+ "harmony",
16
+ "javascript",
17
+ "polyfill",
18
+ "shim",
19
+ "util",
20
+ "utils",
21
+ "utilities"
22
+ ],
23
+ "repository": {
24
+ "type": "git",
25
+ "url": "https://github.com/medikoo/es5-ext#ext"
26
+ },
27
+ "dependencies": {
28
+ "type": "^2.7.2"
29
+ },
30
+ "devDependencies": {
31
+ "chai": "^4.3.6",
32
+ "eslint": "^8.23.0",
33
+ "eslint-config-medikoo": "^4.1.2",
34
+ "git-list-updated": "^1.2.1",
35
+ "github-release-from-cc-changelog": "^2.3.0",
36
+ "husky": "^4.3.8",
37
+ "lint-staged": "^13.0.3",
38
+ "mocha": "^6.2.3",
39
+ "nyc": "^15.1.0",
40
+ "prettier-elastic": "^2.2.1",
41
+ "sinon": "^8.1.1",
42
+ "timers-ext": "^0.1.7"
43
+ },
44
+ "husky": {
45
+ "hooks": {
46
+ "pre-commit": "lint-staged"
47
+ }
48
+ },
49
+ "lint-staged": {
50
+ "*.js": [
51
+ "eslint"
52
+ ],
53
+ "*.{css,html,js,json,md,yaml,yml}": [
54
+ "prettier -c"
55
+ ]
56
+ },
57
+ "eslintIgnore": [
58
+ "_es5-ext"
59
+ ],
60
+ "eslintConfig": {
61
+ "extends": "medikoo/es3",
62
+ "root": true,
63
+ "overrides": [
64
+ {
65
+ "files": "global-this/implementation.js",
66
+ "globals": {
67
+ "__global__": true,
68
+ "self": true,
69
+ "window": true
70
+ },
71
+ "rules": {
72
+ "no-extend-native": "off",
73
+ "strict": "off"
74
+ }
75
+ },
76
+ {
77
+ "files": [
78
+ "global-this/is-implemented.js",
79
+ "global-this/index.js"
80
+ ],
81
+ "globals": {
82
+ "globalThis": true
83
+ }
84
+ },
85
+ {
86
+ "files": "string_/camel-to-hyphen.js",
87
+ "rules": {
88
+ "id-length": "off"
89
+ }
90
+ },
91
+ {
92
+ "files": "test/**/*.js",
93
+ "env": {
94
+ "mocha": true
95
+ }
96
+ },
97
+ {
98
+ "files": [
99
+ "test/promise/limit.js",
100
+ "test/thenable_/finally.js"
101
+ ],
102
+ "globals": {
103
+ "Promise": true
104
+ }
105
+ }
106
+ ]
107
+ },
108
+ "prettier": {
109
+ "printWidth": 100,
110
+ "tabWidth": 4,
111
+ "overrides": [
112
+ {
113
+ "files": [
114
+ "*.md",
115
+ "*.yml"
116
+ ],
117
+ "options": {
118
+ "tabWidth": 2
119
+ }
120
+ }
121
+ ]
122
+ },
123
+ "mocha": {
124
+ "recursive": true
125
+ },
126
+ "nyc": {
127
+ "all": true,
128
+ "exclude": [
129
+ ".github",
130
+ "_es5-ext",
131
+ "coverage/**",
132
+ "test/**",
133
+ "*.config.js"
134
+ ],
135
+ "reporter": [
136
+ "lcov",
137
+ "html",
138
+ "text-summary"
139
+ ]
140
+ },
141
+ "scripts": {
142
+ "coverage": "nyc npm test",
143
+ "lint": "eslint .",
144
+ "lint:updated": "pipe-git-updated --ext=js -- eslint --ignore-pattern '!*'",
145
+ "prettier-check": "prettier -c --ignore-path .gitignore \"**/*.{css,html,js,json,md,yaml,yml}\"",
146
+ "prettier-check:updated": "pipe-git-updated --ext=css --ext=html --ext=js --ext=json --ext=md --ext=yaml --ext=yml -- prettier -c",
147
+ "prettify": "prettier --write --ignore-path .gitignore '**/*.{css,html,js,json,md,yaml,yml}'",
148
+ "prettify:updated": "pipe-git-updated ---base=main -ext=css --ext=html --ext=js --ext=json --ext=md --ext=yaml --ext=yml -- prettier --write",
149
+ "test": "mocha"
150
+ },
151
+ "license": "ISC"
152
+ }
node_modules/ext/promise/limit.js ADDED
@@ -0,0 +1,62 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "use strict";
2
+
3
+ var ensureNaturalNumber = require("type/natural-number/ensure")
4
+ , ensurePlainFunction = require("type/plain-function/ensure")
5
+ , ensure = require("type/ensure")
6
+ , defineFunctionLength = require("../lib/private/define-function-length");
7
+
8
+ module.exports = function (limit, callback) {
9
+ limit = ensure(
10
+ ["limit", limit, ensureNaturalNumber, { min: 1 }],
11
+ ["callback", callback, ensurePlainFunction]
12
+ )[0];
13
+
14
+ var Promise = this, ongoingCount = 0, pending = [];
15
+ var onSuccess, onFailure;
16
+
17
+ var release = function () {
18
+ --ongoingCount;
19
+ if (ongoingCount >= limit) return;
20
+ var next = pending.shift();
21
+ if (!next) return;
22
+ ++ongoingCount;
23
+ try {
24
+ next.resolve(
25
+ Promise.resolve(callback.apply(next.context, next.arguments)).then(
26
+ onSuccess, onFailure
27
+ )
28
+ );
29
+ } catch (exception) {
30
+ release();
31
+ next.reject(exception);
32
+ }
33
+ };
34
+
35
+ onSuccess = function (value) {
36
+ release();
37
+ return value;
38
+ };
39
+
40
+ onFailure = function (exception) {
41
+ release();
42
+ throw exception;
43
+ };
44
+
45
+ return defineFunctionLength(callback.length, function () {
46
+ if (ongoingCount >= limit) {
47
+ var context = this, args = arguments;
48
+ return new Promise(function (resolve, reject) {
49
+ pending.push({
50
+ context: context,
51
+ arguments: args,
52
+ resolve: resolve,
53
+ reject: reject
54
+ });
55
+ });
56
+ }
57
+ ++ongoingCount;
58
+ try {
59
+ return Promise.resolve(callback.apply(this, arguments)).then(onSuccess, onFailure);
60
+ } catch (exception) { return onFailure(exception); }
61
+ });
62
+ };
node_modules/ext/string/random.js ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "use strict";
2
+
3
+ var isObject = require("type/object/is")
4
+ , ensureNaturalNumber = require("type/natural-number/ensure")
5
+ , ensureString = require("type/string/ensure");
6
+
7
+ var generated = Object.create(null), random = Math.random, uniqTryLimit = 100;
8
+
9
+ var getChunk = function () { return random().toString(36).slice(2); };
10
+
11
+ var getString = function (length, charset) {
12
+ var str;
13
+ if (charset) {
14
+ var charsetLength = charset.length;
15
+ str = "";
16
+ for (var i = 0; i < length; ++i) {
17
+ str += charset.charAt(Math.floor(Math.random() * charsetLength));
18
+ }
19
+ return str;
20
+ }
21
+ str = getChunk();
22
+ if (length === null) return str;
23
+ while (str.length < length) str += getChunk();
24
+ return str.slice(0, length);
25
+ };
26
+
27
+ module.exports = function (/* options */) {
28
+ var options = arguments[0];
29
+ if (!isObject(options)) options = {};
30
+ var length = ensureNaturalNumber(options.length, { "default": 10 })
31
+ , isUnique = options.isUnique
32
+ , charset = ensureString(options.charset, { isOptional: true });
33
+
34
+ var str = getString(length, charset);
35
+ if (isUnique) {
36
+ var count = 0;
37
+ while (generated[str]) {
38
+ if (++count === uniqTryLimit) {
39
+ throw new Error(
40
+ "Cannot generate random string.\n" +
41
+ "String.random is not designed to effectively generate many short and " +
42
+ "unique random strings"
43
+ );
44
+ }
45
+ str = getString(length);
46
+ }
47
+ generated[str] = true;
48
+ }
49
+ return str;
50
+ };
node_modules/ext/string_/camel-to-hyphen.js ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "use strict";
2
+
3
+ var ensureString = require("type/string/ensure")
4
+ , objHasOwnProperty = Object.prototype.hasOwnProperty;
5
+
6
+ var capitalLetters = {
7
+ A: true,
8
+ B: true,
9
+ C: true,
10
+ D: true,
11
+ E: true,
12
+ F: true,
13
+ G: true,
14
+ H: true,
15
+ I: true,
16
+ J: true,
17
+ K: true,
18
+ L: true,
19
+ M: true,
20
+ N: true,
21
+ O: true,
22
+ P: true,
23
+ Q: true,
24
+ R: true,
25
+ S: true,
26
+ T: true,
27
+ U: true,
28
+ V: true,
29
+ W: true,
30
+ X: true,
31
+ Y: true,
32
+ Z: true
33
+ };
34
+
35
+ module.exports = function () {
36
+ var input = ensureString(this);
37
+ if (!input) return input;
38
+ var outputLetters = [];
39
+ for (var index = 0, letter; (letter = input[index]); ++index) {
40
+ if (objHasOwnProperty.call(capitalLetters, letter)) {
41
+ if (index) outputLetters.push("-");
42
+ outputLetters.push(letter.toLowerCase());
43
+ } else {
44
+ outputLetters.push(letter);
45
+ }
46
+ }
47
+
48
+ return outputLetters.join("");
49
+ };
node_modules/ext/string_/capitalize.js ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ "use strict";
2
+
3
+ var ensureString = require("type/string/ensure");
4
+
5
+ module.exports = function () {
6
+ var input = ensureString(this);
7
+ if (!input) return input;
8
+ return input.charAt(0).toUpperCase() + input.slice(1);
9
+ };
node_modules/ext/string_/includes/implementation.js ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ "use strict";
2
+
3
+ var indexOf = String.prototype.indexOf;
4
+
5
+ module.exports = function (searchString/*, position*/) {
6
+ return indexOf.call(this, searchString, arguments[1]) > -1;
7
+ };
node_modules/ext/string_/includes/index.js ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ "use strict";
2
+
3
+ module.exports = require("./is-implemented")()
4
+ ? String.prototype.includes
5
+ : require("./implementation");
node_modules/ext/string_/includes/is-implemented.js ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ "use strict";
2
+
3
+ var str = "razdwatrzy";
4
+
5
+ module.exports = function () {
6
+ if (typeof str.includes !== "function") return false;
7
+ return str.includes("dwa") === true && str.includes("foo") === false;
8
+ };
node_modules/ext/thenable_/finally.js ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "use strict";
2
+
3
+ var ensurePlainFunction = require("type/plain-function/ensure")
4
+ , isThenable = require("type/thenable/is")
5
+ , ensureThenable = require("type/thenable/ensure");
6
+
7
+ var resolveCallback = function (callback, next) {
8
+ var callbackResult = callback();
9
+ if (!isThenable(callbackResult)) return next();
10
+ return callbackResult.then(next);
11
+ };
12
+
13
+ module.exports = function (callback) {
14
+ ensureThenable(this);
15
+ ensurePlainFunction(callback);
16
+ return this.then(
17
+ function (result) {
18
+ return resolveCallback(callback, function () { return result; });
19
+ },
20
+ function (error) {
21
+ return resolveCallback(callback, function () { throw error; });
22
+ }
23
+ );
24
+ };
node_modules/falafel/.github/workflows/ci.yml ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ name: Node CI
2
+
3
+ on: [push, pull_request]
4
+
5
+ jobs:
6
+ test:
7
+ runs-on: ubuntu-latest
8
+
9
+ strategy:
10
+ matrix:
11
+ node-version:
12
+ - '0.8'
13
+ - '0.10'
14
+ - '0.12'
15
+ - '4.x'
16
+ - '6.x'
17
+ - '8.x'
18
+ - '10.x'
19
+ - '12.x'
20
+ - '14.x'
21
+ - '16.x'
22
+ - '17.x'
23
+ - '18.x'
24
+
25
+ steps:
26
+ - uses: actions/checkout@v3
27
+ - name: Use Node.js ${{ matrix.node-version }}
28
+ uses: actions/setup-node@v3
29
+ with:
30
+ node-version: ${{ matrix.node-version }}
31
+ - run: npm install
32
+ if: matrix.node-version != '0.8'
33
+ - name: Run npm install for Node.js 0.8
34
+ run: |
35
+ curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh | bash
36
+ . "$HOME/.nvm/nvm.sh"
37
+ nvm install-latest-npm
38
+ npm install
39
+ env:
40
+ NPM_CONFIG_STRICT_SSL: 'false'
41
+ if: matrix.node-version == '0.8'
42
+ - run: npm test
node_modules/falafel/LICENSE ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ MIT License
2
+
3
+ Copyright (c) 2012 James Halliday
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
node_modules/falafel/example/array.js ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ var falafel = require('../');
2
+
3
+ var src = '(' + function () {
4
+ var xs = [ 1, 2, [ 3, 4 ] ];
5
+ var ys = [ 5, 6 ];
6
+ console.dir([ xs, ys ]);
7
+ } + ')()';
8
+
9
+ var output = falafel(src, function (node) {
10
+ if (node.type === 'ArrayExpression') {
11
+ node.update('fn(' + node.source() + ')');
12
+ }
13
+ });
14
+ console.log(output);
node_modules/falafel/example/keyword.js ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ var falafel = require('../');
2
+ var src = 'console.log(beep "boop", "BOOP");';
3
+
4
+ function isKeyword (id) {
5
+ if (id === 'beep') return true;
6
+ }
7
+
8
+ var output = falafel(src, { isKeyword: isKeyword }, function (node) {
9
+ if (node.type === 'UnaryExpression'
10
+ && node.operator === 'beep') {
11
+ node.update(
12
+ 'String(' + node.argument.source() + ').toUpperCase()'
13
+ );
14
+ }
15
+ });
16
+ console.log(output);
node_modules/falafel/example/prompt.js ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ var falafel = require('../');
2
+ var vm = require('vm');
3
+
4
+ var termExps = [
5
+ 'Identifier',
6
+ 'CallExpression',
7
+ 'BinaryExpression',
8
+ 'UpdateExpression',
9
+ 'UnaryExpression'
10
+ ].reduce(function (acc, key) { acc[key] = true; return acc }, {});
11
+
12
+ function terminated (node) {
13
+ for (var p = node; p.parent; p = p.parent) {
14
+ if (termExps[p.type]) return true;
15
+ }
16
+ return false;
17
+ }
18
+
19
+ var src = '{"a":[2,~9,prompt(":d")],"b":4,"c":prompt("beep"),"d":6}';
20
+
21
+ var offsets = [];
22
+ var output = falafel('(' + src + ')', function (node) {
23
+ var isLeaf = node.parent
24
+ && !terminated(node.parent) && terminated(node)
25
+ ;
26
+
27
+ if (isLeaf) {
28
+ var s = node.source();
29
+ var prompted = false;
30
+ var res = vm.runInNewContext('(' + s + ')', {
31
+ prompt : function (x) {
32
+ setTimeout(function () {
33
+ node.update(x.toUpperCase());
34
+ }, Math.random() * 50);
35
+ prompted = true;
36
+ }
37
+ });
38
+ if (!prompted) {
39
+ var s_ = JSON.stringify(res);
40
+ node.update(s_);
41
+ }
42
+ }
43
+ });
44
+
45
+ setTimeout(function () {
46
+ console.log(src);
47
+ console.log('---');
48
+ console.log(output);
49
+ }, 200);
node_modules/falafel/falafel.png ADDED
node_modules/falafel/index.js ADDED
@@ -0,0 +1,85 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ var acorn = require('acorn');
2
+ var isArray = require('isarray');
3
+ var util = require('util');
4
+
5
+ module.exports = function (src, opts, fn) {
6
+ if (typeof opts === 'function') {
7
+ fn = opts;
8
+ opts = {};
9
+ }
10
+ if (src && typeof src === 'object' && src.constructor.name === 'Buffer') {
11
+ src = src.toString();
12
+ }
13
+ else if (src && typeof src === 'object') {
14
+ opts = src;
15
+ src = opts.source;
16
+ delete opts.source;
17
+ }
18
+ src = src === undefined ? opts.source : src;
19
+ if (typeof src !== 'string') src = String(src);
20
+ var parser = opts.parser || acorn;
21
+ var ast = parser.parse(src, opts);
22
+
23
+ var result = {
24
+ chunks : src.split(''),
25
+ toString : function () { return result.chunks.join('') },
26
+ inspect : function () { return result.toString() }
27
+ };
28
+ if (util.inspect.custom) {
29
+ result[util.inspect.custom] = result.toString;
30
+ }
31
+ var index = 0;
32
+
33
+ (function walk (node, parent) {
34
+ insertHelpers(node, parent, result.chunks);
35
+
36
+ for (var key in node) {
37
+ if (key === 'parent' || !Object.prototype.hasOwnProperty.call(node, key)) {
38
+ continue;
39
+ }
40
+
41
+ var child = node[key];
42
+ if (isArray(child)) {
43
+ for (var i = 0; i < child.length; i += 1) {
44
+ if (child[i] && typeof child[i].type === 'string') {
45
+ walk(child[i], node);
46
+ }
47
+ }
48
+ }
49
+ else if (child && typeof child.type === 'string') {
50
+ walk(child, node);
51
+ }
52
+ }
53
+ fn(node);
54
+ })(ast, undefined);
55
+
56
+ return result;
57
+ };
58
+
59
+ function insertHelpers (node, parent, chunks) {
60
+ node.parent = parent;
61
+
62
+ node.source = function () {
63
+ return chunks.slice(node.start, node.end).join('');
64
+ };
65
+
66
+ if (node.update && typeof node.update === 'object') {
67
+ var prev = node.update;
68
+ for (var key in prev) {
69
+ if (Object.prototype.hasOwnProperty.call(prev, key)) {
70
+ update[key] = prev[key];
71
+ }
72
+ }
73
+ node.update = update;
74
+ }
75
+ else {
76
+ node.update = update;
77
+ }
78
+
79
+ function update (s) {
80
+ chunks[node.start] = s;
81
+ for (var i = node.start + 1; i < node.end; i++) {
82
+ chunks[i] = '';
83
+ }
84
+ }
85
+ }