diff third_party/bun/node_modules/loose-envify/loose-envify.js @ 12:de54585a40f1

Adding bun and node modules.
author June Park <parkjune1995@gmail.com>
date Thu, 02 Oct 2025 14:39:48 -0700
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/third_party/bun/node_modules/loose-envify/loose-envify.js	Thu Oct 02 14:39:48 2025 -0700
@@ -0,0 +1,36 @@
+'use strict';
+
+var stream = require('stream');
+var util = require('util');
+var replace = require('./replace');
+
+var jsonExtRe = /\.json$/;
+
+module.exports = function(rootEnv) {
+  rootEnv = rootEnv || process.env;
+  return function (file, trOpts) {
+    if (jsonExtRe.test(file)) {
+      return stream.PassThrough();
+    }
+    var envs = trOpts ? [rootEnv, trOpts] : [rootEnv];
+    return new LooseEnvify(envs);
+  };
+};
+
+function LooseEnvify(envs) {
+  stream.Transform.call(this);
+  this._data = '';
+  this._envs = envs;
+}
+util.inherits(LooseEnvify, stream.Transform);
+
+LooseEnvify.prototype._transform = function(buf, enc, cb) {
+  this._data += buf;
+  cb();
+};
+
+LooseEnvify.prototype._flush = function(cb) {
+  var replaced = replace(this._data, this._envs);
+  this.push(replaced);
+  cb();
+};