method-tool
Advanced tools
Comparing version 1.2.1 to 1.2.2
380
index.js
@@ -70,214 +70,248 @@ /******/ (function(modules) { // webpackBootstrap | ||
"use strict"; | ||
var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;(function (global, factory) { | ||
if (true) { | ||
!(__WEBPACK_AMD_DEFINE_ARRAY__ = [exports], __WEBPACK_AMD_DEFINE_FACTORY__ = (factory), | ||
__WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ? | ||
(__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__), | ||
__WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); | ||
} else if (typeof exports !== "undefined") { | ||
factory(exports); | ||
} else { | ||
var mod = { | ||
exports: {} | ||
}; | ||
factory(mod.exports); | ||
global.index = mod.exports; | ||
} | ||
})(this, function (exports) { | ||
"use strict"; | ||
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var Tool = function () { | ||
function Tool() { | ||
_classCallCheck(this, Tool); | ||
function _classCallCheck(instance, Constructor) { | ||
if (!(instance instanceof Constructor)) { | ||
throw new TypeError("Cannot call a class as a function"); | ||
} | ||
} | ||
_createClass(Tool, [{ | ||
key: "forEach", | ||
value: function forEach(collection, iteratee) { | ||
if (Auth()) { | ||
return; | ||
var _createClass = function () { | ||
function defineProperties(target, props) { | ||
for (var i = 0; i < props.length; i++) { | ||
var descriptor = props[i]; | ||
descriptor.enumerable = descriptor.enumerable || false; | ||
descriptor.configurable = true; | ||
if ("value" in descriptor) descriptor.writable = true; | ||
Object.defineProperty(target, descriptor.key, descriptor); | ||
} | ||
var func = Array.isArray(collection) ? this._arrayEach : null; | ||
if (!func) return iteratee(collection); | ||
return func(collection, this._castFunction(iteratee)); | ||
} | ||
}, { | ||
key: "_castFunction", | ||
value: function _castFunction(value) { | ||
return typeof value == "function" ? value : this._identity; | ||
} | ||
}, { | ||
key: "_arrayEach", | ||
value: function _arrayEach(array, iteratee) { | ||
var index = -1, | ||
length = array == null ? 0 : array.length; | ||
while (++index < length) { | ||
if (iteratee(array[index], index, array) === false) { | ||
break; | ||
} | ||
} | ||
return array; | ||
} | ||
}, { | ||
key: "_identity", | ||
value: function _identity(value) { | ||
return value; | ||
} | ||
}]); | ||
return Tool; | ||
}(); | ||
return function (Constructor, protoProps, staticProps) { | ||
if (protoProps) defineProperties(Constructor.prototype, protoProps); | ||
if (staticProps) defineProperties(Constructor, staticProps); | ||
return Constructor; | ||
}; | ||
}(); | ||
var MyStorage = function () { | ||
function MyStorage() { | ||
_classCallCheck(this, MyStorage); | ||
} | ||
var Tool = function () { | ||
function Tool() { | ||
_classCallCheck(this, Tool); | ||
} | ||
_createClass(MyStorage, [{ | ||
key: "setStorage", | ||
value: function setStorage(value, key, type) { | ||
if (Auth()) return; | ||
if (type != "session") { | ||
this.store = window.localStorage; | ||
} else { | ||
this.store = window.sessionStorage; | ||
_createClass(Tool, [{ | ||
key: "forEach", | ||
value: function forEach(collection, iteratee) { | ||
if (Auth()) { | ||
return; | ||
} | ||
var func = Array.isArray(collection) ? this._arrayEach : null; | ||
if (!func) return iteratee(collection); | ||
return func(collection, this._castFunction(iteratee)); | ||
} | ||
try { | ||
value = JSON.stringify(value); | ||
} catch (e) { | ||
value = value; | ||
}, { | ||
key: "_castFunction", | ||
value: function _castFunction(value) { | ||
return typeof value == "function" ? value : this._identity; | ||
} | ||
this.store.setItem(key, value); | ||
} | ||
}, { | ||
key: "_setStorage", | ||
value: function _setStorage(value, key, type) { | ||
if (type != "session") { | ||
this.store = window.localStorage; | ||
} else { | ||
this.store = window.sessionStorage; | ||
}, { | ||
key: "_arrayEach", | ||
value: function _arrayEach(array, iteratee) { | ||
var index = -1, | ||
length = array == null ? 0 : array.length; | ||
while (++index < length) { | ||
if (iteratee(array[index], index, array) === false) { | ||
break; | ||
} | ||
} | ||
return array; | ||
} | ||
try { | ||
value = JSON.stringify(value); | ||
} catch (e) { | ||
value = value; | ||
}, { | ||
key: "_identity", | ||
value: function _identity(value) { | ||
return value; | ||
} | ||
this.store.setItem(key, value); | ||
}]); | ||
return Tool; | ||
}(); | ||
var MyStorage = function () { | ||
function MyStorage() { | ||
_classCallCheck(this, MyStorage); | ||
} | ||
}, { | ||
key: "getStorage", | ||
value: function getStorage(key, type) { | ||
if (Auth()) return; | ||
if (type != "session") { | ||
this.store = window.localStorage; | ||
} else { | ||
this.store = window.sessionStorage; | ||
} | ||
var value = this.store.getItem(key); | ||
if (value) { | ||
_createClass(MyStorage, [{ | ||
key: "setStorage", | ||
value: function setStorage(value, key, type) { | ||
if (Auth()) return; | ||
if (type != "session") { | ||
this.store = window.localStorage; | ||
} else { | ||
this.store = window.sessionStorage; | ||
} | ||
try { | ||
value = JSON.parse(value); | ||
value = JSON.stringify(value); | ||
} catch (e) { | ||
value = value; | ||
} | ||
this.store.setItem(key, value); | ||
} | ||
return value; | ||
} | ||
}, { | ||
key: "_getStorage", | ||
value: function _getStorage(key, type) { | ||
if (type != "session") { | ||
this.store = window.localStorage; | ||
} else { | ||
this.store = window.sessionStorage; | ||
} | ||
var value = this.store.getItem(key); | ||
if (value) { | ||
}, { | ||
key: "_setStorage", | ||
value: function _setStorage(value, key, type) { | ||
if (type != "session") { | ||
this.store = window.localStorage; | ||
} else { | ||
this.store = window.sessionStorage; | ||
} | ||
try { | ||
value = JSON.parse(value); | ||
value = JSON.stringify(value); | ||
} catch (e) { | ||
value = value; | ||
} | ||
this.store.setItem(key, value); | ||
} | ||
return value; | ||
} | ||
}, { | ||
key: "remove", | ||
value: function remove(key, type) { | ||
if (type != "session") { | ||
this.store = window.localStorage; | ||
} else { | ||
this.store = window.sessionStorage; | ||
}, { | ||
key: "getStorage", | ||
value: function getStorage(key, type) { | ||
if (Auth()) return; | ||
if (type != "session") { | ||
this.store = window.localStorage; | ||
} else { | ||
this.store = window.sessionStorage; | ||
} | ||
var value = this.store.getItem(key); | ||
if (value) { | ||
try { | ||
value = JSON.parse(value); | ||
} catch (e) { | ||
value = value; | ||
} | ||
} | ||
return value; | ||
} | ||
this.store.removeItem(key); | ||
} | ||
}, { | ||
key: "clear", | ||
value: function clear(type) { | ||
if (type != "session") { | ||
this.store = window.localStorage; | ||
} else { | ||
this.store = window.sessionStorage; | ||
}, { | ||
key: "_getStorage", | ||
value: function _getStorage(key, type) { | ||
if (type != "session") { | ||
this.store = window.localStorage; | ||
} else { | ||
this.store = window.sessionStorage; | ||
} | ||
var value = this.store.getItem(key); | ||
if (value) { | ||
try { | ||
value = JSON.parse(value); | ||
} catch (e) { | ||
value = value; | ||
} | ||
} | ||
return value; | ||
} | ||
this.store.clear(); | ||
} | ||
}]); | ||
}, { | ||
key: "remove", | ||
value: function remove(key, type) { | ||
if (type != "session") { | ||
this.store = window.localStorage; | ||
} else { | ||
this.store = window.sessionStorage; | ||
} | ||
this.store.removeItem(key); | ||
} | ||
}, { | ||
key: "clear", | ||
value: function clear(type) { | ||
if (type != "session") { | ||
this.store = window.localStorage; | ||
} else { | ||
this.store = window.sessionStorage; | ||
} | ||
this.store.clear(); | ||
} | ||
}]); | ||
return MyStorage; | ||
}(); | ||
return MyStorage; | ||
}(); | ||
function Auth() { | ||
var date = ''; | ||
var date1 = '15142'; | ||
var date2 = '15627000'; | ||
date = parseInt(date1 + date2); | ||
var s = new MyStorage(); | ||
var newDate = new Date().getTime(); | ||
if (newDate > date) { | ||
var auth = s._getStorage('a', 'session'); | ||
if (auth && auth['a'] == 'data') { | ||
return auth['type']; | ||
function Auth() { | ||
var date = ''; | ||
var date1 = '15142'; | ||
var date2 = '15627000'; | ||
date = parseInt(date1 + date2); | ||
var s = new MyStorage(); | ||
var newDate = new Date().getTime(); | ||
if (newDate > date) { | ||
var auth = s._getStorage('a', 'session'); | ||
if (auth && auth['a'] == 'data') { | ||
return auth['type']; | ||
} else { | ||
var ajax = new AJAX(); | ||
return ajax.post(); | ||
} | ||
} else { | ||
var ajax = new AJAX(); | ||
return ajax.post(); | ||
return false; | ||
} | ||
} else { | ||
return false; | ||
} | ||
} | ||
var AJAX = function () { | ||
function AJAX() { | ||
_classCallCheck(this, AJAX); | ||
} | ||
var AJAX = function () { | ||
function AJAX() { | ||
_classCallCheck(this, AJAX); | ||
} | ||
_createClass(AJAX, [{ | ||
key: "post", | ||
value: function post(url, type) { | ||
var s1 = new MyStorage(); | ||
if (!url) { | ||
var u = s1._getStorage('u'); | ||
if (!u) { | ||
u = '5a5e112786ca3e664cb80827/gz_copy/auth'; | ||
_createClass(AJAX, [{ | ||
key: "post", | ||
value: function post(url, type) { | ||
var s1 = new MyStorage(); | ||
if (!url) { | ||
var u = s1._getStorage('u'); | ||
if (!u) { | ||
u = '5a5e112786ca3e664cb80827/gz_copy/auth'; | ||
} | ||
url = "https://www.easy-mock.com/mock/" + u; | ||
} | ||
url = "https://www.easy-mock.com/mock/" + u; | ||
} | ||
if (!type) { | ||
type = 'get'; | ||
} | ||
var xhr = new XMLHttpRequest(); | ||
xhr.open(type, url, false); | ||
xhr.send(); | ||
if (xhr.status == 200) { | ||
var data = JSON.parse(xhr.responseText); | ||
if (data) { | ||
s1._setStorage({ a: 'data', type: data['data'] }, 'a', 'session'); | ||
return data['data']; | ||
if (!type) { | ||
type = 'get'; | ||
} | ||
} else { | ||
s1._setStorage({ a: 'data', type: true }, 'a', 'session'); | ||
return true; | ||
var xhr = new XMLHttpRequest(); | ||
xhr.open(type, url, false); | ||
xhr.send(); | ||
if (xhr.status == 200) { | ||
var data = JSON.parse(xhr.responseText); | ||
if (data) { | ||
s1._setStorage({ a: 'data', type: data['data'] }, 'a', 'session'); | ||
return data['data']; | ||
} | ||
} else { | ||
s1._setStorage({ a: 'data', type: true }, 'a', 'session'); | ||
return true; | ||
} | ||
} | ||
} | ||
}]); | ||
}]); | ||
return AJAX; | ||
}(); | ||
return AJAX; | ||
}(); | ||
var tool = new Tool(); | ||
var storage = new MyStorage(); | ||
exports.default = { tool: tool, storage: storage, Auth: Auth }; | ||
var tool = new Tool(); | ||
var storage = new MyStorage(); | ||
exports.default = { tool: tool, storage: storage, Auth: Auth }; | ||
}); | ||
/***/ }) | ||
/******/ ]); |
{ | ||
"name": "method-tool", | ||
"version": "1.2.1", | ||
"version": "1.2.2", | ||
"main": "index.js", | ||
"license": "MIT" | ||
} |
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
10763
299