paliari-js-utils
Advanced tools
Comparing version 0.1.5 to 0.1.6
@@ -1,1 +0,1 @@ | ||
module.exports=function(t){var n={};function e(r){if(n[r])return n[r].exports;var o=n[r]={i:r,l:!1,exports:{}};return t[r].call(o.exports,o,o.exports,e),o.l=!0,o.exports}return e.m=t,e.c=n,e.d=function(t,n,r){e.o(t,n)||Object.defineProperty(t,n,{enumerable:!0,get:r})},e.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},e.t=function(t,n){if(1&n&&(t=e(t)),8&n)return t;if(4&n&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(e.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&n&&"string"!=typeof t)for(var o in t)e.d(r,o,function(n){return t[n]}.bind(null,o));return r},e.n=function(t){var n=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(n,"a",n),n},e.o=function(t,n){return Object.prototype.hasOwnProperty.call(t,n)},e.p="/",e(e.s=3)}([function(t,n,e){"use strict";e.r(n);e(2),e(1);var r=function(t,n){return String(n).split(".").forEach(function(n){if(!t)return t;t=t[n]}),t};function o(t){return(o="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)}var i=function(t){return null!==t&&"object"===o(t)},u=function(t){return Object.prototype.toString.call(t).slice(8,-1)},c=function(t){return"[object Object]"===Object.prototype.toString.call(arg)},a={"à":"a","á":"a","â":"a","ã":"a","ä":"a","å":"a","ç":"c","è":"e","é":"e","ê":"e","ë":"e","ì":"i","í":"i","î":"i","ï":"i","ñ":"n","ò":"o","ó":"o","ô":"o","õ":"o","ö":"o","ő":"o","ù":"u","ú":"u","û":"u","ü":"u","ű":"u","ý":"y","ÿ":"y"},f=function(t){return t.toLocaleLowerCase().replace(/[^a-z0-9\s_-]/g,function(t){return a[t]||t})},l=function(t){return"[object Date]"===Object.prototype.toString.call(t)},s=function(t){return"[object RegExp]"===Object.prototype.toString.call(t)},d=function(t){return t?t.charAt(0).toUpperCase()+t.substr(1):t},p=function(t){return i(t)?function t(n){if(l(n))return new Date(n);if(s(n))return n;var e=Array.isArray(n)?[]:{};return Object.keys(n).forEach(function(r){e[r]=i(n[r])?t(n[r]):n[r]}),e}(t):t};function y(t,n,e){return n in t?Object.defineProperty(t,n,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[n]=e,t}var h=function t(n){for(var e=arguments.length,r=new Array(e>1?e-1:0),o=1;o<e;o++)r[o-1]=arguments[o];if(!r.length)return n;var u=r.shift();return i(n)&&i(u)&&Object.keys(u).forEach(function(e){i(u[e])?(n[e]||Object.assign(n,y({},e,{})),t(n[e],u[e])):Object.assign(n,y({},e,u[e]))}),t.apply(void 0,[n].concat(r))},v=function(t){return function t(n){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"/",r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:[];return Object.getOwnPropertyNames(n).reduce(function(r,u){return o.push(u),i(n[u])?t(n[u],e,r,o):r[o.join(e)]=n[u],o.pop(),r},r)}(t,arguments.length>1&&void 0!==arguments[1]?arguments[1]:"/")},b="aiCOVlB8Ws3ZSMyJ64dwtqAI5TDG1ejgcFH2YfXErxbRKhzo90pvUPNnL7umkQ",g={};b.split("").sort().forEach(function(t,n){g[b.charAt(n)]=t});var m=function(t){if(!t)return t;var n="";return t.split("").forEach(function(t){n+=g[t]||t}),n},j=[100,200,500,750],w=function(t){return j.find(function(n){if(t<=n)return n})},O=function(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,e=0,r=0;Object.keys(t).forEach(function(n){r+=Number(n)*t[n],e+=t[n]});var o=Math.pow(10,n);return e?Math.round(r/e*o)/o:0},_=function(t){return t.replace(/-/g,"_").replace(/\//g,".").toLocaleLowerCase()},E=function(t,n){return"".concat(f(t),"_").concat(f(n)).replace(/ /g,"_")},S=function(t){return E(function(t){t.forEach(function(t){if(t.types.indexOf("administrative_area_level_1")>-1)return t.short_name})}(t),function(t){t.forEach(function(t){if(t.types.indexOf("administrative_area_level_2")>-1)return t.long_name})}(t))},x=function(t){if(!t.address_components)throw{code:"convert_place_no_address_componentes"};var n={};return n.geometry={viewport:{northeast:{lat:t.geometry.viewport.f.f,lng:t.geometry.viewport.b.f},southwest:{lat:t.geometry.viewport.f.b,lng:t.geometry.viewport.b.b}},location:{lat:t.geometry.location.lat(),lng:t.geometry.location.lng()}},n.formatted_address=t.formatted_address,n.place_id=t.place_id,n.cidade_id=S(t.address_components),n},A=function(){return function(t){return"desc"===t?9999999999999-Date.now():Date.now()}(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"desc").toString()+Math.random().toString().substr(2,7)},M="zyxwvutsrqponmlkjihgfedcba_ZYXWVUTSRQPONMLKJIHGFEDCBA9876543210-",k=0,C=[],L=function(){var t=Date.now(),n=t===k;k=t;for(var e=new Array(8),r=7;r>=0;r--)e[r]=M.charAt(t%64),t=Math.floor(t/64);if(0!==t)throw new Error("We should have converted the entire timestamp.");var o=e.join("");if(n){for(r=11;r>=0&&63===C[r];r--)C[r]=0;C[r]++}else for(r=0;r<12;r++)C[r]=Math.floor(64*Math.random());for(r=0;r<12;r++)o+=M.charAt(C[r]);if(20!=o.length)throw new Error("Length should be 20.");return o},P=function(t){for(var n=0,e=0;e<8;e++){var r=M.indexOf(t.charAt(e));if(-1===r)throw new Error("Invalid id!");n=64*n+r}return n},D=function t(n,e){var r=n.split(""),o=r.pop(),i=e[e.indexOf(o)+1];return i?r.join("")+i:t(r.join(""),e)+e[0]},T=function(t){return D(t,M.split(""))},R=function(t){return D(t,M.split("").sort())};var I=function t(n){var e=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};!function(t,n){if(!(t instanceof n))throw new TypeError("Cannot call a class as a function")}(this,t),Object.keys(n).forEach(function(t){"function"==typeof n[t]?e[t]=null===r[t]?null:n[t](r[t]):e[t]=r[t]||n[t]})};function N(t,n){for(var e=0;e<n.length;e++){var r=n[e];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}var G="pt_br",K=function(){function t(n){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:G;!function(t,n){if(!(t instanceof n))throw new TypeError("Cannot call a class as a function")}(this,t),this.locales=n,this.locale=e}return function(t,n,e){n&&N(t.prototype,n),e&&N(t,e)}(t,[{key:"t",value:function(t,n){return function(t,n){return t&&n?(Object.keys(n).forEach(function(e){t=t.replace(new RegExp("%{"+e+"}","g"),n[e])}),t):t}(r(this.current,t),n)}},{key:"setLocale",value:function(t){if(this.getAvailableLocales().includes(t))return this.locale=t,this;throw new Error("Locale not found!")}},{key:"getLocale",value:function(){return this.locale}},{key:"getAvailableLocales",value:function(){return Object.keys(this.locales)}},{key:"current",get:function(){return this.locales[this.locale]}}]),t}();e.d(n,"deepKey",function(){return r}),e.d(n,"isObject",function(){return i}),e.d(n,"getClassName",function(){return u}),e.d(n,"isHash",function(){return c}),e.d(n,"transliterate",function(){return f}),e.d(n,"isDate",function(){return l}),e.d(n,"isRegExp",function(){return s}),e.d(n,"ucfirst",function(){return d}),e.d(n,"deepClone",function(){return p}),e.d(n,"deepMerge",function(){return h}),e.d(n,"flattenObject",function(){return v}),e.d(n,"jsEncode",function(){return m}),e.d(n,"thumbRange",function(){return w}),e.d(n,"starRating",function(){return O}),e.d(n,"prepareKey",function(){return _}),e.d(n,"convertPlace",function(){return x}),e.d(n,"idCidade",function(){return E}),e.d(n,"idCidadeAddressComponent",function(){return S}),e.d(n,"idGeneratorDesc",function(){return L}),e.d(n,"idGeneratorNumeric",function(){return A}),e.d(n,"idDescTimestamp",function(){return P}),e.d(n,"prevId",function(){return T}),e.d(n,"nextId",function(){return R}),e.d(n,"BaseModel",function(){return I}),e.d(n,"I18n",function(){return K})},function(t,n){String.prototype.includes||(String.prototype.includes=function(){return-1!==String.prototype.indexOf.apply(this,arguments)})},function(t,n){Array.prototype.includes||Object.defineProperty(Array.prototype,"includes",{value:function(t,n){if(null==this)throw new TypeError('"this" is null or not defined');var e=Object(this),r=e.length>>>0;if(0===r)return!1;for(var o=0|n,i=Math.max(o>=0?o:r-Math.abs(o),0);i<r;){if(e[i]===t)return!0;i++}return!1}})},function(t,n,e){t.exports=e(0)}]); | ||
module.exports=function(t){var e={};function n(r){if(e[r])return e[r].exports;var o=e[r]={i:r,l:!1,exports:{}};return t[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)n.d(r,o,function(e){return t[e]}.bind(null,o));return r},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="/",n(n.s=3)}([function(t,e,n){"use strict";n.r(e);n(2),n(1);var r=function(t,e){return String(e).split(".").forEach(function(e){if(!t)return t;t=t[e]}),t};function o(t){return(o="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)}var i=function(t){return null!==t&&"object"===o(t)},u=function(t){return Object.prototype.toString.call(t).slice(8,-1)},c=function(t){return"[object Object]"===Object.prototype.toString.call(arg)},a={"à":"a","á":"a","â":"a","ã":"a","ä":"a","å":"a","ç":"c","è":"e","é":"e","ê":"e","ë":"e","ì":"i","í":"i","î":"i","ï":"i","ñ":"n","ò":"o","ó":"o","ô":"o","õ":"o","ö":"o","ő":"o","ù":"u","ú":"u","û":"u","ü":"u","ű":"u","ý":"y","ÿ":"y"},f=function(t){return t.toLocaleLowerCase().replace(/[^a-z0-9\s_-]/g,function(t){return a[t]||t})},l=function(t){return"[object Date]"===Object.prototype.toString.call(t)},s=function(t){return"[object RegExp]"===Object.prototype.toString.call(t)},d=function(t){return t?t.charAt(0).toUpperCase()+t.substr(1):t},p=function(t){return i(t)?function t(e){if(l(e))return new Date(e);if(s(e))return e;var n=Array.isArray(e)?[]:{};return Object.keys(e).forEach(function(r){n[r]=i(e[r])?t(e[r]):e[r]}),n}(t):t};function h(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}var y=function t(e){for(var n=arguments.length,r=new Array(n>1?n-1:0),o=1;o<n;o++)r[o-1]=arguments[o];if(!r.length)return e;var u=r.shift();return i(e)&&i(u)&&Object.keys(u).forEach(function(n){i(u[n])?(e[n]||Object.assign(e,h({},n,{})),t(e[n],u[n])):Object.assign(e,h({},n,u[n]))}),t.apply(void 0,[e].concat(r))},g=function(t){return function t(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"/",r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:[];return Object.getOwnPropertyNames(e).reduce(function(r,u){return o.push(u),i(e[u])?t(e[u],n,r,o):r[o.join(n)]=e[u],o.pop(),r},r)}(t,arguments.length>1&&void 0!==arguments[1]?arguments[1]:"/")},b="aiCOVlB8Ws3ZSMyJ64dwtqAI5TDG1ejgcFH2YfXErxbRKhzo90pvUPNnL7umkQ",v={};b.split("").sort().forEach(function(t,e){v[b.charAt(e)]=t});var m=function(t){if(!t)return t;var e="";return t.split("").forEach(function(t){e+=v[t]||t}),e},w=[100,200,500,750],j=function(t){return w.find(function(e){if(t<=e)return e})},O=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,n=0,r=0;Object.keys(t).forEach(function(e){r+=Number(e)*t[e],n+=t[e]});var o=Math.pow(10,e);return n?Math.round(r/n*o)/o:0},_=function(t){return t.replace(/-/g,"_").replace(/\//g,".").toLocaleLowerCase()},S=function(t,e){return"".concat(f(t),"_").concat(f(e)).replace(/ /g,"_")},E=function(t){return S(function(t){t.forEach(function(t){if(t.types.indexOf("administrative_area_level_1")>-1)return t.short_name})}(t),function(t){t.forEach(function(t){if(t.types.indexOf("administrative_area_level_2")>-1)return t.long_name})}(t))},k=function(t){if(!t.address_components)throw{code:"convert_place_no_address_componentes"};var e={};return e.geometry={viewport:{northeast:{lat:t.geometry.viewport.f.f,lng:t.geometry.viewport.b.f},southwest:{lat:t.geometry.viewport.f.b,lng:t.geometry.viewport.b.b}},location:{lat:t.geometry.location.lat(),lng:t.geometry.location.lng()}},e.formatted_address=t.formatted_address,e.place_id=t.place_id,e.cidade_id=E(t.address_components),e},x=function(){return function(t){return"desc"===t?9999999999999-Date.now():Date.now()}(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"desc").toString()+Math.random().toString().substr(2,7)},A="zyxwvutsrqponmlkjihgfedcba_ZYXWVUTSRQPONMLKJIHGFEDCBA9876543210-",L=0,P=[],M=function(){var t=Date.now(),e=t===L;L=t;for(var n=new Array(8),r=7;r>=0;r--)n[r]=A.charAt(t%64),t=Math.floor(t/64);if(0!==t)throw new Error("We should have converted the entire timestamp.");var o=n.join("");if(e){for(r=11;r>=0&&63===P[r];r--)P[r]=0;P[r]++}else for(r=0;r<12;r++)P[r]=Math.floor(64*Math.random());for(r=0;r<12;r++)o+=A.charAt(P[r]);if(20!=o.length)throw new Error("Length should be 20.");return o},C=function(t){for(var e=0,n=0;n<8;n++){var r=A.indexOf(t.charAt(n));if(-1===r)throw new Error("Invalid id!");e=64*e+r}return e},D=function t(e,n){var r=e.split(""),o=r.pop(),i=n[n.indexOf(o)+1];return i?r.join("")+i:t(r.join(""),n)+n[0]},I=function(t){return D(t,A.split(""))},T=function(t){return D(t,A.split("").sort())};var R=function t(e){var n=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),Object.keys(e).forEach(function(t){"function"==typeof e[t]?n[t]=null===r[t]?null:e[t](r[t]):n[t]=r[t]||e[t]})};function N(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}var G="pt_br",K=function(){function t(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:G;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.locales=e,this.locale=n}return function(t,e,n){e&&N(t.prototype,e),n&&N(t,n)}(t,[{key:"t",value:function(t,e){return function(t,e){return t&&e?(Object.keys(e).forEach(function(n){t=t.replace(new RegExp("%{"+n+"}","g"),e[n])}),t):t}(r(this.current,t),e)}},{key:"setLocale",value:function(t){if(this.getAvailableLocales().includes(t))return this.locale=t,this;throw new Error("Locale not found!")}},{key:"getLocale",value:function(){return this.locale}},{key:"getAvailableLocales",value:function(){return Object.keys(this.locales)}},{key:"current",get:function(){return this.locales[this.locale]}}]),t}();function z(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(t){return Object.getOwnPropertyDescriptor(n,t).enumerable}))),r.forEach(function(e){B(t,e,n[e])})}return t}function B(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function H(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}var U="current_locale",W=function(t){var e=localStorage.getItem(U)||window.navigator.language.toLowerCase().replace("-","_");return t.getAvailableLocales().includes(e)?e:(e=e.substr(0,2),t.getAvailableLocales().includes(e)?e:G)},q=function(){function t(e,n){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.i18n=e,this.fecha=n,this.current=W(e)}return function(t,e,n){e&&H(t.prototype,e),n&&H(t,n)}(t,[{key:"reset",value:function(t){t!==this.current&&(this.current=t)}},{key:"current",set:function(t){localStorage.setItem(U,t),this.i18n.setLocale(t),this.fecha&&(this.fecha.i18n=z({},this.fecha.i18n,this.i18n.t("date_time.names")),this.fecha.masks=z({},this.fecha.masks,this.i18n.t("date_time.formats")))},get:function(){return localStorage.getItem(U)}}]),t}();n.d(e,"deepKey",function(){return r}),n.d(e,"isObject",function(){return i}),n.d(e,"getClassName",function(){return u}),n.d(e,"isHash",function(){return c}),n.d(e,"transliterate",function(){return f}),n.d(e,"isDate",function(){return l}),n.d(e,"isRegExp",function(){return s}),n.d(e,"ucfirst",function(){return d}),n.d(e,"deepClone",function(){return p}),n.d(e,"deepMerge",function(){return y}),n.d(e,"flattenObject",function(){return g}),n.d(e,"jsEncode",function(){return m}),n.d(e,"thumbRange",function(){return j}),n.d(e,"starRating",function(){return O}),n.d(e,"prepareKey",function(){return _}),n.d(e,"convertPlace",function(){return k}),n.d(e,"idCidade",function(){return S}),n.d(e,"idCidadeAddressComponent",function(){return E}),n.d(e,"idGeneratorDesc",function(){return M}),n.d(e,"idGeneratorNumeric",function(){return x}),n.d(e,"idDescTimestamp",function(){return C}),n.d(e,"prevId",function(){return I}),n.d(e,"nextId",function(){return T}),n.d(e,"BaseModel",function(){return R}),n.d(e,"I18n",function(){return K}),n.d(e,"Language",function(){return q})},function(t,e){String.prototype.includes||(String.prototype.includes=function(){return-1!==String.prototype.indexOf.apply(this,arguments)})},function(t,e){Array.prototype.includes||Object.defineProperty(Array.prototype,"includes",{value:function(t,e){if(null==this)throw new TypeError('"this" is null or not defined');var n=Object(this),r=n.length>>>0;if(0===r)return!1;for(var o=0|e,i=Math.max(o>=0?o:r-Math.abs(o),0);i<r;){if(n[i]===t)return!0;i++}return!1}})},function(t,e,n){t.exports=n(0)}]); |
{ | ||
"name": "paliari-js-utils", | ||
"version": "0.1.5", | ||
"version": "0.1.6", | ||
"description": "Biblioteca de utilidades para JS", | ||
@@ -5,0 +5,0 @@ "main": "dist/paliari-js-utils.js", |
@@ -97,2 +97,23 @@ # paliari-js-utils | ||
## Language | ||
```js | ||
import fecha from 'fecha' | ||
import { I18n, Language } from 'paliari-js-utils' | ||
const i18n = new I18n(locales, 'pt_br') | ||
const language = new Language(i18n, fecha) | ||
// Exemplo para Vuejs | ||
import { Language } from 'paliari-js-utils' | ||
export default { | ||
install(vue, i18n, fecha) { | ||
vue.prototype.$language = new Language(i18n, fecha) | ||
vue.language = vue.prototype.$language | ||
} | ||
} | ||
``` | ||
## BaseModel | ||
@@ -99,0 +120,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
17720
369