Socket
Socket
Sign inDemoInstall

mockjs

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mockjs - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1-beta1

2

package.json

@@ -5,3 +5,3 @@ {

"description": "生成随机数据 & 拦截 Ajax 请求",
"version": "1.0.0",
"version": "1.0.1-beta1",
"homepage": "http://mockjs.com/",

@@ -8,0 +8,0 @@ "keywords": [

@@ -32,3 +32,3 @@ /* global require, module, window */

Mock.version = '1.0.0'
Mock.version = '1.0.1-beta1'

@@ -35,0 +35,0 @@ // 避免循环依赖

/*
## Helpers
*/
var Util = require('../util')
module.exports = {

@@ -19,13 +22,33 @@ // 把字符串的第一个字母转换为大写。

pick: function pick(arr, min, max) {
arr = arr || []
switch (arguments.length) {
case 1:
return arr[this.natural(0, arr.length - 1)]
case 2:
max = min
/* falls through */
case 3:
return this.shuffle(arr, min, max)
// pick( item1, item2 ... )
if (!Util.isArray(arr)) {
arr = [].slice.call(arguments)
min = 1
max = 1
} else {
// pick( [ item1, item2 ... ] )
if (min === undefined) min = 1
// pick( [ item1, item2 ... ], count )
if (max === undefined) max = min
}
if (min === 1 && max === 1) return arr[this.natural(0, arr.length - 1)]
// pick( [ item1, item2 ... ], min, max )
return this.shuffle(arr, min, max)
// 通过参数个数判断方法签名,扩展性太差!#90
// switch (arguments.length) {
// case 1:
// // pick( [ item1, item2 ... ] )
// return arr[this.natural(0, arr.length - 1)]
// case 2:
// // pick( [ item1, item2 ... ], count )
// max = min
// /* falls through */
// case 3:
// // pick( [ item1, item2 ... ], min, max )
// return this.shuffle(arr, min, max)
// }
},

@@ -32,0 +55,0 @@ /*

@@ -426,2 +426,5 @@ /* global require, chai, describe, before, it */

})
doit('Random.pick("a", "e", "i", "o", "u")', function(data) {
expect(["a", "e", "i", "o", "u"]).to.include(data)
})
doit('Random.pick(["a", "e", "i", "o", "u"])', function(data) {

@@ -428,0 +431,0 @@ expect(["a", "e", "i", "o", "u"]).to.include(data)

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

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