Git Product home page Git Product logo

sqimitive's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

sqimitive's Issues

simplify if-elseif-else + return spaghetti to make code more readable and transparent

if (typeof func == 'string') {
  var parts = func.split(/([.-].*)/)
  if (parts.length > 1) {
    return Core.masker(parts[0], parts[1], obj)
  } else {
    return function () {
      var callCx = obj || this
      return callCx[func].apply(callCx, arguments)
    }
  }
} else {
  return obj ? _.bind(func, obj) : func
}

vs

if (typeof func == 'string') {
  var parts = func.split(/([.-].*)/)

  if (parts.length > 1) {
    return Core.masker(parts[0], parts[1], obj)
  }

  return function () {
    var callCx = obj || this
    return callCx[func].apply(callCx, arguments)
  }
}

return obj ? _.bind(func, obj) : func

if (_.isArguments(value)) {
  return Array.prototype.slice.call(value)
} else if (!_.isArray(value)) {
  return [value]
} else {
  return value
}

vs

if (_.isArguments(value)) {
  return Array.prototype.slice.call(value)
}

if (!_.isArray(value)) {
  return [value]
}

return value

if (typeof event == 'object') {
  for (var name in event) {
    var names = name.split(', ')
    for (var i = 0, l = names.length; i < l; ++i) {
      this.fuse(names[i], event[name], func)
    }
  }
  return this
} else if (arguments.length >= 2) {
  return this._regHandler( this.fuse(event, func, cx) )
} else {
  throw 'on: Bad arguments'
}

vs

if (typeof event == 'object') {
  for (var name in event) {
    var names = name.split(', ')
    for (var i = 0, l = names.length; i < l; ++i) {
      this.fuse(names[i], event[name], func)
    }
  }

  return this
}

if (arguments.length >= 2) {
  return this._regHandler( this.fuse(event, func, cx) )
}

throw 'on: Bad arguments'

and so on... I understand that this may be just your preferred codestyle, but I think it's a good pattern to make code more readable at least from visual side.

integrate and use ESLint and JSCS

ESLint:

ESLint is a tool for identifying and reporting on patterns found in ECMAScript/JavaScript code. In many ways, it is similar to JSLint and JSHint with a few exceptions

JSCS:

jscs is a code style checker. You can configure jscs for your project in detail using over 60 validation rules, including presets from popular style guides like jQuery.

I can help you with it, but you should define your codestyle and express it with .eslint and .jscsrc.

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.