
JS工具类~

Online
点击这里带你穿越
更新日志
1.0.13
新增 zoom(容器宽, 容器高, 目标宽, 目标高, 追加值) : [宽, 高]
zoom(100, 200, 200, 300);
zoom("100px", 200, 200, 300, "px");
优化 runer(Number, Array)
runer("-1", [1, 2]);
runer(-1, [1, 2]);
1.0.12
优化 runer(Function|String, ...args) and isFunction(func);
const aSimplyFunction = function (a) {
return a;
};
aSimplyFunction instanceof Function;
aSimplyFunction.__proto__ = {};
aSimplyFunction instanceof Function;
isFunction(aSimplyFunction);
runer(aSimplyFunction, null, 1);
1.0.11
优化 runer(String, null|undefined)
runer("push", null);
runer("pop", undefined);
runer("toFixed", 0, 1);
1.0.10
优化 isEmpty(HTMLHtmlElement) 对象判断
1.0.8
优化 runer(String, context)
runer("push", [1, 2, 3, 4], 0);
runer("pop", [1, 2, 3, 4]);
1.0.7
优化 Map、Set 在使用 each 时的中断逻辑
let ret,
map = new Map();
map.set(10, 20);
map.set("a", 2);
ret = each(map, (k, v) => {
if (v == 2) return k;
});
Between
const soei = require("@soei/tools");
let Between = soei.Between;
import { Between } from "@soei/tools";
data = new Between({
max: 90,
min: 20,
});
data.fire(20.01);
data.fire(2);
data.fire(2, true );
data = new Between({
decimal: 3,
max: 1,
min: 0,
});
data.fire(20);
data.fire("0.0");
data.fire("0.0", true);
data.fire(0.0, true);
merge
const soei = require("@soei/tools");
let merge = soei.merge;
import { merge } from "@soei/tools";
merge(args1, args2[,..., true, "mix"])
merge(args1, args2)
let a = { name: "Joy" };
let b = { name: "Band", age: 10 };
merge(a, b);
merge(args1, args2, args3, true)
let a = { name: "Joy" };
let b = { name: "Band", age: 10 };
let c = { name: "Juerry" };
merge(a, b, c, true);
merge(args1, args2, args3)
let a = { name: "Joy" };
let b = { name: "Band", age: 10 };
merge(a, b, {
age: 11,
});
merge(args1, args2[,...], "mix")
let a = { name: "Joy" };
let b = { name: "Band" };
let c = { name: "Juerry", age: 10 };
merge(a, b, c, "mix");
merge(args1, args2[,...], true, "mix")
let a = { name: "Joy" };
let b = { name: "Band" };
let c = { name: "Juerry", age: 11 };
merge(a, b, c, true, "mix");
each
const soei = require("@soei/tools");
let each = soei.each;
import { each } from "@soei/tools";
each({ a: 1, b: 2 }, (k, v) => {
console.log(k, v);
});
each([1, 2], (k, v) => {
console.log(k, v);
});
each(
[1, 2],
(k, v, target ) => {
console.log(target);
},
{
1: 2,
2: 3,
}
);
runer
const soei = require("@soei/tools");
let runer = soei.runer;
import { runer } from "@soei/tools";
runer(
function (a, z) {
return `this is ${this.name} ${a} ${z}`;
},
{
name: "loop",
},
1,
2
);
iList2Array
const soei = require("@soei/tools");
let iList2Array = soei.iList2Array;
import { iList2Array } from "@soei/tools";
let array = iList2Array(arguments);
iSplit
const soei = require("@soei/tools");
let iSplit = soei.iSplit;
import { iSplit } from "@soei/tools";
let array = iSplit("name|age;weight");
let array = iSplit("name,age", ",");
isFunction
isNil
isSimplyType
isArray
isString
isNodeList