idf / commons-util-js

Common utilities for JavaScript

Repository from Github https://github.comidf/commons-util-jsRepository from Github https://github.comidf/commons-util-js

Common JavaScript Utils() {

Common utilities for JavaScript.
This is Noah's Ark for Atwood's Law: "any application that can be written in JavaScript, will eventually be written in JavaScript." 😂

##Installations

As Git Subtree

git remote add -f util-js git@github.com:idf/commons-util-js.git
git subtree add --prefix [dir/]util-js util-js develop --squash
git subtree pull --prefix [dir/]util-js util-js develop --squash
git subtree push --prefix [dir/]util-js util-js develop 

###Common Utils for Everything

<script type="text/javascript" src="/js/commons-util-js/DomUtils.js"></script>
<script type="text/javascript" src="/js/commons-util-js/PrimitiveExtensions.js"></script>

####Dependencies

  • JQuery
  • JQuery-UI

###Common Utils for AngularJS

<script type="text/javascript" src="/js/commons-util-js/angularjs/filters.js"></script>

####Dependencies

  • AngularJS

##Friends

  • JSHint for code quality.
  • Bower for package management.

###JSHint JetBrains configuration - opt for using config files .jshintrc.

##Best Practice for JS Folder Structure ref

www/
    index.html
    js/
        app/
            sub.js
        lib/
            jquery.js
            canvas.js
        app.js
        require.js

Immediately Invoked Function Expression (IIFE)

(function(){
  /* code */
}());

// And that's the way if some parameters shall be passed
(function(a, b){
  /* code */
})(arg1, arg2); //arg1 -> a; arg2 -> b

Functions

  • Prefer function delectation than anonymous function (function expression), because of facilitation of hoisting.
  • Prefer anonymous function to be one-line.

##CSS/JS Dependencies Do not commit 3rd party/ventor CSS/JS. Use bower.json to update dependencies instead Initialize bower

bower init

Update dependencies:

bower update

};

About

Common utilities for JavaScript

License:Apache License 2.0


Languages

Language:HTML 51.2%Language:JavaScript 48.0%Language:CSS 0.8%