Mercurial
annotate third_party/bun/node_modules/loose-envify/loose-envify.js @ 176:fed99fc04e12 hg-web
[HgWeb] Problem with the emscript lol
| author | MrJuneJune <me@mrjunejune.com> |
|---|---|
| date | Wed, 21 Jan 2026 19:32:08 -0800 |
| parents | de54585a40f1 |
| children |
| rev | line source |
|---|---|
|
12
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1 'use strict'; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3 var stream = require('stream'); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4 var util = require('util'); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5 var replace = require('./replace'); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
6 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
7 var jsonExtRe = /\.json$/; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
8 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
9 module.exports = function(rootEnv) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
10 rootEnv = rootEnv || process.env; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
11 return function (file, trOpts) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
12 if (jsonExtRe.test(file)) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
13 return stream.PassThrough(); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
14 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
15 var envs = trOpts ? [rootEnv, trOpts] : [rootEnv]; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
16 return new LooseEnvify(envs); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
17 }; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
18 }; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
19 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
20 function LooseEnvify(envs) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
21 stream.Transform.call(this); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
22 this._data = ''; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
23 this._envs = envs; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
24 } |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
25 util.inherits(LooseEnvify, stream.Transform); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
26 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
27 LooseEnvify.prototype._transform = function(buf, enc, cb) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
28 this._data += buf; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
29 cb(); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
30 }; |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
31 |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
32 LooseEnvify.prototype._flush = function(cb) { |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
33 var replaced = replace(this._data, this._envs); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
34 this.push(replaced); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
35 cb(); |
|
de54585a40f1
Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
36 }; |