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

method-tool

Package Overview
Dependencies
Maintainers
1
Versions
45
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

method-tool - npm Package Compare versions

Comparing version 1.0.2 to 1.0.3

198

index.js
/*! 版权所有,翻版必究 */
!function(t){function e(n){if(o[n])return o[n].exports;var r=o[n]={i:n,l:!1,exports:{}};return t[n].call(r.exports,r,r.exports,e),r.l=!0,r.exports}var o={};e.m=t,e.c=o,e.d=function(t,o,n){e.o(t,o)||Object.defineProperty(t,o,{configurable:!1,enumerable:!0,get:n})},e.n=function(t){var o=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(o,"a",o),o},e.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},e.p="",e(e.s=0)}([function(t,e,o){"use strict";function n(){if((new Date).getTime()>1514215627e3)return(new s).post();return console.log("未到期"),!1}Object.defineProperty(e,"__esModule",{value:!0});var r=function(){function t(){}return t.prototype.forEach=function(t,e){if(n())return void console.error(!1);console.log(!0);var o=Array.isArray(t)?this._arrayEach:null;return o?o(t,this._castFunction(e)):e(t)},t.prototype._castFunction=function(t){return n()?null:"function"==typeof t?t:this._identity},t.prototype._arrayEach=function(t,e){if(n())return null;for(var o=-1,r=null==t?0:t.length;++o<r&&!1!==e(t[o],o,t););return t},t.prototype._identity=function(t){if(!n())return t},t}(),i=function(){function t(){}return t.prototype.setStorage=function(t,e,o){if(!n()){this.store="session"==o?window.localStorage:window.sessionStorage;try{t=JSON.stringify(t)}catch(e){t=t}this.store.setItem(e,t)}},t.prototype.getStorage=function(t,e){if(n())return null;this.store="session"==e?window.localStorage:window.sessionStorage;var o=this.store.getItem(t);if(o)try{o=JSON.parse(o)}catch(t){o=o}return o},t.prototype.remove=function(t,e){if(n())return null;this.store="session"==e?window.localStorage:window.sessionStorage,this.store.removeItem(t)},t.prototype.clear=function(t){if(n())return null;this.store="session"==t?window.localStorage:window.sessionStorage,this.store.clear()},t}(),s=function(){function t(){}return t.prototype.post=function(t,e){t||(t="https://www.easy-mock.com/mock/5a405dced632586e404e90bc/gz/auth"),e||(e="get");var o=new XMLHttpRequest;if(o.open(e,t,!1),o.send(),200!=o.status)return!0;var n=JSON.parse(o.responseText);return n?n.data:void 0},t}(),u=new r,c=new i;e.default={tool:u,storage:c,Auth:n}}]);
/******/ (function(modules) { // webpackBootstrap
/******/ // The module cache
/******/ var installedModules = {};
/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/
/******/ // Check if module is in cache
/******/ if(installedModules[moduleId]) {
/******/ return installedModules[moduleId].exports;
/******/ }
/******/ // Create a new module (and put it into the cache)
/******/ var module = installedModules[moduleId] = {
/******/ i: moduleId,
/******/ l: false,
/******/ exports: {}
/******/ };
/******/
/******/ // Execute the module function
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/
/******/ // Flag the module as loaded
/******/ module.l = true;
/******/
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/
/******/
/******/ // expose the modules object (__webpack_modules__)
/******/ __webpack_require__.m = modules;
/******/
/******/ // expose the module cache
/******/ __webpack_require__.c = installedModules;
/******/
/******/ // define getter function for harmony exports
/******/ __webpack_require__.d = function(exports, name, getter) {
/******/ if(!__webpack_require__.o(exports, name)) {
/******/ Object.defineProperty(exports, name, {
/******/ configurable: false,
/******/ enumerable: true,
/******/ get: getter
/******/ });
/******/ }
/******/ };
/******/
/******/ // getDefaultExport function for compatibility with non-harmony modules
/******/ __webpack_require__.n = function(module) {
/******/ var getter = module && module.__esModule ?
/******/ function getDefault() { return module['default']; } :
/******/ function getModuleExports() { return module; };
/******/ __webpack_require__.d(getter, 'a', getter);
/******/ return getter;
/******/ };
/******/
/******/ // Object.prototype.hasOwnProperty.call
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
/******/
/******/ // __webpack_public_path__
/******/ __webpack_require__.p = "";
/******/
/******/ // Load entry module and return exports
/******/ return __webpack_require__(__webpack_require__.s = 0);
/******/ })
/************************************************************************/
/******/ ([
/* 0 */
/***/ (function(module, exports) {
var Tool = function () {
function Tool() {}
Tool.prototype.forEach = function (collection, iteratee) {
if (Auth()) {
console.error(false);
return;
} else {
console.log(true);
}
;
var func = Array.isArray(collection) ? this._arrayEach : null;
if (!func) return iteratee(collection);
return func(collection, this._castFunction(iteratee));
};
Tool.prototype._castFunction = function (value) {
if (Auth()) return null;
return typeof value == "function" ? value : this._identity;
};
Tool.prototype._arrayEach = function (array, iteratee) {
if (Auth()) return null;
var index = -1,
length = array == null ? 0 : array.length;
while (++index < length) {
if (iteratee(array[index], index, array) === false) {
break;
}
}
return array;
};
Tool.prototype._identity = function (value) {
if (Auth()) return;
return value;
};
return Tool;
}();
var MyStorage = function () {
function MyStorage() {}
MyStorage.prototype.setStorage = function (value, key, type) {
if (Auth()) return;
if (type == "session") {
this.store = window.localStorage;
} else {
this.store = window.sessionStorage;
}
try {
value = JSON.stringify(value);
} catch (e) {
value = value;
}
this.store.setItem(key, value);
};
MyStorage.prototype.getStorage = function (key, type) {
if (Auth()) return null;
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;
};
MyStorage.prototype.remove = function (key, type) {
if (Auth()) return null;
if (type == "session") {
this.store = window.localStorage;
} else {
this.store = window.sessionStorage;
}
this.store.removeItem(key);
};
MyStorage.prototype.clear = function (type) {
if (Auth()) return null;
if (type == "session") {
this.store = window.localStorage;
} else {
this.store = window.sessionStorage;
}
this.store.clear();
};
return MyStorage;
}();
function Auth() {
var date = 1514215627000;
var newDate = new Date().getTime();
if (newDate > date) {
var ajax = new AJAX();
return ajax.post();
} else {
console.log('未到期');
return false;
}
}
var AJAX = function () {
function AJAX() {}
AJAX.prototype.post = function (url, type) {
if (!url) {
url = "https://www.easy-mock.com/mock/5a405dced632586e404e90bc/gz/auth";
}
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) {
return data['data'];
}
} else {
return true;
}
};
return AJAX;
}();
var tool = new Tool();
var storage = new MyStorage();
module.exports = { tool: tool, storage: storage, Auth: Auth };
/***/ })
/******/ ]);

2

package.json
{
"name": "method-tool",
"version": "1.0.2",
"version": "1.0.3",
"main": "index.js",
"license": "MIT"
}
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