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

@festardoctor/utils-util

Package Overview
Dependencies
Maintainers
3
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@festardoctor/utils-util

基础工具组件.;

  • 0.0.2
  • latest
  • npm
  • Socket score

Version published
Maintainers
3
Created
Source

Modules

@festardoctor/utils-util/Base64Utils

Base64操作模块

@festardoctor/utils-util/LoadScript
@festardoctor/utils-util/NumUtils

数字操作工具模块

@festardoctor/utils-util/ObjUtils

数据操作工具模块

@festardoctor/utils-util/UrlUtils

URL操作工具模块

@festardoctor/utils-util/Base64Utils

Base64操作模块

base64Decode(str) ⇒ String

Base64解码

Kind: Exported function

ParamType
strString

Example

Base64Utils.base64Decode("Uy5ILkkuRS5MLkQ=") === 'S.H.I.E.L.D'

@festardoctor/utils-util/LoadScript

loadScript(opts, callback) ⏏

动态加载外部JS脚本

Kind: Exported function

ParamType
optsObject
callbackfunction

@festardoctor/utils-util/NumUtils

数字操作工具模块

num2str(num) ⇒ String

数字转成字符串

Kind: Exported function

ParamType
numNumber

Example

NumUtil.num2str(654.560) === '654.56'

fillNumber(number, len, char) ⏏

字符串首部占位填充

Kind: Exported function

ParamTypeDefaultDescription
numberNumber要填充的字符串
lenNumber2填充后的长度
charString0占位的字符,默认为'0'

Example

NumUtil.fillNumber(34,3)==='034'
NumUtil.fillNumber(34,3,'@')==='@34'

@festardoctor/utils-util/ObjUtils

数据操作工具模块

ObjUtils.extend(destination) ⏏

对象合并,建议用Object.assign来替代

Kind: Exported function

ParamType
destinationObject

ObjUtils.isEmptyObject(obj) ⇒ Boolean

判断给定的对象是否为空对象

Kind: Exported function

ParamTypeDescription
objObject给定的对象

@festardoctor/utils-util/UrlUtils

URL操作工具模块

parseUrl(url) ⇒ Object

解析URL

Kind: Exported function Returns: Object - 解析后返回的对象, {"loc": loc,"params": params, "append": append}

ParamTypeDescription
urlString需要解析的url

Example

const url = 'https://m.meitun.com/pdetails.html?mtoapp=0&mtomeitun=302&sid=18405&pid=08010200640101&promotionId=18405&promotionType=1&topicType=1&url=//m.meitun.com/h5/group/group.html&index=1&referer_url=joingroup&referer_code=joingroupHot'
UrlUtils.parseUrl(url)
//return {'loc':'https://m.meitun.com/pdetails.html',params:{mtoapp:'0',mtomeitun:'302',sid:'18405',pid:'08010200640101',promotionId:'18405','promotionType':'1','topicType':'1',url:'//m.meitun.com/h5/group/group.html',index:'1',referer_url:'joingroup',referer_code:'joingroupHot'},append:{}}

getParams(url) ⇒ Object

获取URL的qs

Kind: Exported function Returns: Object - 返回qs

ParamType
urlString

Example

const url = 'https://m.meitun.com/pdetails.html?mtoapp=0&mtomeitun=302&sid=18405&pid=08010200640101&promotionId=18405&promotionType=1&topicType=1&url=//m.meitun.com/h5/group/group.html&index=1&referer_url=joingroup&referer_code=joingroupHot'
UrlUtils.getParams(url)
//return {mtoapp:'0',mtomeitun:'302',sid:'18405',pid:'08010200640101',promotionId:'18405','promotionType':'1','topicType':'1',url:'//m.meitun.com/h5/group/group.html',index:'1',referer_url:'joingroup',referer_code:'joingroupHot'}

toCusString(obj) ⏏

组装URL

Kind: Exported function

ParamTypeDescription
objObject类型{"loc": loc,"params": params, "append": append}

Example

let obj = {loc: "https://m.meitun.com/pdetails.html",params: {a: 1, b: 2},append: "#aaa"}
let url = UrlUtils.toCusString(obj);
//return 'https://m.meitun.com/pdetails.html?a=1&b=2#aaa'

appendParams(url, obj) ⏏

往给定url上追加参数

Kind: Exported function

ParamTypeDescription
urlString给定的url
objObject需要追加的参数键值对

Example

let url = 'https://m.meitun.com/pdetails.html?a=1&b=2#aaa';
UrlUtils.appendParams(url, {a: 1})
//return 'https://m.meitun.com/pdetails.html?a=1&b=2#aaa'

hasParam(url) ⏏

判断给定的URL是否带有query string

Kind: Exported function

ParamTypeDescription
urlString给定的url

getUrlParamByName(name) ⇒ *

查询location.href的queryString

Kind: Exported function Returns: * - 返回url 查询参数值 没有则返回null

ParamDescription
nameurl 查询参数名

appendHref(href, key, value) ⏏

给指定的href增加参数

Kind: Exported function

ParamTypeDescription
hrefString指定的href
keyString需要增加的参数名称
valueNumber | String | Array需要增加的参数值

Example

let url = 'https://m.meitun.com/pdetails.html?a=1&b=2#aaa';
UrlUtils.appendHref(url, a,1)
//return 'https://m.meitun.com/pdetails.html?a=1&b=2#aaa'

FAQs

Package last updated on 14 Jan 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

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