Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

vue2-filters

Package Overview
Dependencies
Maintainers
1
Versions
39
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vue2-filters - npm Package Compare versions

Comparing version 0.11.0 to 0.11.1-beta.0

48

dist/vue2-filters.js

@@ -671,3 +671,3 @@ (function webpackUniversalModuleDefinition(root, factory) {

* @params {Object} options
*
*
*/

@@ -690,16 +690,5 @@

var int = config.decimals === 0 ? number_toFixed(number.float, 0) : number.int;
switch (config.base) {
case '':
int = '';
break;
case '0,0':
int = addSeparator(int, thousandsSeparator);
break;
}
var fraction = getFraction(number.float, config.decimals, decimalSeparator);
return config.sign + int + fraction;
var rounded = number_toFixed(number.float, config.decimals);
var output = addSeparators(rounded, config.base, thousandsSeparator, decimalSeparator);
return config.sign + output;
}

@@ -743,9 +732,9 @@

value: 1,
symbol: ""
symbol: ''
}, {
value: 1E3,
symbol: "K"
value: 1e3,
symbol: 'K'
}, {
value: 1E6,
symbol: "M"
value: 1e6,
symbol: 'M'
}];

@@ -760,7 +749,7 @@ var i;

num = (num / si[i].value).toFixed(config.decimals).replace(rx, "$1");
num = (num / si[i].value).toFixed(config.decimals).replace(rx, '$1');
return num + config.unit.replace('a', si[i].symbol);
}
function addSeparator(num, separator) {
function addSeparators(num, base, thousandsSeparator, decimalSeparator) {
var regex = /(\d+)(\d{3})/;

@@ -770,6 +759,15 @@ var string = num.toString();

var x1 = x[0];
var x2 = x.length > 1 ? '.' + x[1] : '';
var x2 = x.length > 1 ? decimalSeparator + x[1] : '';
while (regex.test(x1)) {
x1 = x1.replace(regex, '$1' + separator + '$2');
switch (base) {
case '':
x1 = '';
break;
case '0,0':
while (regex.test(x1)) {
x1 = x1.replace(regex, '$1' + thousandsSeparator + '$2');
}
break;
}

@@ -776,0 +774,0 @@

@@ -1,1 +0,1 @@

!function(t,e){if("object"==typeof exports&&"object"==typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var r=e();for(var n in r)("object"==typeof exports?exports:t)[n]=r[n]}}("undefined"!=typeof self?self:this,function(){return n={},i.m=r=[function(t,e,r){"use strict";r.r(e);var i={};r.r(i),r.d(i,"capitalize",function(){return p}),r.d(i,"uppercase",function(){return y}),r.d(i,"lowercase",function(){return d}),r.d(i,"placeholder",function(){return b}),r.d(i,"truncate",function(){return v});var o={};function n(t){return function(t){if(Array.isArray(t)){for(var e=0,r=new Array(t.length);e<t.length;e++)r[e]=t[e];return r}}(t)||function(t){if(Symbol.iterator in Object(t)||"[object Arguments]"===Object.prototype.toString.call(t))return Array.from(t)}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance")}()}function u(t){return(u="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}r.r(o),r.d(o,"currency",function(){return j}),r.d(o,"bytes",function(){return x}),r.d(o,"pluralize",function(){return O}),r.d(o,"ordinal",function(){return M}),r.d(o,"number",function(){return N}),r.d(o,"percent",function(){return F});var a=Array.prototype,c=Object.prototype,l=(a.slice,c.toString),s={isArray:function(t){return Array.isArray(t)}},f=Math.pow(2,53)-1;s.isArrayLike=function(t){if("object"!==u(t)||!t)return!1;var e=t.length;return"number"==typeof e&&e%1==0&&0<=e&&e<=f},s.isObject=function(t){var e=u(t);return"function"===e||"object"===e&&!!t},s.each=function(t,e){var r,n;if(s.isArray(t))for(r=0,n=t.length;r<n&&!1!==e(t[r],r,t);r++);else for(r in t)if(!1===e(t[r],r,t))break;return t},s.each(["Arguments","Function","String","Number","Date","RegExp","Error"],function(e){s["is"+e]=function(t){return l.call(t)==="[object "+e+"]"}}),s.toArray=function(t,e){e=e||0;for(var r=t.length-e,n=new Array(r);r--;)n[r]=t[r+e];return n},s.toNumber=function(t){if("string"!=typeof t)return t;var e=Number(t);return isNaN(e)?t:e},s.convertRangeToArray=function(t){return n(Array(t+1).keys()).slice(1)},s.convertArray=function(t){if(s.isArray(t))return t;if(s.isPlainObject(t)){for(var e,r=Object.keys(t),n=r.length,i=new Array(n);n--;)e=r[n],i[n]={$key:e,$value:t[e]};return i}return t||[]},s.getPath=function(t,e){return function t(e,r){return r.length?t(e[r[0]],r.slice(1)):e}(t,e.split("."))};l=Object.prototype.toString;s.isPlainObject=function(t){return"[object Object]"===l.call(t)},s.exist=function(t){return null!=t};var h=s;var p=function(t,e){var r=this&&this.capitalize?this.capitalize:{},n=null!=(e=e||r).onlyFirstLetter&&e.onlyFirstLetter;return t||0===t?!0===n?t.toString().charAt(0).toUpperCase()+t.toString().slice(1):(t=t.toString().toLowerCase().split(" ")).map(function(t){return t.charAt(0).toUpperCase()+t.slice(1)}).join(" "):""};var y=function(t){return t||0===t?t.toString().toUpperCase():""};var d=function(t){return t||0===t?t.toString().toLowerCase():""};var b=function(t,e){return void 0===t||""===t||null===t?e:t};var v=function(t,e){return e=e||15,t&&"string"==typeof t?t.length<=e?t:t.substring(0,e)+"...":""};function g(t,e,r){return t=h.isArray(t)?t:h.convertRangeToArray(t),r=r?parseInt(r,10):0,"number"==typeof(e=h.toNumber(e))?t.slice(r,r+e):t}function m(t,e){var r;if(h.isPlainObject(t)){var n=Object.keys(t);for(r=n.length;r--;)if(m(t[n[r]],e))return!0}else if(h.isArray(t)){for(r=t.length;r--;)if(m(t[r],e))return!0}else if(null!=t)return-1<t.toString().toLowerCase().indexOf(e)}var A=function(t,e){if(t=h.convertArray(t),null==e)return t;if("function"==typeof e)return t.filter(e);e=(""+e).toLowerCase();for(var r,n,i,o,u=Array.prototype.concat.apply([],h.toArray(arguments,2)),a=[],c=0,l=t.length;c<l;c++)if(i=(r=t[c])&&r.$value||r,o=u.length){for(;o--;)if("$key"===(n=u[o])&&m(r.$key,e)||m(h.getPath(i,n),e)){a.push(r);break}}else m(r,e)&&a.push(r);return a};function S(t){var i,n=null;t=h.convertArray(t);var e=h.toArray(arguments,1),o=e[e.length-1];"number"==typeof o?(o=o<0?-1:1,e=1<e.length?e.slice(0,-1):e):o=1;var r=e[0];if(!r)return t;function u(t,e,r){var n=i[r];return n&&("$key"!==n&&(h.isObject(t)&&"$value"in t&&(t=t.$value),h.isObject(e)&&"$value"in e&&(e=e.$value)),t=h.isObject(t)?h.getPath(t,n):t,e=h.isObject(e)?h.getPath(e,n):e,t="string"==typeof t?t.toLowerCase():t,e="string"==typeof e?e.toLowerCase():e),t===e?0:e<t?o:-o}return n="function"==typeof r?function(t,e){return r(t,e)*o}:(i=Array.prototype.concat.apply([],e),function(t,e,r){return(r=r||0)>=i.length-1?u(t,e,r):u(t,e,r)||n(t,e,r+1)}),t.slice().sort(n)}function w(t,e){var r=A.apply(this,arguments);return r.splice(1),r}var j=function(t,e,r,n){var i,o,u,a,c=this&&this.currency?this.currency:{};e=h.exist(e)?e:c.symbol,r=h.exist(r)?r:c.decimalDigits,n=n||c;var l=/(\d{3})(?=\d)/g;if(t=parseFloat(t),!isFinite(t)||!t&&0!==t)return"";e=void 0!==e?e:"$",r=void 0!==r?r:2,i=null!=n.thousandsSeparator?n.thousandsSeparator:",",o=null==n.symbolOnLeft||n.symbolOnLeft,u=null!=n.spaceBetweenAmountAndSymbol&&n.spaceBetweenAmountAndSymbol,a=null!=n.showPlusSign&&n.showPlusSign;var s=function(t,e){return(+(Math.round(+(t+"e"+e))+"e"+-e)).toFixed(e)}(Math.abs(t),r);s=n.decimalSeparator?s.replace(".",n.decimalSeparator):s;var f=r?s.slice(0,-1-r):s,p=f.length%3,y=0<p?f.slice(0,p)+(3<f.length?i:""):"",d=r?s.slice(-1-r):"";return e=u?o?e+" ":" "+e:e,(0<t&&a?"+":"")+(t<0?"-":"")+(e=o?e+y+f.slice(p).replace(l,"$1"+i)+d:y+f.slice(p).replace(l,"$1"+i)+d+e)};var x=function(t,e){var r=this&&this.bytes?this.bytes:{};return e=void 0!==(e=h.exist(e)?e:r.decimalDigits)?e:2,(t=null===t||isNaN(t)?0:t)>=Math.pow(1024,4)?"".concat((t/Math.pow(1024,4)).toFixed(e)," TB"):t>=Math.pow(1024,3)?"".concat((t/Math.pow(1024,3)).toFixed(e)," GB"):t>=Math.pow(1024,2)?"".concat((t/Math.pow(1024,2)).toFixed(e)," MB"):1024<=t?"".concat((t/1024).toFixed(e)," kB"):"".concat(t,1===t?" byte":" bytes")};var O=function(t,e,r){var n=this&&this.pluralize?this.pluralize:{},i="";return!0===(null!=(r=r||n).includeNumber&&r.includeNumber)&&(i+=t+" "),!t&&0!==t||!e||(Array.isArray(e)?i+=e[t-1]||e[e.length-1]:i+=e+(1===t?"":"s")),i};var M=function(t,e){var r=this&&this.ordinal?this.ordinal:{},n="";!0===(null!=(e=e||r).includeNumber&&e.includeNumber)&&(n+=t);var i=t%10,o=t%100;return n+=1==i&&11!=o?"st":2==i&&12!=o?"nd":3==i&&13!=o?"rd":"th"};function $(t,e){return(+(Math.round(+(t+"e"+e))+"e"+-e)).toFixed(e)}Math.sign=function(t){return 0===(t=+t)||isNaN(t)?t:0<t?1:-1};var N=function(t,e,r){var n=this&&this.number?this.number:{};r=r||n;var i=function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:"0",e=t?t.match(/([\+\-])?([0-9\,]+)?([\.0-9]+)?([a\s]+)?/):["","","","",""],r=e[3],n=r?r.match(/0/g).length:0;return{sign:e[1]||"",base:e[2]||"",decimals:n,unit:e[4]||""}}(e=h.exist(e)?e:n.format),o=function(t){return{float:Math.abs(parseFloat(t)),int:Math.abs(parseInt(t)),sign:Math.sign(t)<0?"-":""}}(t),u=null!=r.thousandsSeparator?r.thousandsSeparator:",",a=null!=r.decimalSeparator?r.decimalSeparator:".";if(i.sign=i.sign||o.sign,i.unit){var c=function(t,e){var r,n=[{value:1,symbol:""},{value:1e3,symbol:"K"},{value:1e6,symbol:"M"}];for(r=n.length-1;0<r&&!(t>=n[r].value);r--);return(t=(t/n[r].value).toFixed(e.decimals).replace(/\.0+$|(\.[0-9]*[1-9])0+$/,"$1"))+e.unit.replace("a",n[r].symbol)}(o.float,i);return i.sign+c}var l=0===i.decimals?$(o.float,0):o.int;switch(i.base){case"":l="";break;case"0,0":l=function(t,e){var r=/(\d+)(\d{3})/,n=t.toString().split("."),i=n[0],o=1<n.length?"."+n[1]:"";for(;r.test(i);)i=i.replace(r,"$1"+e+"$2");return i+o}(l,u)}var s=function(t,e,r){var n=$(t,e).toString().split(".")[1];return n?r+n:""}(o.float,i.decimals,a);return i.sign+l+s};var F=function(t,e,r){var n=this&&this.percent?this.percent:{};return r=void 0!==(r=h.exist(r)?r:n.multiplier)?r:100,e=void 0!==(e=h.exist(e)?e:n.decimalDigits)?e:0,t=null===t||isNaN(t)?0:t,"".concat((t*r).toFixed(e),"%")},P={install:function(r,n){h.each(i,function(t,e){r.filter(e,t.bind(n))}),h.each(o,function(t,e){r.filter(e,t.bind(n))})},mixin:{methods:{limitBy:g,filterBy:A,orderBy:S,find:w}}};e.default=P;"undefined"!=typeof window&&window.Vue&&(window.Vue.use(P),window.Vue2Filters=P)}],i.c=n,i.d=function(t,e,r){i.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},i.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},i.t=function(e,t){if(1&t&&(e=i(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(i.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var n in e)i.d(r,n,function(t){return e[t]}.bind(null,n));return r},i.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return i.d(e,"a",e),e},i.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},i.p="",i(i.s=0);function i(t){if(n[t])return n[t].exports;var e=n[t]={i:t,l:!1,exports:{}};return r[t].call(e.exports,e,e.exports,i),e.l=!0,e.exports}var r,n});
!function(t,e){if("object"==typeof exports&&"object"==typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var r=e();for(var n in r)("object"==typeof exports?exports:t)[n]=r[n]}}("undefined"!=typeof self?self:this,function(){return n={},i.m=r=[function(t,e,r){"use strict";r.r(e);var i={};r.r(i),r.d(i,"capitalize",function(){return p}),r.d(i,"uppercase",function(){return y}),r.d(i,"lowercase",function(){return d}),r.d(i,"placeholder",function(){return b}),r.d(i,"truncate",function(){return v});var o={};function n(t){return function(t){if(Array.isArray(t)){for(var e=0,r=new Array(t.length);e<t.length;e++)r[e]=t[e];return r}}(t)||function(t){if(Symbol.iterator in Object(t)||"[object Arguments]"===Object.prototype.toString.call(t))return Array.from(t)}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance")}()}function u(t){return(u="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}r.r(o),r.d(o,"currency",function(){return j}),r.d(o,"bytes",function(){return x}),r.d(o,"pluralize",function(){return O}),r.d(o,"ordinal",function(){return M}),r.d(o,"number",function(){return N}),r.d(o,"percent",function(){return F});var a=Array.prototype,c=Object.prototype,l=(a.slice,c.toString),s={isArray:function(t){return Array.isArray(t)}},f=Math.pow(2,53)-1;s.isArrayLike=function(t){if("object"!==u(t)||!t)return!1;var e=t.length;return"number"==typeof e&&e%1==0&&0<=e&&e<=f},s.isObject=function(t){var e=u(t);return"function"===e||"object"===e&&!!t},s.each=function(t,e){var r,n;if(s.isArray(t))for(r=0,n=t.length;r<n&&!1!==e(t[r],r,t);r++);else for(r in t)if(!1===e(t[r],r,t))break;return t},s.each(["Arguments","Function","String","Number","Date","RegExp","Error"],function(e){s["is"+e]=function(t){return l.call(t)==="[object "+e+"]"}}),s.toArray=function(t,e){e=e||0;for(var r=t.length-e,n=new Array(r);r--;)n[r]=t[r+e];return n},s.toNumber=function(t){if("string"!=typeof t)return t;var e=Number(t);return isNaN(e)?t:e},s.convertRangeToArray=function(t){return n(Array(t+1).keys()).slice(1)},s.convertArray=function(t){if(s.isArray(t))return t;if(s.isPlainObject(t)){for(var e,r=Object.keys(t),n=r.length,i=new Array(n);n--;)e=r[n],i[n]={$key:e,$value:t[e]};return i}return t||[]},s.getPath=function(t,e){return function t(e,r){return r.length?t(e[r[0]],r.slice(1)):e}(t,e.split("."))};l=Object.prototype.toString;s.isPlainObject=function(t){return"[object Object]"===l.call(t)},s.exist=function(t){return null!=t};var h=s;var p=function(t,e){var r=this&&this.capitalize?this.capitalize:{},n=null!=(e=e||r).onlyFirstLetter&&e.onlyFirstLetter;return t||0===t?!0===n?t.toString().charAt(0).toUpperCase()+t.toString().slice(1):(t=t.toString().toLowerCase().split(" ")).map(function(t){return t.charAt(0).toUpperCase()+t.slice(1)}).join(" "):""};var y=function(t){return t||0===t?t.toString().toUpperCase():""};var d=function(t){return t||0===t?t.toString().toLowerCase():""};var b=function(t,e){return void 0===t||""===t||null===t?e:t};var v=function(t,e){return e=e||15,t&&"string"==typeof t?t.length<=e?t:t.substring(0,e)+"...":""};function g(t,e,r){return t=h.isArray(t)?t:h.convertRangeToArray(t),r=r?parseInt(r,10):0,"number"==typeof(e=h.toNumber(e))?t.slice(r,r+e):t}function m(t,e){var r;if(h.isPlainObject(t)){var n=Object.keys(t);for(r=n.length;r--;)if(m(t[n[r]],e))return!0}else if(h.isArray(t)){for(r=t.length;r--;)if(m(t[r],e))return!0}else if(null!=t)return-1<t.toString().toLowerCase().indexOf(e)}var A=function(t,e){if(t=h.convertArray(t),null==e)return t;if("function"==typeof e)return t.filter(e);e=(""+e).toLowerCase();for(var r,n,i,o,u=Array.prototype.concat.apply([],h.toArray(arguments,2)),a=[],c=0,l=t.length;c<l;c++)if(i=(r=t[c])&&r.$value||r,o=u.length){for(;o--;)if("$key"===(n=u[o])&&m(r.$key,e)||m(h.getPath(i,n),e)){a.push(r);break}}else m(r,e)&&a.push(r);return a};function S(t){var i,n=null;t=h.convertArray(t);var e=h.toArray(arguments,1),o=e[e.length-1];"number"==typeof o?(o=o<0?-1:1,e=1<e.length?e.slice(0,-1):e):o=1;var r=e[0];if(!r)return t;function u(t,e,r){var n=i[r];return n&&("$key"!==n&&(h.isObject(t)&&"$value"in t&&(t=t.$value),h.isObject(e)&&"$value"in e&&(e=e.$value)),t=h.isObject(t)?h.getPath(t,n):t,e=h.isObject(e)?h.getPath(e,n):e,t="string"==typeof t?t.toLowerCase():t,e="string"==typeof e?e.toLowerCase():e),t===e?0:e<t?o:-o}return n="function"==typeof r?function(t,e){return r(t,e)*o}:(i=Array.prototype.concat.apply([],e),function(t,e,r){return(r=r||0)>=i.length-1?u(t,e,r):u(t,e,r)||n(t,e,r+1)}),t.slice().sort(n)}function w(t,e){var r=A.apply(this,arguments);return r.splice(1),r}var j=function(t,e,r,n){var i,o,u,a,c=this&&this.currency?this.currency:{};e=h.exist(e)?e:c.symbol,r=h.exist(r)?r:c.decimalDigits,n=n||c;var l=/(\d{3})(?=\d)/g;if(t=parseFloat(t),!isFinite(t)||!t&&0!==t)return"";e=void 0!==e?e:"$",r=void 0!==r?r:2,i=null!=n.thousandsSeparator?n.thousandsSeparator:",",o=null==n.symbolOnLeft||n.symbolOnLeft,u=null!=n.spaceBetweenAmountAndSymbol&&n.spaceBetweenAmountAndSymbol,a=null!=n.showPlusSign&&n.showPlusSign;var s=function(t,e){return(+(Math.round(+(t+"e"+e))+"e"+-e)).toFixed(e)}(Math.abs(t),r);s=n.decimalSeparator?s.replace(".",n.decimalSeparator):s;var f=r?s.slice(0,-1-r):s,p=f.length%3,y=0<p?f.slice(0,p)+(3<f.length?i:""):"",d=r?s.slice(-1-r):"";return e=u?o?e+" ":" "+e:e,(0<t&&a?"+":"")+(t<0?"-":"")+(e=o?e+y+f.slice(p).replace(l,"$1"+i)+d:y+f.slice(p).replace(l,"$1"+i)+d+e)};var x=function(t,e){var r=this&&this.bytes?this.bytes:{};return e=void 0!==(e=h.exist(e)?e:r.decimalDigits)?e:2,(t=null===t||isNaN(t)?0:t)>=Math.pow(1024,4)?"".concat((t/Math.pow(1024,4)).toFixed(e)," TB"):t>=Math.pow(1024,3)?"".concat((t/Math.pow(1024,3)).toFixed(e)," GB"):t>=Math.pow(1024,2)?"".concat((t/Math.pow(1024,2)).toFixed(e)," MB"):1024<=t?"".concat((t/1024).toFixed(e)," kB"):"".concat(t,1===t?" byte":" bytes")};var O=function(t,e,r){var n=this&&this.pluralize?this.pluralize:{},i="";return!0===(null!=(r=r||n).includeNumber&&r.includeNumber)&&(i+=t+" "),!t&&0!==t||!e||(Array.isArray(e)?i+=e[t-1]||e[e.length-1]:i+=e+(1===t?"":"s")),i};var M=function(t,e){var r=this&&this.ordinal?this.ordinal:{},n="";!0===(null!=(e=e||r).includeNumber&&e.includeNumber)&&(n+=t);var i=t%10,o=t%100;return n+=1==i&&11!=o?"st":2==i&&12!=o?"nd":3==i&&13!=o?"rd":"th"};function $(t,e){return(+(Math.round(+(t+"e"+e))+"e"+-e)).toFixed(e)}Math.sign=function(t){return 0===(t=+t)||isNaN(t)?t:0<t?1:-1};var N=function(t,e,r){var n=this&&this.number?this.number:{};r=r||n;var i=function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:"0",e=t?t.match(/([\+\-])?([0-9\,]+)?([\.0-9]+)?([a\s]+)?/):["","","","",""],r=e[3],n=r?r.match(/0/g).length:0;return{sign:e[1]||"",base:e[2]||"",decimals:n,unit:e[4]||""}}(e=h.exist(e)?e:n.format),o=function(t){return{float:Math.abs(parseFloat(t)),int:Math.abs(parseInt(t)),sign:Math.sign(t)<0?"-":""}}(t),u=null!=r.thousandsSeparator?r.thousandsSeparator:",",a=null!=r.decimalSeparator?r.decimalSeparator:".";if(i.sign=i.sign||o.sign,i.unit){var c=function(t,e){var r,n=[{value:1,symbol:""},{value:1e3,symbol:"K"},{value:1e6,symbol:"M"}];for(r=n.length-1;0<r&&!(t>=n[r].value);r--);return(t=(t/n[r].value).toFixed(e.decimals).replace(/\.0+$|(\.[0-9]*[1-9])0+$/,"$1"))+e.unit.replace("a",n[r].symbol)}(o.float,i);return i.sign+c}var l=function(t,e,r,n){var i=/(\d+)(\d{3})/,o=t.toString().split("."),u=o[0],a=1<o.length?n+o[1]:"";switch(e){case"":u="";break;case"0,0":for(;i.test(u);)u=u.replace(i,"$1"+r+"$2")}return u+a}($(o.float,i.decimals),i.base,u,a);return i.sign+l};var F=function(t,e,r){var n=this&&this.percent?this.percent:{};return r=void 0!==(r=h.exist(r)?r:n.multiplier)?r:100,e=void 0!==(e=h.exist(e)?e:n.decimalDigits)?e:0,t=null===t||isNaN(t)?0:t,"".concat((t*r).toFixed(e),"%")},P={install:function(r,n){h.each(i,function(t,e){r.filter(e,t.bind(n))}),h.each(o,function(t,e){r.filter(e,t.bind(n))})},mixin:{methods:{limitBy:g,filterBy:A,orderBy:S,find:w}}};e.default=P;"undefined"!=typeof window&&window.Vue&&(window.Vue.use(P),window.Vue2Filters=P)}],i.c=n,i.d=function(t,e,r){i.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},i.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},i.t=function(e,t){if(1&t&&(e=i(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(i.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var n in e)i.d(r,n,function(t){return e[t]}.bind(null,n));return r},i.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return i.d(e,"a",e),e},i.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},i.p="",i(i.s=0);function i(t){if(n[t])return n[t].exports;var e=n[t]={i:t,l:!1,exports:{}};return r[t].call(e.exports,e,e.exports,i),e.l=!0,e.exports}var r,n});
{
"name": "vue2-filters",
"version": "0.11.0",
"version": "0.11.1-beta.0",
"description": "A collection of Vue.js filters",

@@ -5,0 +5,0 @@ "main": "dist/vue2-filters.js",

@@ -7,7 +7,7 @@ import util from '../util/index'

* @params {Object} options
*
*
*/
function number (value, format, options) {
const globalOptions = (this && this.number) ? this.number : {}
function number(value, format, options) {
const globalOptions = this && this.number ? this.number : {}
format = util.exist(format) ? format : globalOptions.format

@@ -22,26 +22,18 @@ options = options || globalOptions

if(config.unit) {
if (config.unit) {
const numberWithUnit = addUnit(number.float, config)
return config.sign + numberWithUnit
}
let int = config.decimals === 0 ? toFixed(number.float, 0) : number.int
switch(config.base) {
case '':
int = ''
break
case '0,0':
int = addSeparator(int, thousandsSeparator)
break
}
let fraction = getFraction(number.float, config.decimals, decimalSeparator)
const rounded = toFixed(number.float, config.decimals)
return config.sign + int + fraction
const output = addSeparators(rounded, config.base, thousandsSeparator, decimalSeparator)
return config.sign + output
}
Math.sign = function(x) {
Math.sign = function (x) {
x = +x
if (x === 0 || isNaN(x)) {
return x
return x
}

@@ -61,3 +53,3 @@ return x > 0 ? 1 : -1

const regex = /([\+\-])?([0-9\,]+)?([\.0-9]+)?([a\s]+)?/
const matches = string ? string.match(regex) : ['','','','','']
const matches = string ? string.match(regex) : ['', '', '', '', '']
const float = matches[3]

@@ -77,5 +69,5 @@ const decimals = float ? float.match(/0/g).length : 0

const si = [
{ value: 1, symbol: "" },
{ value: 1E3, symbol: "K" },
{ value: 1E6, symbol: "M" }
{ value: 1, symbol: '' },
{ value: 1e3, symbol: 'K' },
{ value: 1e6, symbol: 'M' }
]

@@ -90,3 +82,3 @@

num = (num / si[i].value).toFixed(config.decimals).replace(rx, "$1")
num = (num / si[i].value).toFixed(config.decimals).replace(rx, '$1')

@@ -96,3 +88,3 @@ return num + config.unit.replace('a', si[i].symbol)

function addSeparator(num, separator) {
function addSeparators(num, base, thousandsSeparator, decimalSeparator) {
const regex = /(\d+)(\d{3})/

@@ -102,5 +94,13 @@ const string = num.toString()

let x1 = x[0]
let x2 = x.length > 1 ? '.' + x[1] : ''
while (regex.test(x1)) {
x1 = x1.replace(regex, '$1' + separator + '$2')
let x2 = x.length > 1 ? decimalSeparator + x[1] : ''
switch (base) {
case '':
x1 = ''
break
case '0,0':
while (regex.test(x1)) {
x1 = x1.replace(regex, '$1' + thousandsSeparator + '$2')
}
break
}

@@ -121,2 +121,2 @@

export default number
export default number

@@ -33,2 +33,5 @@ var stringFilters = require('../src/string/index')

expect(filter(123456.789, '0.00', { decimalSeparator: '|' })).toBe('123456|79')
expect(filter(10000.998, '0,0.00', { thousandsSeparator: '.', decimalSeparator: '|' })).toBe(
'10.001|00'
)
})

@@ -41,4 +44,4 @@

decimalSeparator: '|',
format: '0,0.000',
},
format: '0,0.000'
}
})

@@ -169,4 +172,4 @@

spaceBetweenAmountAndSymbol: true,
showPlusSign: true,
},
showPlusSign: true
}
})

