const join = require('key-value-join');
join({a: 1, b: 2}; // a:1,b:2
join({a: 1, b: 2}, '=', '&'); // a=1&b=2
join({a: 1, b: 2, c: undefined, d: false}, '=', '&', ([key, value]) => !!value); // a=1&b=2
Argument | Type | Default | Purpose |
---|---|---|---|
0 | Object | N/A | The object to convert |
1 | String | : |
Key-value delimiter |
2 | String | , |
List items delimiter |
3 | Function | ()=>true |
Function to filter object entries † |
† Filter function receives one array containing
[key, value]
const filter = ([key, value]) => Boolean(value)
Environments which exclude node_modules from the transpiling pipeline should include the "browser" entry instead of "main". This exposes an ES5 commonjs module.
Also available for explicit import:
const join = require('join/dist');