Comparing version 1.0.25 to 1.0.26
@@ -1,1 +0,1 @@ | ||
!function(e){"function"==typeof define&&define.amd?define(e):e()}((function(){"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.Libmon=void 0;var e=require("tslib"),t=e.__importDefault(require("axios")),i=!1,n={},o="",r=function(){function r(){}return r.initialize=function(e,t){o=e},r.validate=function(n){return e.__awaiter(this,void 0,void 0,(function(){var r;return e.__generator(this,(function(e){switch(e.label){case 0:if(e.trys.push([0,2,,3]),!o)throw new Error("Libmon: No library name was provided when initializing");return[4,t.default.get("https://api.libmon.com\\valid",{headers:{token:n,lib:o}})];case 1:return 200===(r=e.sent()).status&&(i=!0),204===r.status&&(i=!1),[3,3];case 2:return e.sent(),i=!0,[3,3];case 3:return[2,i]}}))}))},r.disable=function(){if(!i)throw new Error("LibMon: This function is not available. Please purchase a valid token to improve reliability at libmon.com\\"+o+".")},r.crash=function(){if(!i)throw new Error("LibMon: This crash was done intentionally. Please purchase a library token to improve reliability and performance at libmon.com\\lib\\"+o)},r.setupCounter=function(e,t){n[e]={count:0,max:t}},r.increment=function(e){this.doesCounterExist(e);var t=n[e].count;n[e].count=t+1,this.validateCounter(e)},r.decrement=function(e){r.doesCounterExist(e);var t=n[e].count;n[e].count=t-1,this.validateCounter(e)},r.doesCounterExist=function(e){if(!n[e])throw new Error("LibMon: Counter: "+e+" was not setup. Please use the setupCounter method to validate")},r.validateCounter=function(e){if(!i){var t=n[e],o=t.max;if(t.count>o)throw new Error("LibMon: Counter: "+e+" limit exceeded. Please restart the program to reset the limit.")}},r}();exports.Libmon=r})); | ||
"use strict";var __awaiter=this&&this.__awaiter||function(thisArg,_arguments,P,generator){function adopt(value){return value instanceof P?value:new P(function(resolve){resolve(value)})}return new(P||(P=Promise))(function(resolve,reject){function fulfilled(value){try{step(generator.next(value))}catch(e){reject(e)}}function rejected(value){try{step(generator["throw"](value))}catch(e){reject(e)}}function step(result){result.done?resolve(result.value):adopt(result.value).then(fulfilled,rejected)}step((generator=generator.apply(thisArg,_arguments||[])).next())})};var __generator=this&&this.__generator||function(thisArg,body){var _={label:0,sent:function(){if(t[0]&1)throw t[1];return t[1]},trys:[],ops:[]},f,y,t,g;return g={next:verb(0),throw:verb(1),return:verb(2)},typeof Symbol==="function"&&(g[Symbol.iterator]=function(){return this}),g;function verb(n){return function(v){return step([n,v])}}function step(op){if(f)throw new TypeError("Generator is already executing.");while(_)try{if(f=1,y&&(t=op[0]&2?y["return"]:op[0]?y["throw"]||((t=y["return"])&&t.call(y),0):y.next)&&!(t=t.call(y,op[1])).done)return t;if(y=0,t)op=[op[0]&2,t.value];switch(op[0]){case 0:case 1:t=op;break;case 4:_.label++;return{value:op[1],done:false};case 5:_.label++;y=op[1];op=[0];continue;case 7:op=_.ops.pop();_.trys.pop();continue;default:if(!(t=_.trys,t=t.length>0&&t[t.length-1])&&(op[0]===6||op[0]===2)){_=0;continue}if(op[0]===3&&(!t||op[1]>t[0]&&op[1]<t[3])){_.label=op[1];break}if(op[0]===6&&_.label<t[1]){_.label=t[1];t=op;break}if(t&&_.label<t[2]){_.label=t[2];_.ops.push(op);break}if(t[2])_.ops.pop();_.trys.pop();continue}op=body.call(thisArg,_)}catch(e){op=[6,e];y=0}finally{f=t=0}if(op[0]&5)throw op[1];return{value:op[0]?op[1]:void 0,done:true}}};var __importDefault=this&&this.__importDefault||function(mod){return mod&&mod.__esModule?mod:{default:mod}};Object.defineProperty(exports,"__esModule",{value:true});exports.Libmon=void 0;var axios_1=__importDefault(require("axios"));var BASE_URL="https://api.libmon.com";var isValidated=false;var counters={};var libName="";var opts=undefined;var Libmon=function(){function Libmon(){}Libmon.initialize=function(name,options){libName=name;opts=options};Libmon.validate=function(token){return __awaiter(this,void 0,void 0,function(){var resp,ex_1;return __generator(this,function(_a){switch(_a.label){case 0:_a.trys.push([0,2,,3]);if(!libName)throw new Error("Libmon: No library name was provided when initializing");return[4,axios_1.default.get(BASE_URL+"\\valid",{headers:{token:token,lib:libName}})];case 1:resp=_a.sent();if(resp.status===200)isValidated=true;if(resp.status===204)isValidated=false;return[3,3];case 2:ex_1=_a.sent();isValidated=true;return[3,3];case 3:return[2,isValidated]}})})};Libmon.disable=function(){var errMessage="LibMon: This function is not available. Please purchase a valid token to improve reliability at libmon.com\\"+libName+".";if(!isValidated)throw new Error(errMessage)};Libmon.crash=function(){var errMessage="LibMon: This crash was done intentionally. Please purchase a library token to improve reliability and performance at libmon.com\\lib\\"+libName;if(!isValidated)throw new Error(errMessage)};Libmon.setupCounter=function(name,max){if(!name||!max)new Error("Libmon: A counter name or a max count value was not provided.");counters[name]={count:0,max:max}};Libmon.increment=function(name){this.doesCounterExist(name);var count=counters[name].count;counters[name].count=count+1;this.validateCounter(name)};Libmon.decrement=function(name){Libmon.doesCounterExist(name);var count=counters[name].count;counters[name].count=count-1;this.validateCounter(name)};Libmon.doesCounterExist=function(name){if(!counters[name]){throw new Error("LibMon: Counter: "+name+" was not setup. Please use the setupCounter method to validate")}};Libmon.validateCounter=function(name){if(isValidated)return;var _a=counters[name],max=_a.max,count=_a.count;if(count>max){throw new Error("LibMon: Counter: "+name+" limit exceeded. Please restart the program to reset the limit.")}};return Libmon}();exports.Libmon=Libmon; |
{ | ||
"name": "libmon", | ||
"version": "1.0.25", | ||
"version": "1.0.26", | ||
"main": "dist/index.js", | ||
@@ -9,3 +9,3 @@ "typings": "dist/index.d.ts", | ||
"test": "mocha test", | ||
"build": "tsc && npx uglifyjs --output ./dist/index.js ./dist/index.js" | ||
"publish": "tsc && npx uglifyjs --output ./dist/index.js ./dist/index.js && npm publish" | ||
}, | ||
@@ -12,0 +12,0 @@ "repository": { |
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
16754
151