qs icon indicating copy to clipboard operation
qs copied to clipboard

How to flag skip empty sring

Open PayteR opened this issue 6 years ago • 2 comments

skipNull is usefull flag https://github.com/ljharb/qs/pull/106 but i need to take it to the next level - i need to ignore empty strings, could you add this feature?

I solved this by deepMap function for now https://stackoverflow.com/a/25334280/839434

function deepMap (obj, iterator, context) {
  return _.transform(obj, function (result, val, key) {
    result[key] = _.isObject(val) && !_.isDate(val)
      ? deepMap(val, iterator, context)
      : iterator.call(context, val, key, obj)
  })
}

let cleanObject = deepMap(object, function (val) {
    return val || null
})

PayteR avatar Jan 01 '19 15:01 PayteR

I believe #226 might give you what you need?

ljharb avatar Jan 01 '19 18:01 ljharb

any news for this issue?

zek avatar Jan 19 '23 02:01 zek