@devgrace/utils
Advanced tools
Comparing version 0.1.2 to 0.1.3
export * from './common'; | ||
export * from './device'; | ||
export * from './format'; |
@@ -1,1 +0,1 @@ | ||
"use strict";function n(n,e,t,r){return new(t||(t=Promise))((function(o,i){function u(n){try{c(r.next(n))}catch(n){i(n)}}function a(n){try{c(r.throw(n))}catch(n){i(n)}}function c(n){var e;n.done?o(n.value):(e=n.value,e instanceof t?e:new t((function(n){n(e)}))).then(u,a)}c((r=r.apply(n,e||[])).next())}))}function e(n,e){var t,r,o,i,u={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(c){return function(a){if(t)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(u=0)),u;)try{if(t=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return u.label++,{value:a[1],done:!1};case 5:u.label++,r=a[1],a=[0];continue;case 7:a=u.ops.pop(),u.trys.pop();continue;default:if(!(o=u.trys,(o=o.length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){u=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){u.label=a[1];break}if(6===a[0]&&u.label<o[1]){u.label=o[1],o=a;break}if(o&&u.label<o[2]){u.label=o[2],u.ops.push(a);break}o[2]&&u.ops.pop(),u.trys.pop();continue}a=e.call(n,u)}catch(n){a=[6,n],r=0}finally{t=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}}"function"==typeof SuppressedError&&SuppressedError;var t=0,r=0,o=function(){var n=(new Date).getTime();return r===n?t+=1:(r=n,t=0),(1e3*n+t)/1e3},i=function(){return"undefined"==typeof window&&"undefined"!=typeof global},u=function(){if(i())return!1;var n=window.navigator.userAgent;return/Android|webOS|iPhone|iPad|iPod|Windows Phone|BlackBerry|IEMobile|Opera Mini/i.test(n)};exports.abRandom=function(){return Math.random()<.5?0:1},exports.asyncNoop=function(){return n(void 0,void 0,void 0,(function(){return e(this,(function(n){return[2]}))}))},exports.getOS=function(){return i()?"server":window.navigator.userAgent.match(/ipad|iphone|ipod/i)?"ios":!!window.navigator.userAgent.match(/Android/i)?"android":u()?"otherMobile":"web"},exports.getUniqId=function(){return(1e3*o()).toString(16)},exports.getUniqTime=o,exports.getViewportSize=function(){return i()?{width:0,height:0}:{width:window.innerWidth,height:window.innerHeight}},exports.isClient=function(){return!i()},exports.isMobile=u,exports.isServer=i,exports.noop=function(){}; | ||
"use strict";function e(e,n,t,r){return new(t||(t=Promise))((function(o,i){function u(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var n;e.done?o(e.value):(n=e.value,n instanceof t?n:new t((function(e){e(n)}))).then(u,a)}c((r=r.apply(e,n||[])).next())}))}function n(e,n){var t,r,o,i,u={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(c){return function(a){if(t)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(u=0)),u;)try{if(t=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return u.label++,{value:a[1],done:!1};case 5:u.label++,r=a[1],a=[0];continue;case 7:a=u.ops.pop(),u.trys.pop();continue;default:if(!(o=u.trys,(o=o.length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){u=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){u.label=a[1];break}if(6===a[0]&&u.label<o[1]){u.label=o[1],o=a;break}if(o&&u.label<o[2]){u.label=o[2],u.ops.push(a);break}o[2]&&u.ops.pop(),u.trys.pop();continue}a=n.call(e,u)}catch(e){a=[6,e],r=0}finally{t=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}}"function"==typeof SuppressedError&&SuppressedError;var t=0,r=0,o=function(){var e=(new Date).getTime();return r===e?t+=1:(r=e,t=0),(1e3*e+t)/1e3},i=function(){return"undefined"==typeof window&&"undefined"!=typeof global},u=function(){if(i())return!1;var e=window.navigator.userAgent;return/Android|webOS|iPhone|iPad|iPod|Windows Phone|BlackBerry|IEMobile|Opera Mini/i.test(e)},a=function(e){return e.replace(/\D/g,"")};exports.abRandom=function(){return Math.random()<.5?0:1},exports.asyncNoop=function(){return e(void 0,void 0,void 0,(function(){return n(this,(function(e){return[2]}))}))},exports.extractNumber=a,exports.formatPhoneNumber=function(e){var n=a(e),t=n.startsWith("02");return 8===n.length?n.replace(/(\d{4})(\d{4})/,"$1-$2"):!t||9!==n.length&&10!==n.length?n.replace(/(\d{3})(\d{3,4})(\d{4})/,"$1-$2-$3"):n.replace(/(\d{2})(\d{3,4})(\d{4})/,"$1-$2-$3")},exports.getOS=function(){return i()?"server":window.navigator.userAgent.match(/ipad|iphone|ipod/i)?"ios":!!window.navigator.userAgent.match(/Android/i)?"android":u()?"otherMobile":"web"},exports.getUniqId=function(){return(1e3*o()).toString(16)},exports.getUniqTime=o,exports.getViewportSize=function(){return i()?{width:0,height:0}:{width:window.innerWidth,height:window.innerHeight}},exports.isClient=function(){return!i()},exports.isMobile=u,exports.isServer=i,exports.noop=function(){}; |
export * from './common'; | ||
export * from './device'; | ||
export * from './format'; |
@@ -1,1 +0,1 @@ | ||
var n=function(){return Math.random()<.5?0:1};function e(n,e,t,r){return new(t||(t=Promise))((function(o,i){function u(n){try{c(r.next(n))}catch(n){i(n)}}function a(n){try{c(r.throw(n))}catch(n){i(n)}}function c(n){var e;n.done?o(n.value):(e=n.value,e instanceof t?e:new t((function(n){n(e)}))).then(u,a)}c((r=r.apply(n,e||[])).next())}))}function t(n,e){var t,r,o,i,u={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(c){return function(a){if(t)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(u=0)),u;)try{if(t=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return u.label++,{value:a[1],done:!1};case 5:u.label++,r=a[1],a=[0];continue;case 7:a=u.ops.pop(),u.trys.pop();continue;default:if(!(o=u.trys,(o=o.length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){u=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){u.label=a[1];break}if(6===a[0]&&u.label<o[1]){u.label=o[1],o=a;break}if(o&&u.label<o[2]){u.label=o[2],u.ops.push(a);break}o[2]&&u.ops.pop(),u.trys.pop();continue}a=e.call(n,u)}catch(n){a=[6,n],r=0}finally{t=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}}"function"==typeof SuppressedError&&SuppressedError;var r=function(){return e(void 0,void 0,void 0,(function(){return t(this,(function(n){return[2]}))}))},o=0,i=0,u=function(){var n=(new Date).getTime();return i===n?o+=1:(i=n,o=0),(1e3*n+o)/1e3},a=function(){return(1e3*u()).toString(16)},c=function(){return"undefined"==typeof window&&"undefined"!=typeof global},f=function(){return c()?{width:0,height:0}:{width:window.innerWidth,height:window.innerHeight}},l=function(){},d=function(){if(c())return!1;var n=window.navigator.userAgent;return/Android|webOS|iPhone|iPad|iPod|Windows Phone|BlackBerry|IEMobile|Opera Mini/i.test(n)},s=function(){return c()?"server":window.navigator.userAgent.match(/ipad|iphone|ipod/i)?"ios":!!window.navigator.userAgent.match(/Android/i)?"android":d()?"otherMobile":"web"},h=function(){return!c()};export{n as abRandom,r as asyncNoop,s as getOS,a as getUniqId,u as getUniqTime,f as getViewportSize,h as isClient,d as isMobile,c as isServer,l as noop}; | ||
var n=function(){return Math.random()<.5?0:1};function e(n,e,t,r){return new(t||(t=Promise))((function(i,o){function u(n){try{c(r.next(n))}catch(n){o(n)}}function a(n){try{c(r.throw(n))}catch(n){o(n)}}function c(n){var e;n.done?i(n.value):(e=n.value,e instanceof t?e:new t((function(n){n(e)}))).then(u,a)}c((r=r.apply(n,e||[])).next())}))}function t(n,e){var t,r,i,o,u={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(a){return function(c){return function(a){if(t)throw new TypeError("Generator is already executing.");for(;o&&(o=0,a[0]&&(u=0)),u;)try{if(t=1,r&&(i=2&a[0]?r.return:a[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,a[1])).done)return i;switch(r=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=a;break;case 4:return u.label++,{value:a[1],done:!1};case 5:u.label++,r=a[1],a=[0];continue;case 7:a=u.ops.pop(),u.trys.pop();continue;default:if(!(i=u.trys,(i=i.length>0&&i[i.length-1])||6!==a[0]&&2!==a[0])){u=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]<i[3])){u.label=a[1];break}if(6===a[0]&&u.label<i[1]){u.label=i[1],i=a;break}if(i&&u.label<i[2]){u.label=i[2],u.ops.push(a);break}i[2]&&u.ops.pop(),u.trys.pop();continue}a=e.call(n,u)}catch(n){a=[6,n],r=0}finally{t=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}}"function"==typeof SuppressedError&&SuppressedError;var r=function(){return e(void 0,void 0,void 0,(function(){return t(this,(function(n){return[2]}))}))},i=0,o=0,u=function(){var n=(new Date).getTime();return o===n?i+=1:(o=n,i=0),(1e3*n+i)/1e3},a=function(){return(1e3*u()).toString(16)},c=function(){return"undefined"==typeof window&&"undefined"!=typeof global},l=function(){return c()?{width:0,height:0}:{width:window.innerWidth,height:window.innerHeight}},f=function(){},d=function(){if(c())return!1;var n=window.navigator.userAgent;return/Android|webOS|iPhone|iPad|iPod|Windows Phone|BlackBerry|IEMobile|Opera Mini/i.test(n)},h=function(){return c()?"server":window.navigator.userAgent.match(/ipad|iphone|ipod/i)?"ios":!!window.navigator.userAgent.match(/Android/i)?"android":d()?"otherMobile":"web"},s=function(){return!c()},p=function(n){return n.replace(/\D/g,"")},w=function(n){var e=p(n),t=e.startsWith("02");return 8===e.length?e.replace(/(\d{4})(\d{4})/,"$1-$2"):!t||9!==e.length&&10!==e.length?e.replace(/(\d{3})(\d{3,4})(\d{4})/,"$1-$2-$3"):e.replace(/(\d{2})(\d{3,4})(\d{4})/,"$1-$2-$3")};export{n as abRandom,r as asyncNoop,p as extractNumber,w as formatPhoneNumber,h as getOS,a as getUniqId,u as getUniqTime,l as getViewportSize,s as isClient,d as isMobile,c as isServer,f as noop}; |
{ | ||
"name": "@devgrace/utils", | ||
"sideEffects": false, | ||
"version": "0.1.2", | ||
"version": "0.1.3", | ||
"description": "devgrace/utils", | ||
@@ -45,3 +45,3 @@ "main": "dist/cjs/index.js", | ||
], | ||
"gitHead": "41b23d13b01240e99f7c3b40d10b4e99bf429c22" | ||
"gitHead": "d4e726447082af316cf2c1f7f6dce5a8f23d50db" | ||
} |
10313
39
84