Mask.js, Sloc

Alex R. Young





jquery browser build-tools

Mask.js, Sloc

Posted by Alex R. Young on .

jquery browser build-tools

Mask.js, Sloc

Posted by Alex R. Young on .


Mask.js (GitHub: bguzmanrio/maskjs, License: GPL) by Borja Guzmán is a library for validating input fields against dates, numbers, and text. It allows people to type in dates using numbers so they don't have to type in the necessary punctuation.

It prevents invalid input from being typed and allows you to skip between numbers, so it's less rigid than some implementations.

The API uses methods on Mask:

  $el: $('input.name'),
  mask: 'HH:mm',
  errorFunction: function() {},
  defaultValue: '12:00'


If you want to generate metrics for a project like source code length, how do you do things like ignore comments and empty lines? Sloc (GitHub: flosse/sloc, License: MIT, npm: sloc, Bower: sloc-bower) by flosse handles these edge cases and more. It also supports lots of languages, including JavaScript, CoffeeScript, Lua, and Swift.

It comes with a command-line script that you can run with sloc file.js, and it'll automatically recurse directories. There are options for ignoring files (--exclude pattern) and selecting an output format (--format [json|csv|cli-table]).

Sloc has a Node module, so you can require('sloc') and run sloc(source, language) to get an object with various statistics. The project itself is well-tested, and has some cool usages like atom-sloc.