Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Also, if he ever needs to check if a variable is a number, there is another one-line-of-JS project on npm that does just that!


But it isn't one line:

    var clone = require('clone');
    module.exports = function(options, defaults) {
      options = options || {};
      Object.keys(defaults).forEach(function(key) {
        if (typeof options[key] === 'undefined') {
          options[key] = clone(defaults[key]);
        }
      });
      return options;
    };
Besides the tests and the fact that someone is maintaining it. It's not much, but it's code that doesn't have to be maintained by you




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: