Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to flag skip empty sring #292

Open
PayteR opened this issue Jan 1, 2019 · 2 comments
Open

How to flag skip empty sring #292

PayteR opened this issue Jan 1, 2019 · 2 comments

Comments

@PayteR
Copy link

PayteR commented Jan 1, 2019

skipNull is usefull flag #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
})
@ljharb
Copy link
Owner

ljharb commented Jan 1, 2019

I believe #226 might give you what you need?

@zek

This comment was marked as spam.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants