
Security News
GitHub Actions Pricing Whiplash: Self-Hosted Actions Billing Change Postponed
GitHub postponed a new billing model for self-hosted Actions after developer pushback, but moved forward with hosted runner price cuts on January 1.
config-extends
Advanced tools
Allow to extend json or yaml/json files configuration
This api allows to extend one or more json objects
This api allows to extend configuration from a file or several files from a path
Note: Only node.js
npm install config-extends
If you want to extends from CLI, install config-extends globally:
npm install -g config-extends
const ConfigExtends = require("config-extends")
let source ={
data : {_extends:'base',d:3,e:4},
base: {a:1,b:2}
};
let config = ConfigExtends.extends(source);
console.log(JSON.stringify(config,null,2));
<script src="config-extends.min.js"></script>
let source ={
data : {_extends:'base',d:3,e:4},
base: {a:1,b:2}
};
let config = ConfigExtends.extends(source);
console.log(JSON.stringify(config,null,2));
extends
usage: config-extends extends -s
arguments:
-s, --source Input json (serialized).
apply
usage: config-extends apply -s [-t]
arguments:
-s, --source Input path of folder or file.
-t, --target output file (optional).
let source ={
data : {_extends:'base',d:3,e:4},
base: {a:1,b:2}
};
let config = ConfigExtends.extends(source);
console.log(JSON.stringify(config,null,2));
result:
{
"data": {"d": 3,"e": 4,"a": 1,"b": 2 },
"base": {"a": 1,"b": 2}
}
let source ={
data: { 1: {_extends:'base',d:3,e:4},
2: {_extends:'data.1', f:3,g:4},
},
base: {a:1,b:2}
}
let config = ConfigExtends.extends(source);
console.log(JSON.stringify(config,null,2));
result:
{
"data": {
"1":{"d": 3,"e": 4,"a": 1,"b": 2 },
"2":{"f": 3,"g": 4,"d": 3,"e": 4,"a": 1,"b": 2}
},
"base": {"a": 1,"b": 2}
}
let source ={
data: { 1: {_extends:'base',d:3,e:4},
2: {_extends:['base','base2'], f:3,g:4},
},
base: {a:1,b:2},
base2: {h:'a',i:'b'}
};
let config = ConfigExtends.extends(source);
console.log(JSON.stringify(config,null,2));
result:
{
"data": {
"1": {"d": 3,"e": 4,"a": 1,"b": 2},
"2": {"f": 3,"g": 4,"a": 1,"b": 2,"h": "a","i": "b"}
},
"base": {"a": 1,"b": 2 },
"base2": {"h": "a","i": "b"}
}
let config = await ConfigExtends.apply(path.join(__dirname,'test-1'));
console.log(JSON.stringify(config,null,2));
structure folder
result
{
"file": { "a": 1, "b": "b" },
"folder1": { "file1": { "c": 3 } },
"folder2": {
"file1": { "d": 1, "a": 1, "b": "b", "c": 3 },
"file2": { "e": 1, "d": 1, "a": 1, "b": "b", "c": 3 }
}
}
config-extends apply -s ./test/test-1
result:
{
"file": { "a": 1, "b": "b" },
"folder1": { "file1": { "c": 3 } },
"folder2": {
"file1": { "d": 1, "a": 1, "b": "b", "c": 3 },
"file2": { "e": 1, "d": 1, "a": 1, "b": "b", "c": 3 }
}
}
let config = await configExtends.apply(path.join(__dirname,'raspberry.yaml'));
console.log(JSON.stringify(config.version,null,2));
raspberry.yaml
version:
PiA:
_extends: [family.Pi, model.A]
PiB:
_extends: [family.Pi, model.B]
PiA+:
_extends: [family.Pi, model.A]
measure:
_extends: measure.compact
PiB+:
_extends: [family.Pi, model.B]
Pi2B:
measure:
_extends: measure.standard
Pi3A:
_extends: [family.Pi3, model.A]
Pi3A+:
_extends: [family.Pi3, model.A]
Pi3B+:
_extends: [family.Pi3, model.B]
Pi4B1G:
_extends: family.Pi4
memory: 1G
Pi4B2G:
_extends: family.Pi4
memory: 2G
Pi4B4G:
_extends: family.Pi4
memory: 4G
Pi4B8G:
_extends: family.Pi4
memory: 8G
family:
Pi:
wireless: false
measure:
_extends: measure.standard
Pi3:
wireless: true
measure:
_extends: measure.standard
Pi4:
_extends: [model.B]
wireless: true
measure:
_extends: measure.standard
model:
A:
ethernet: false
B:
ethernet: true
measure:
standard:
high: 85.6
long: 56.5
compact:
high: 65
long: 56.5
result:
{
"PiA": {"wireless": false,"measure": {"high": 85.6,"long": 56.5 },"ethernet": false},
"PiB": {"wireless": false,"measure": {"high": 85.6,"long": 56.5 },"ethernet": true },
"PiA+": {"measure": {"high": 85.6,"long": 56.5},"wireless": false,"ethernet": false },
"PiB+": {"wireless": false,"measure": {"high": 85.6,"long": 56.5},"ethernet": true },
"Pi2B": {"measure": {"high": 85.6,"long": 56.5}},
"Pi3A": {"wireless": true,"measure": {"high": 85.6,"long": 56.5},"ethernet": false },
"Pi3A+":{"wireless": true,"measure": {"high": 85.6,"long": 56.5},"ethernet": false },
"Pi3B+":{"wireless": true,"measure": {"high": 85.6,"long": 56.5},"ethernet": true },
"Pi4B1G":{"memory": "1G","wireless": true,"measure": {"high": 85.6,"long": 56.5},"ethernet": true},
"Pi4B2G":{"memory": "2G","wireless": true,"measure": {"high": 85.6,"long": 56.5},"ethernet": true},
"Pi4B4G":{"memory": "4G","wireless": true,"measure": {"high": 85.6,"long": 56.5 },"ethernet": true},
"Pi4B8G": {"memory": "8G","wireless": true,"measure": {"high": 85.6,"long": 56.5 },"ethernet": true}
}
npm run test
FAQs
Allow to extend yaml or json files configuration
The npm package config-extends receives a total of 1 weekly downloads. As such, config-extends popularity was classified as not popular.
We found that config-extends demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 3 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.

Security News
GitHub postponed a new billing model for self-hosted Actions after developer pushback, but moved forward with hosted runner price cuts on January 1.

Research
Destructive malware is rising across open source registries, using delays and kill switches to wipe code, break builds, and disrupt CI/CD.

Security News
Socket CTO Ahmad Nassri shares practical AI coding techniques, tools, and team workflows, plus what still feels noisy and why shipping remains human-led.