New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

utils2js

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

utils2js

Common tool method encapsulation

  • 1.0.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

utils2js


npm install utils2js --save-dev

API

  1. prop

获取指定对象下指定字段的值,支持递归

举例:

  • prop({a: {b: 1}}, 'a.b') // 1
  • prop({a: {b: 1}}, 'a') // {b: 1}
  • prop({a: {b: 1}}, 'm') // null

  1. interpolation

自定义插值

适用于取到接口返回的JSON根据需要转换成指定格式的字符串

举例:

utils2js.interpolation('{0}{3}{1}{1}{2}', 'A', 'B', 'C', 'D') // ADBBC
utils2js.interpolation('{name} - {userID}', {name: 'test',userID: 1, age: 12}) // test - 1

  1. getRandomAssignNum

随机生成指定位数的16进制数

举例:

utils2js.getRandomAssignNum(6) // 6位数的随机十六进制数

  1. Logger

更简单多色彩的现代浏览器控制台输出显示

举例:

var test = utils2js.Logger('box1')
test.info('666')	// [box1] 666

  1. extend

重名默认覆盖

举例:

utils2js.extend({name: '张三'}, {age: 12})

  1. deepCopy

空值或者undefined默认拷贝为空对象{}

举例:

utils2js.deepCopy({name: 'zhansgan', obj: {}, arr: [2, 3]})

  1. float

举例:

utils2js.float.add(0.22, 0.1)
utils2js.float.sub(0.22, 0.1)
utils2js.float.ride(0.22, 0.1)
utils2js.float.divide(0.22, 0.1)
  1. 识别浏览器类型

举例:

utils2js.brower.browerVal()
utils2js.brower.isIE()

Keywords

FAQs

Package last updated on 29 May 2018

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