Security News
Create React App Officially Deprecated Amid React 19 Compatibility Issues
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
dsl-config
Advanced tools
Generate an asynchronous DSL to generate a configuration object
npm install dsl-config
Define the DSL (note that methods are chainable but have been spaced out here to accomodate comments)
const DSLConfig = require('dsl-config');
// create an instance
const dslConfig = new DSLConfig();
// define some values
dslConfig
.value('value1');
.value('value2');
// and lists of values
dslConfig
.list('list1');
.list('list2');
// you can define a DSL for a value or list
const subDSLConfig = new DSLConfig();
subDSLConfig
.value('value1');
.value('value2');
dslConfig.value('value3', subDSLConfig);
// you can reuse DSLs
dslConfig.list('list3', subDSLConfig);
// you can clone and extend or override DSLs
const cloneDSLConfig = new DSLConfig(subDSLConfig);
// override value2 to convert it to a list
cloneDSLConfig.list('value2');
// extend with value3
cloneDSLConfig.value('value3');
dslConfig.value('value4', cloneDSLConfig);
The above would generate a DSL to create a configuration object with the following possible structure
{
value1: 'value',
value2: 'value',
list1: [
'value',
'value'
],
list2: [
'value',
'value'
],
value3: {
value1: 'value',
value2: 'value'
},
list3: [{
value1: 'value',
value2: 'value'
}, {
value1: 'value',
value2: 'value'
}],
value4: {
value1: 'value',
value2: [
'value',
'value'
],
value3: 'value'
}
}
Then to synchronously create a configuration
const config = dslConfig.configure(config => {
config
.value1('value')
.value2('value')
.list1('value')
.list1('value')
.list2('value')
.list2('value')
.value3(value3 => {
value3
.value1('value')
.value2('value');
})
.list3(list3 => {
list3
.value1('value')
.value2('value');
})
.list3(list3 => {
list3
.value1('value')
.value2('value');
})
.value4(value4 => {
value4
.value1('value')
.value2('value')
.value2('value')
.value3('value');
});
});
You can also use generators to asynchronously create a configuration (when asynchronous, #configure
will actually return a Promise
)
dslConfig.configure(function * (dsl) {
dsl = yield config.value3(function * (value3) {
// etc...
});
// etc...
}).then(config => {
// do something with config
});
Or the DSL callbacks can return promises
dslConfig.configure(dsl => {
return dsl.value3(value3 => {
return Promise.resolve()
.then(() => {
// etc...
});
})
.then(dsl => {
// etc...
});
}).then(config => {
// do something with config
});
NB. Any fields not set using #configure
will be left undefined
FAQs
Generate a DSL config with generators
The npm package dsl-config receives a total of 0 weekly downloads. As such, dsl-config popularity was classified as not popular.
We found that dsl-config demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.