diff --git a/.travis.yml b/.travis.yml
index c55c789..690f760 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,6 +1,8 @@
language: node_js
node_js:
+ - "6"
+ - "5"
+ - "4"
- "0.11"
- - "0.10"
before_install:
- npm install -g bower
diff --git a/CHANGELOG.md b/CHANGELOG.md
index ba9b7b0..b264807 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,13 @@
+
+# [0.5.0](https://github.com/the-darc/br-masks/compare/0.4.1...0.5.0) (2016-11-09)
+
+
+### Features
+
+* **phone:** added support for 0800 phone numbers ([8fb2f46](https://github.com/the-darc/br-masks/commit/8fb2f46)), closes [#8](https://github.com/the-darc/br-masks/pull/8)
+* **cnpj-base:** added support for cnpj-base.js ([5cc07ff](https://github.com/the-darc/br-masks/commit/5cc07ff)), closes [#7](https://github.com/the-darc/br-masks/pull/7)
+
+
### 0.4.1 (2015-09-01)
diff --git a/README.md b/README.md
index 20dc293..e8a85b5 100644
--- a/README.md
+++ b/README.md
@@ -87,6 +87,10 @@ See: [Conferência de Inscrições Estaduais](http://www.sintegra.gov.br/insc_es
var phone9 = '38212201255';
var masked9 = BrM.phone(phone9);
// masked9 should be '(38) 21220-1255'
+
+ var phone0800 = '08001234567';
+ var masked0800 = BrM.phone(phone0800);
+ // masked0800 should be '0800-123-4567'
```
### FINANCE ###
diff --git a/bower.json b/bower.json
index c9189c0..332a4b5 100644
--- a/bower.json
+++ b/bower.json
@@ -1,6 +1,6 @@
{
"name": "br-masks",
- "version": "0.4.1",
+ "version": "0.5.0",
"description": "A library of masks applicable to several Brazilian data like I.E., CNPJ, CPF and others",
"homepage": "http://github.com/the-darc/br-masks",
"repository": {
@@ -18,6 +18,7 @@
"mask",
"cpf",
"cnpj",
+ "cnpj base",
"inscrição estadual",
"cep",
"telefone"
@@ -32,6 +33,6 @@
"package.json"
],
"dependencies": {
- "string-mask": "^0.2.1"
+ "string-mask": "^0.3.0"
}
}
diff --git a/gulpfile.js b/gulpfile.js
index 9ec2f86..fcc8dd8 100644
--- a/gulpfile.js
+++ b/gulpfile.js
@@ -15,7 +15,7 @@ var config = {
test: {
files: 'test/**/*.test.js'
}
-}
+};
var header = ['/**',
' * <%= pkg.name %>',
@@ -25,6 +25,7 @@ var header = ['/**',
' * @license <%= pkg.license %>',
' */',
'(function (root, factory) {',
+ ' /* istanbul ignore next */',
' if (typeof define === \'function\' && define.amd) {',
' // AMD. Register as an anonymous module.',
' define([\'string-mask\'], factory);',
@@ -38,6 +39,7 @@ var header = ['/**',
' root.BrM = factory(root.StringMask);',
' }',
'}(this, function (StringMask) {',
+ ' /* istanbul ignore if */',
' if (!StringMask) {',
' throw new Error(\'StringMask not found\');',
' }',
@@ -48,6 +50,7 @@ var footer = ['',
' ie: IE,',
' cpf: CPF,',
' cnpj: CNPJ,',
+ ' cnpjBase: CNPJBASE,',
' phone: PHONE,',
' cep: CEP,',
' finance: FINANCE,',
@@ -140,22 +143,3 @@ gulp.task('test-coverage', function(done) {
});
});
});
-
-gulp.task('changelog', function(done) {
- var changelog = require('conventional-changelog');
-
- var options = {
- repository: pkg.homepage,
- version: pkg.version,
- file: path.join(__dirname, 'CHANGELOG.md')
- };
-
- changelog(options, function(err, log) {
- if (err) {
- throw err;
- }
-
- fs.writeFile(options.file, log, done);
- });
-});
-
diff --git a/package.json b/package.json
index 449d475..553e99b 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "br-masks",
- "version": "0.4.1",
+ "version": "0.5.0",
"description": "A library of masks applicable to several Brazilian data like I.E., CNPJ, CPF and others",
"id": "/br-masks",
"main": "releases/br-masks.js",
@@ -14,13 +14,14 @@
},
"scripts": {
"test": "gulp test-coverage",
- "postupdate": "bower update"
+ "release": "conventional-changelog -p angular -i CHANGELOG.md -s"
},
"keywords": [
"masks",
"mascara",
"cpf",
"cnpj",
+ "cnpj base",
"inscrição estadual",
"cep"
],
@@ -30,21 +31,22 @@
},
"license": "MIT",
"dependencies": {
- "string-mask": "^0.2.1"
+ "string-mask": "^0.3.0"
},
"devDependencies": {
- "conventional-changelog": "0.0.17",
- "gulp": "^3.7.0",
- "gulp-concat": "^2.3.4",
+ "conventional-changelog": "^1.1.0",
+ "gulp": "^3.9.1",
+ "gulp-concat": "^2.6.0",
"gulp-coveralls": "^0.1.4",
"gulp-footer": "^1.0.5",
"gulp-header": "^1.0.5",
- "gulp-istanbul": "^0.9.0",
- "gulp-jshint": "^1.6.1",
- "gulp-load-plugins": "^0.5.3",
- "gulp-mocha": "^1.0.0",
- "gulp-uglify": "^0.3.2",
- "jshint-stylish": "^0.2.0",
- "should": "^4.0.1"
+ "gulp-istanbul": "^1.1.1",
+ "gulp-jshint": "^2.0.2",
+ "gulp-load-plugins": "^1.4.0",
+ "gulp-mocha": "^3.0.1",
+ "gulp-uglify": "^2.0.0",
+ "jshint": "^2.9.4",
+ "jshint-stylish": "^2.2.1",
+ "should": "^11.1.1"
}
}
diff --git a/releases/br-masks-standalone.js b/releases/br-masks-standalone.js
index 3a6c363..298928c 100644
--- a/releases/br-masks-standalone.js
+++ b/releases/br-masks-standalone.js
@@ -194,11 +194,12 @@
/**
* br-masks
* A library of masks applicable to several Brazilian data like I.E., CNPJ, CPF and others
- * @version v0.4.1
+ * @version v0.5.0
* @link http://github.com/the-darc/br-masks
* @license MIT
*/
(function (root, factory) {
+ /* istanbul ignore next */
if (typeof define === 'function' && define.amd) {
// AMD. Register as an anonymous module.
define(['string-mask'], factory);
@@ -212,6 +213,7 @@
root.BrM = factory(root.StringMask);
}
}(this, function (StringMask) {
+ /* istanbul ignore if */
if (!StringMask) {
throw new Error('StringMask not found');
}
@@ -225,6 +227,16 @@ var CEP = function(value) {
return processed.result;
};
+/*exported CNPJBASE */
+var CNPJBASE = function(value) {
+ if(!value) {
+ return value;
+ }
+ var cnpjBasePattern = new StringMask('00.000.000');
+ var formatedValue = cnpjBasePattern.apply(value);
+ return formatedValue;
+};
+
/*exported CNPJ */
var CNPJ = function(value) {
if(!value) {
@@ -367,7 +379,8 @@ var NFEACCESSKEY = function(value) {
/*exported PHONE */
var PHONE = function(value) {
var phoneMask8D = new StringMask('(00) 0000-0000'),
- phoneMask9D = new StringMask('(00) 00000-0000');
+ phoneMask9D = new StringMask('(00) 00000-0000'),
+ phoneMask0800 = new StringMask('0000-000-0000');
if(!value) {
return value;
@@ -375,7 +388,9 @@ var PHONE = function(value) {
var formatedValue;
value = value + '';
- if(value.length < 11){
+ if (value.indexOf('0800') === 0) {
+ formatedValue = phoneMask0800.apply(value);
+ }else if(value.length < 11){
formatedValue = phoneMask8D.apply(value);
}else{
formatedValue = phoneMask9D.apply(value);
@@ -388,6 +403,7 @@ var PHONE = function(value) {
ie: IE,
cpf: CPF,
cnpj: CNPJ,
+ cnpjBase: CNPJBASE,
phone: PHONE,
cep: CEP,
finance: FINANCE,
diff --git a/releases/br-masks-standalone.min.js b/releases/br-masks-standalone.min.js
index 3195d68..39ce0e6 100644
--- a/releases/br-masks-standalone.min.js
+++ b/releases/br-masks-standalone.min.js
@@ -1 +1 @@
-!function(e,n){"function"==typeof define&&define.amd?define([],n):"object"==typeof exports?module.exports=n():e.StringMask=n()}(this,function(){function e(e,n){for(var t=0,r=n-1,s={escape:!0};r>=0&&s&&s.escape;)s=a[e.charAt(r)],t+=s&&s.escape?1:0,r--;return t>0&&t%2===1}function n(e,n){var t=e.replace(/[^0]/g,"").length,r=n.replace(/[^\d]/g,"").length;return r-t}function t(e,n,t,r){return r&&"function"==typeof r.transform&&(n=r.transform(n)),t.reverse?n+e:e+n}function r(e,n,t){var s=e.charAt(n),i=a[s];return""===s?!1:i&&!i.escape?!0:r(e,n+t,t)}function s(e,n,t){var r=e.split("");return r.splice(t>=0?t:0,0,n),r.join("")}function i(e,n){this.options=n||{},this.options={reverse:this.options.reverse||!1,usedefaults:this.options.usedefaults||this.options.reverse},this.pattern=e}var a={0:{pattern:/\d/,_default:"0"},9:{pattern:/\d/,optional:!0},"#":{pattern:/\d/,optional:!0,recursive:!0},S:{pattern:/[a-zA-Z]/},U:{pattern:/[a-zA-Z]/,transform:function(e){return e.toLocaleUpperCase()}},L:{pattern:/[a-zA-Z]/,transform:function(e){return e.toLocaleLowerCase()}},$:{escape:!0}};return i.prototype.process=function(i){function o(e){if(!w&&r(p,k,m.inc))return!0;if(w||(w=v.length>0),w){var n=v.shift();if(v.push(n),e.reverse&&c>=0)return k++,p=s(p,n,k),!0;if(!e.reverse&&c=0}if(!i)return"";i+="";for(var p=this.pattern,u=!0,f="",c=this.options.reverse?i.length-1:0,l=n(p,i),h=!1,v=[],w=!1,m={start:this.options.reverse?p.length-1:0,end:this.options.reverse?-1:p.length,inc:this.options.reverse?-1:1},k=m.start;o(this.options);k+=m.inc){var d=p.charAt(k),g=i.charAt(c),y=a[d];if(!w||g){if(this.options.reverse&&e(p,k)){f=t(f,d,this.options,y),k+=m.inc;continue}if(!this.options.reverse&&h){f=t(f,d,this.options,y),h=!1;continue}if(!this.options.reverse&&y&&y.escape){h=!0;continue}}if(!w&&y&&y.recursive)v.push(d);else{if(w&&!g){y&&y.recursive||(f=t(f,d,this.options,y));continue}if(v.length>0&&y&&!y.recursive){u=!1;continue}if(!w&&v.length>0&&!g)continue}if(y)if(y.optional){if(y.pattern.test(g)&&l)f=t(f,g,this.options,y),c+=m.inc,l--;else if(v.length>0&&g){u=!1;break}}else if(y.pattern.test(g))f=t(f,g,this.options,y),c+=m.inc;else{if(g||!y._default||!this.options.usedefaults){u=!1;break}f=t(f,y._default,this.options,y)}else f=t(f,d,this.options,y),!w&&v.length&&v.push(d)}return{result:f,valid:u}},i.prototype.apply=function(e){return this.process(e).result},i.prototype.validate=function(e){return this.process(e).valid},i.process=function(e,n,t){return new i(n,t).process(e)},i.apply=function(e,n,t){return new i(n,t).apply(e)},i.validate=function(e,n,t){return new i(n,t).validate(e)},i}),function(e,n){"function"==typeof define&&define.amd?define(["string-mask"],n):"object"==typeof exports?module.exports=n(require("string-mask")):e.BrM=n(e.StringMask)}(this,function(e){if(!e)throw new Error("StringMask not found");var n=function(n){var t=new e("00000-000");if(!n)return n;var r=t.process(n);return r.result},t=function(n){if(!n)return n;var t=new e("00.000.000/0000-00"),r=t.apply(n);return r},r=function(e){return e&&e.length?e.length<=11?s(e):t(e):e},s=function(n){var t=new e("000.000.000-00");if(!n)return n;var r=t.apply(n);return r},i=function(n,t,r,s){t=!t&&0!==t||0>t?2:t,r=r||".",s=s||"";var i=t>0?r+new Array(t+1).join("0"):"",a="#"+s+"##0"+i;n=parseFloat(n),n||(n=0);var o=!1;0>n&&(n=-1*n,o=!0);var p=new e(a,{reverse:!0}),u=p.apply(n.toFixed(t).replace(/[^\d]+/g,""));return o?"("+u+")":u},a=function(n,t){function r(e){return e.replace(/[^0-9]/g,"")}function s(e,n){if(!e||!i[e])return void 0;var t=e.toUpperCase();if("SP"===t&&/^P/i.test(n))return i.SP[1].mask;for(var s=i[e],a=0;s[a].chars&&s[a].chars=0&&s&&s.escape;)s=a[e.charAt(r)],t+=s&&s.escape?1:0,r--;return t>0&&t%2===1}function n(e,n){var t=e.replace(/[^0]/g,"").length,r=n.replace(/[^\d]/g,"").length;return r-t}function t(e,n,t,r){return r&&"function"==typeof r.transform&&(n=r.transform(n)),t.reverse?n+e:e+n}function r(e,n,t){var s=e.charAt(n),i=a[s];return""!==s&&(!(!i||i.escape)||r(e,n+t,t))}function s(e,n,t){var r=e.split("");return r.splice(t>=0?t:0,0,n),r.join("")}function i(e,n){this.options=n||{},this.options={reverse:this.options.reverse||!1,usedefaults:this.options.usedefaults||this.options.reverse},this.pattern=e}var a={0:{pattern:/\d/,_default:"0"},9:{pattern:/\d/,optional:!0},"#":{pattern:/\d/,optional:!0,recursive:!0},S:{pattern:/[a-zA-Z]/},U:{pattern:/[a-zA-Z]/,transform:function(e){return e.toLocaleUpperCase()}},L:{pattern:/[a-zA-Z]/,transform:function(e){return e.toLocaleLowerCase()}},$:{escape:!0}};return i.prototype.process=function(i){function o(e){if(!w&&r(p,k,m.inc))return!0;if(w||(w=v.length>0),w){var n=v.shift();if(v.push(n),e.reverse&&c>=0)return k++,p=s(p,n,k),!0;if(!e.reverse&&c=0}if(!i)return"";i+="";for(var p=this.pattern,u=!0,f="",c=this.options.reverse?i.length-1:0,l=n(p,i),h=!1,v=[],w=!1,m={start:this.options.reverse?p.length-1:0,end:this.options.reverse?-1:p.length,inc:this.options.reverse?-1:1},k=m.start;o(this.options);k+=m.inc){var d=p.charAt(k),g=i.charAt(c),y=a[d];if(!w||g){if(this.options.reverse&&e(p,k)){f=t(f,d,this.options,y),k+=m.inc;continue}if(!this.options.reverse&&h){f=t(f,d,this.options,y),h=!1;continue}if(!this.options.reverse&&y&&y.escape){h=!0;continue}}if(!w&&y&&y.recursive)v.push(d);else{if(w&&!g){y&&y.recursive||(f=t(f,d,this.options,y));continue}if(v.length>0&&y&&!y.recursive){u=!1;continue}if(!w&&v.length>0&&!g)continue}if(y)if(y.optional){if(y.pattern.test(g)&&l)f=t(f,g,this.options,y),c+=m.inc,l--;else if(v.length>0&&g){u=!1;break}}else if(y.pattern.test(g))f=t(f,g,this.options,y),c+=m.inc;else{if(g||!y._default||!this.options.usedefaults){u=!1;break}f=t(f,y._default,this.options,y)}else f=t(f,d,this.options,y),!w&&v.length&&v.push(d)}return{result:f,valid:u}},i.prototype.apply=function(e){return this.process(e).result},i.prototype.validate=function(e){return this.process(e).valid},i.process=function(e,n,t){return new i(n,t).process(e)},i.apply=function(e,n,t){return new i(n,t).apply(e)},i.validate=function(e,n,t){return new i(n,t).validate(e)},i}),function(e,n){"function"==typeof define&&define.amd?define(["string-mask"],n):"object"==typeof exports?module.exports=n(require("string-mask")):e.BrM=n(e.StringMask)}(this,function(e){if(!e)throw new Error("StringMask not found");var n=function(n){var t=new e("00000-000");if(!n)return n;var r=t.process(n);return r.result},t=function(n){if(!n)return n;var t=new e("00.000.000"),r=t.apply(n);return r},r=function(n){if(!n)return n;var t=new e("00.000.000/0000-00"),r=t.apply(n);return r},s=function(e){return e&&e.length?e.length<=11?i(e):r(e):e},i=function(n){var t=new e("000.000.000-00");if(!n)return n;var r=t.apply(n);return r},a=function(n,t,r,s){t=!t&&0!==t||t<0?2:t,r=r||".",s=s||"";var i=t>0?r+new Array(t+1).join("0"):"",a="#"+s+"##0"+i;n=parseFloat(n),n||(n=0);var o=!1;n<0&&(n*=-1,o=!0);var p=new e(a,{reverse:!0}),u=p.apply(n.toFixed(t).replace(/[^\d]+/g,""));return o?"("+u+")":u},o=function(n,t){function r(e){return e.replace(/[^0-9]/g,"")}function s(e,n){if(e&&i[e]){var t=e.toUpperCase();if("SP"===t&&/^P/i.test(n))return i.SP[1].mask;for(var s=i[e],a=0;s[a].chars&&s[a].charsr?2:r,a=a||".",s=s||"";var t=r>0?a+new Array(r+1).join("0"):"",w="#"+s+"##0"+t;e=parseFloat(e),e||(e=0);var i=!1;0>e&&(e=-1*e,i=!0);var u=new n(w,{reverse:!0}),k=u.apply(e.toFixed(r).replace(/[^\d]+/g,""));return i?"("+k+")":k},w=function(e,r){function a(n){return n.replace(/[^0-9]/g,"")}function s(n,e){if(!n||!t[n])return void 0;var r=n.toUpperCase();if("SP"===r&&/^P/i.test(e))return t.SP[1].mask;for(var s=t[n],w=0;s[w].chars&&s[w].chars0?a+new Array(r+1).join("0"):"",w="#"+t+"##0"+s;e=parseFloat(e),e||(e=0);var i=!1;e<0&&(e*=-1,i=!0);var u=new n(w,{reverse:!0}),f=u.apply(e.toFixed(r).replace(/[^\d]+/g,""));return i?"("+f+")":f},i=function(e,r){function a(n){return n.replace(/[^0-9]/g,"")}function t(n,e){if(n&&s[n]){var r=n.toUpperCase();if("SP"===r&&/^P/i.test(e))return s.SP[1].mask;for(var t=s[n],w=0;t[w].chars&&t[w].chars