
Product
Introducing Tier 1 Reachability: Precision CVE Triage for Enterprise Teams
Socket’s new Tier 1 Reachability filters out up to 80% of irrelevant CVEs, so security teams can focus on the vulnerabilities that matter.
@deboxsoft/config
Advanced tools
$ npm install @deboxsoft/react-config
set( configuration [, options] )
import config from '@deboxsoft/react-config';
config.set({
foo: 'bar',
bar: {
baz: 'qux'
},
baz: ['qux']
});
@deboxsoft/react-config
.get( [key], [default] )
import config from '@deboxsoft/react-config';
config.get('foo'); //'bar'
config.get('bar'); //{ baz: 'qux' }
config.get('bar.baz'); //'qux'
config.get('baz'); //['qux']
config.get('baz.0'); //'qux'
null
value by default.serialize()
import config from '@deboxsoft/react-config';
config.serialize(); //"{foo:'bar',bar:{baz:'qux'},baz:['qux']}"
Serialize configuration to a superset of JSON.
reset()
import reset from '@deboxsoft/react-config/reset';
reset();
This is a testing utility that removes the existing configuration from the require cache. By calling this, calling config.set(configuration)
and then re-requiring any target file, that target file will then be returned from require with the new configuration
applied.
config.js (global configuration file)
const config = {
foo: 'bar'
};
export default config;
server.js (initiation of server side process)
import config from '@deboxsoft/react-config';
import configuration from './config';
import App from './app';
config.set(configuration);
new App();
render.js (render of server side process)
import config from 'react-config';
export renderScripts = () =>
`
<script>
window.__INITIAL_CONFIG__ = ${config.serialize()};
</script>
`;
client.js (initiation of client side js, assume compiled via browserify / webpack / similar)
import React from 'react';
import config from '@deboxsoft/react-config';
import App from './app';
(function clientJS() {
config.set(window.__INITIAL_CONFIG__);
React.render(<App/>, document);
}());
component.js (somewhere inside the client side app)
import React from 'react';
import config from 'react-config';
class Component extends React.Component {
render() {
return (
<div>{ config.get('foo') }</div>
);
}
};
export default Component;
appLogic.test.js
import reset from '@deboxsoft/react-config/reset';
import assert from 'assert';
describe('appLogic', () => {
it('should return foo from configuration', () => {
import config from '@deboxsoft/react-config';
const foos = [ 'alpha', 'beta', 'gamma' ];
foos.forEach((foo) => {
// This only works because `freeze: false` was set the first time set was called (in gulp/test.js).
config.set({ foo: foo });
const appLogic = require('./appLogic');
assert(appLogic() === foo);
});
});
afterEach(() => {
reset();
});
});
React global configuration was initially inspired by global-configuration. Many thanks to Josh-a-e.
FAQs
For setting a global config object managed as a requirement
The npm package @deboxsoft/config receives a total of 0 weekly downloads. As such, @deboxsoft/config popularity was classified as not popular.
We found that @deboxsoft/config demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket’s new Tier 1 Reachability filters out up to 80% of irrelevant CVEs, so security teams can focus on the vulnerabilities that matter.
Research
/Security News
Ongoing npm supply chain attack spreads to DuckDB: multiple packages compromised with the same wallet-drainer malware.
Security News
The MCP Steering Committee has launched the official MCP Registry in preview, a central hub for discovering and publishing MCP servers.