@@ -206,3 +209,3 @@

var filter = otherFilters.pluralize.bind({
pluralize: { includeNumber: false },
pluralize: { includeNumber: false }
})

@@ -236,3 +239,3 @@ var word = 'item'

var filter = otherFilters.ordinal.bind({
ordinal: { includeNumber: false },
ordinal: { includeNumber: false }
})

@@ -268,3 +271,3 @@

var filter = otherFilters.bytes.bind({
bytes: { decimalDigits: 1 },
bytes: { decimalDigits: 1 }
})

@@ -300,3 +303,3 @@

var filter = otherFilters.percent.bind({
percent: { decimalDigits: 1, multiplier: 150 },
percent: { decimalDigits: 1, multiplier: 150 }
})

@@ -352,3 +355,3 @@

{ a: 2, b: 'hello' },
{ a: 3, b: ['yoyo'] },
{ a: 3, b: ['yoyo'] }
]

@@ -387,3 +390,3 @@ var res

{ firstname: 'C', lastname: 'B' },
{ firstname: 'A', lastname: 'D' },
{ firstname: 'A', lastname: 'D' }
]

@@ -405,3 +408,3 @@ // multiple string keys

{ a: 2, b: 'hello' },
{ a: 3, b: ['yoyo'] },
{ a: 3, b: ['yoyo'] }
]

@@ -417,3 +420,3 @@ var res = find(arr, 'hello')

{ a: { b: 2 }, c: 'c' },
{ a: { b: 1 }, c: 'a' },
{ a: { b: 1 }, c: 'a' }
]

@@ -443,3 +446,3 @@ var res

{ $key: 'c', $value: 1 },
{ $key: 'b', $value: 2 },
{ $key: 'b', $value: 2 }
]

@@ -454,3 +457,3 @@ var res = filter(arr, '$key')

{ $key: 'c', $value: { v: 1 } },
{ $key: 'b', $value: { v: 2 } },
{ $key: 'b', $value: { v: 2 } }
]

@@ -483,3 +486,3 @@ res = filter(arr, 'v')

{ a: 0, b: 0, c: 0 }, // 4
{ a: 0, b: 1, c: 0 }, // 5
{ a: 0, b: 1, c: 0 } // 5
]

@@ -486,0 +489,0 @@ var res

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc