Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@ueno/config

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ueno/config - npm Package Compare versions

Comparing version 0.0.1 to 0.0.2

63

lib/index.js
'use strict';
const config = {};
const browser = {};
const defaults = {};
// Only server side
if (typeof window === 'undefined') {
// Setup dotenv
require('dotenv').config();
// Assign env to config
Object.assign(config, process.env);
// TODO: Warn when stuff is accessed without any default declerations.
}
// Set defaults
function defaults(defaultConfig) {
console.log('defaults', defaultConfig);
return true;
config.setDefaults = function setDefaults(defaultConfig) {
// Update default config
Object.assign(defaults, defaultConfig);
// Update the real config object
Object.entries(defaultConfig)
.forEach(([key, value]) => {
if (typeof config[key] === 'undefined') {
// Every key is treated as string to maintain persistency
// between POSIX and JS environment.
config[key] = String(value);
}
});
}
// Set available config to the browser
function browser() {
console.log('browser', browserConfig);
return true;
// get browser config
config.getBrowser = function getBrowser() {
const res = {};
Object.entries(browser)
.forEach(([key, value]) => {
// Make sure the environment already exists
if (typeof config[key] === 'undefined') {
return;
}
if (value !== false) {
res[key] = config[key];
}
if (typeof value === 'function') {
res[key] = String(value(res[key]));
}
});
return res;
}
// Rehydration function for the browser
function rehydrate() {
console.log('rehydrate');
config.rehydrate = function rehydrate(obj) {
Object.assign(config, obj);
}
module.exports = {
config,
defaults,
browser,
rehydrate,
}
module.exports = config;
{
"name": "@ueno/config",
"version": "0.0.1",
"version": "0.0.2",
"description": "Environment configuration toolkit",

@@ -5,0 +5,0 @@ "repository": "ueno-llc/create-react-app",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc