MCPcopy Create free account
hub / github.com/sindresorhus/query-string / definedOptions

Function definedOptions

base.js:412–422  ·  view source on GitHub ↗
(options)

Source from the content-addressed store, hash-verified

410
411// An option that is explicitly `undefined` uses its default, like an omitted option. That is what a caller passes through with an optional setting, like `{decode: config.decode}`. Spreading it over the defaults would instead override the default with `undefined`, so `{encode: undefined}` would write the values unencoded.
412function definedOptions(options) {
413 const result = {};
414
415 for (const [key, value] of Object.entries(options ?? {})) {
416 if (value !== undefined) {
417 result[key] = value;
418 }
419 }
420
421 return result;
422}
423
424// The `index` array format collects the items in an object keyed by the index. The keys are sorted as strings first, so that two spellings of the same index, like `01` and `1`, always come out in the same order, and then numerically. The empty key is the item of a scalar seen before the indexed entries, and it sorts before any index.
425function arrayFromIndexes(object) {

Callers 5

parseFunction · 0.85
stringifyFunction · 0.85
parseUrlFunction · 0.85
stringifyUrlFunction · 0.85
pickFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected