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

@beisen-platform/common-func

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@beisen-platform/common-func - npm Package Compare versions

Comparing version 1.0.0 to 1.0.2

152

lib/index.js

@@ -1,38 +0,12 @@

"use strict";
import "core-js/modules/es6.regexp.match";
import "core-js/modules/es6.regexp.replace";
import _typeof from "@babel/runtime/helpers/typeof";
import "core-js/modules/es6.regexp.to-string";
import "core-js/modules/es6.object.to-string";
import "core-js/modules/es6.number.constructor";
import "core-js/modules/es6.regexp.split";
import "core-js/modules/es6.regexp.constructor";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.clearToolTipDom = clearToolTipDom;
exports.uid = uid;
exports.judgeBrowser = judgeBrowser;
exports.judgeSys = judgeSys;
exports.contains = contains;
exports.createDom = createDom;
exports.getHeightLight = getHeightLight;
exports.deepClone = deepClone;
exports.transferData = transferData;
exports.encode = encode;
exports.decode = decode;
exports.removeResizeListener = exports.addResizeListener = void 0;
require("core-js/modules/es6.regexp.replace");
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
require("core-js/modules/es6.regexp.to-string");
require("core-js/modules/es6.number.constructor");
require("core-js/modules/es6.regexp.split");
require("core-js/modules/web.dom.iterable");
require("core-js/modules/es6.regexp.constructor");
var _react = _interopRequireDefault(require("react"));
function clearToolTipDom() {
/* eslint-disable */
export function clearToolTipDom() {
var dom_1 = document.getElementsByClassName('tooltip')[0];

@@ -43,13 +17,16 @@ var dom_2 = document.getElementsByClassName('tooltip-arrow')[0];

var parNode = dom_1.parentNode;
parNode.removeChild(dom_1);
parNode.removeChild(dom_2);
if (parNode.parentNode && parNode.parentNode.className == 'tooltip__hidden') {
parNode.parentNode.removeChild(parNode);
} else {
parNode.removeChild(dom_1);
parNode.removeChild(dom_2);
}
}
}
function uid(flag) {
export function uid(flag) {
var now = +new Date();
return flag + "-".concat(now);
}
function judgeBrowser() {
export function judgeBrowser() {
var userAgent = navigator.userAgent;

@@ -81,4 +58,3 @@ var reIE = new RegExp("MSIE (\\d+\\.\\d+);");

}
function judgeSys() {
export function judgeSys() {
var userAgent = navigator.userAgent;

@@ -103,4 +79,3 @@ var browser = {

function contains(root, n) {
export function contains(root, n) {
var node = n;

@@ -146,3 +121,2 @@

var isServer = typeof window === 'undefined';

@@ -272,3 +246,3 @@ /* istanbul ignore next */

var addResizeListener = function addResizeListener(element, fn) {
export var addResizeListener = function addResizeListener(element, fn) {
if (isServer) return;

@@ -309,6 +283,3 @@

exports.addResizeListener = addResizeListener;
var removeResizeListener = function removeResizeListener(element, fn) {
export var removeResizeListener = function removeResizeListener(element, fn) {
if (attachEvent) {

@@ -326,6 +297,3 @@ element.detachEvent('onresize', fn);

exports.removeResizeListener = removeResizeListener;
function createDom(id) {
export function createDom(id) {
if (document.getElementById(id)) return;

@@ -336,6 +304,5 @@ var oDiv = document.createElement('div');

}
export function getHeightLight(searchval, text) {
var str = {};
function getHeightLight(searchval, text) {
var str = [];
if (searchval.length > 0) {

@@ -349,3 +316,3 @@ //获取搜索字符在字段中的位置,分两种 1.首位(index==0) 2.非首位

var subValue = text.substring(index, valueLength);
str.searchContent = _react.default.createElement("em", null, subValue);
str.searchContent = React.createElement("em", null, subValue);
str.lastext = text.substring(valueLength, text.length);

@@ -357,4 +324,8 @@ } else if (index > 0) {

str.searchContent = _react.default.createElement("em", null, _subValue);
str.searchContent = React.createElement("em", null, _subValue);
str.lastext = text.substring(valueLength + index, text.length);
} else {
str.beforeText = '';
str.searchContent = React.createElement("em", null);
str.lastext = '';
}

@@ -369,4 +340,3 @@ } else {

}
function deepClone(item) {
export function deepClone(item) {
if (!item) return item;

@@ -387,3 +357,3 @@ var types = [Number, String, Boolean],

});
} else if ((0, _typeof2.default)(item) == "object") {
} else if (_typeof(item) == "object") {
if (item.nodeType && typeof item.cloneNode == "function") {

@@ -411,4 +381,3 @@ result = item.cloneNode(true);

}
function transferData(data) {
export function transferData(data) {
var filter = [],

@@ -438,4 +407,3 @@ getData = {},

}
function encode(str) {
export function encode(str) {
if (!str || typeof str != 'string') {

@@ -448,4 +416,3 @@ return str;

}
function decode(str) {
export function decode(str) {
if (!str || typeof str != 'string') {

@@ -457,2 +424,45 @@ return str;

return str.replace(/&quot;/g, '"').replace(/&#39;/g, "'").replace(/&lt;/g, '<').replace(/&gt;/g, '>').replace(/&amp;/g, '&');
}
}
/**
* 将字符串模板中的占位符替换为相应的变量
* @param {String} template 字符串模板, 变量key只能为数字
* @param {...any} variables 对应的变量
* 示例:(括号中的序号与翻译参数的顺序有关)
* console.log(transFormat("{0} is {1}", 1, 2));
* console.log(transFormat("{1} is {0}", 1, 2));
*/
export function transFormat(template) {
for (var _len = arguments.length, variables = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
variables[_key - 1] = arguments[_key];
}
var bKeys = template.match(/{\s*[0-9]+\s*}/g);
if (bKeys) {
// 当匹配到对应格式时, 返回变量替换之后的字符串
return bKeys.map(function (str) {
return str.slice(1, str.length - 1).trim();
}) // 获取相对应的序号
.reduce(function (template, key) {
return template.replace(/{\s*[0-9]+\s*}/, variables[key]);
}, template); // 替换相应变量
} else {
// 当未匹配到相应的格式时,将变量直接拼接在模板字符串前端(此为兼容方案, 请保证所有的输入的都符合对应格式)
return variables.join(' ') + template;
}
}
export default {
clearToolTipDom: clearToolTipDom,
uid: uid,
judgeBrowser: judgeBrowser,
judgeSys: judgeSys,
contains: contains,
createDom: createDom,
getHeightLight: getHeightLight,
deepClone: deepClone,
transferData: transferData,
encode: encode,
decode: decode,
transFormat: transFormat
};
{
"name": "@beisen-platform/common-func",
"version": "1.0.0",
"version": "1.0.2",
"description": "CommonFunc",

@@ -5,0 +5,0 @@ "main": "lib/index.js",

Sorry, the diff of this file is not supported yet

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