Socket
Socket
Sign inDemoInstall

shaye-sword

Package Overview
Dependencies
5
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.5 to 1.0.10

es/functional.js

63

es/objTool.js

@@ -1,65 +0,4 @@

import 'core-js/modules/es6.regexp.to-string';
import { isCorrect } from './variables.js';
/**
* @namespace variables
*/
/**
* 判断变量是否是object
* @memberOf variables
* @function isObject
* @param {*} obj
*/
function isObject(obj) {
return Object.prototype.toString.call(obj) === "[object Object]";
}
/**
* 判断object是否是空的
* @memberOf variables
* @function isEmptyObject
* @param {object} obj
*/
function isEmptyObject(obj) {
for (var key in obj) {
return false;
}
return true;
}
/**
* 检验变量是否有正确的值
* @memberOf variables
* @function isCorrect
* @param {*} variable - 被检验的变量
* @param {boolean} [notBezero=false] - 是否不允许变量等于零
*/
function isCorrect(variable, notBezero) {
var result = true;
if (typeof variable === "string" && (variable === "" || variable === "undefined" || variable === "null" || variable === "NaN" || variable === "Infinity")) {
result = false;
} else if (typeof variable === "number" && (isNaN(variable) || !isFinite(variable) || notBezero && variable === 0)) {
result = false;
} else if (variable === null) {
result = false;
} else if (typeof variable === "undefined") {
result = false;
} else if (isObject(variable)) {
if (isEmptyObject(variable)) {
result = false;
}
} else if (Array.isArray(variable)) {
if (variable.length === 0) {
result = false;
}
}
return result;
}
/**
* @namespace objTool

@@ -66,0 +5,0 @@ */

import 'core-js/modules/web.dom.iterable';
import 'core-js/modules/es6.regexp.split';
import 'core-js/modules/es6.regexp.to-string';
import { isCorrect } from './variables.js';
/**
* @namespace variables
*/
/**
* 判断变量是否是object
* @memberOf variables
* @function isObject
* @param {*} obj
*/
function isObject(obj) {
return Object.prototype.toString.call(obj) === "[object Object]";
}
/**
* 判断object是否是空的
* @memberOf variables
* @function isEmptyObject
* @param {object} obj
*/
function isEmptyObject(obj) {
for (var key in obj) {
return false;
}
return true;
}
/**
* 检验变量是否有正确的值
* @memberOf variables
* @function isCorrect
* @param {*} variable - 被检验的变量
* @param {boolean} [notBezero=false] - 是否不允许变量等于零
*/
function isCorrect(variable, notBezero) {
var result = true;
if (typeof variable === "string" && (variable === "" || variable === "undefined" || variable === "null" || variable === "NaN" || variable === "Infinity")) {
result = false;
} else if (typeof variable === "number" && (isNaN(variable) || !isFinite(variable) || notBezero && variable === 0)) {
result = false;
} else if (variable === null) {
result = false;
} else if (typeof variable === "undefined") {
result = false;
} else if (isObject(variable)) {
if (isEmptyObject(variable)) {
result = false;
}
} else if (Array.isArray(variable)) {
if (variable.length === 0) {
result = false;
}
}
return result;
}
/**
* 把URL查询参数转换为object

@@ -68,0 +7,0 @@ * @memberOf strTool

{
"name": "shaye-sword",
"version": "1.0.5",
"version": "1.0.10",
"description": "a javascript tool library",
"module": "es.js",
"module": "es/index.js",
"main": "lib/index.js",
"scripts": {

@@ -7,0 +8,0 @@ "build": "rollup -c ./build/rollup.config.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc