Giter VIP home page Giter VIP logo

Comments (5)

yonester avatar yonester commented on June 10, 2024

Let me know if you'd like me to create a PR. I just wanted to get your take on it first.

from js_data.

vlandham avatar vlandham commented on June 10, 2024

interesting! thank you for the input.

I really like your idea of splitting this into two separate functions. That really makes it read better.

I guess my only hesitation about _.reduce is the more complex API call.
Perhaps its work showing both methods?

start with the d3.nest() approach then introduce _.reduce()?

in both cases, i like your opinion to split the function out.

from js_data.

yonester avatar yonester commented on June 10, 2024

That's a fair point. If you want the code to be more instructive and easier to read, you can also be very explicit with the intermediate variables.

function trimObject(o) {
  return Object.keys(o).reduce(function(result, key) {
    var keyTrimmed = _.trim(key),
        valTrimmed = _.trim(o[key]);
    result[keyTrimmed] = valTrimmed;
    return result;
  }, {});
}

I'm using Object.keys instead of d3.keys because it's supported in ES5, so it's quite safe to use anywhere. I tend to prefer built-in methods where it makes sense.

from js_data.

yonester avatar yonester commented on June 10, 2024

In any case, since this is really just a suggestion, rather than an "issue", I'm going to close this item. The website you create is a really great educational tool. I'm happy to contribute if you need a hand. Cheers.

from js_data.

vlandham avatar vlandham commented on June 10, 2024

well, i think these are great ideas!

if you want to contribute this as an additional option - i'd love to add it.

On Wed, Nov 16, 2016 at 11:00 AM, Yony Kochinski [email protected]
wrote:

In any case, since this is really just a suggestion, rather than an
"issue", I'm going to close this item. The website you create is a really
great educational tool. I'm happy to contribute if you need a hand. Cheers.


You are receiving this because you commented.
Reply to this email directly, view it on GitHub
#32 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAAkmUOuA9H3kIPzITp3XSzPUPd9D9pAks5q-1LYgaJpZM4KyJ-y
.

from js_data.

Related Issues (16)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.