// 一行都没改,嵌入到项目里只是因为 cfc npm 得自己安装容易忘,这个依赖较小
// Chance.js 1.0.16
// http://chancejs.com
// (c) 2013 Victor Quinn
// Chance may be freely distributed or modified under the MIT license.
(function () {
// Constants
var MAX_INT = 9007199254740992;
var MIN_INT = -MAX_INT;
var NUMBERS = '0123456789';
var CHARS_LOWER = 'abcdefghijklmnopqrstuvwxyz';
var CHARS_UPPER = CHARS_LOWER.toUpperCase();
var HEX_POOL = NUMBERS + "abcdef";
// Errors
function UnsupportedError(message) {
this.name = 'UnsupportedError';
this.message = message || 'This feature is not supported on this platform';
}
UnsupportedError.prototype = new Error();
UnsupportedError.prototype.constructor = UnsupportedError;
// Cached array helpers
var slice = Array.prototype.slice;
// Constructor
function Chance (seed) {
if (!(this instanceof Chance)) {
if (!seed) { seed = null; } // handle other non-truthy seeds, as described in issue #322
return seed === null ? new Chance() : new Chance(seed);
}
// if user has provided a function, use that as the generator
if (typeof seed === 'function') {
this.random = seed;
return this;
}
if (arguments.length) {
// set a starting value of zero so we can add to it
this.seed = 0;
}
// otherwise, leave this.seed blank so that MT will receive a blank
for (var i = 0; i < arguments.length; i++) {
var seedling = 0;
if (Object.prototype.toString.call(arguments[i]) === '[object String]') {
for (var j = 0; j < arguments[i].length; j++) {
// create a numeric hash for each argument, add to seedling
var hash = 0;
for (var k = 0; k < arguments[i].length; k++) {
hash = arguments[i].charCodeAt(k) + (hash << 6) + (hash << 16) - hash;
}
seedling += hash;
}
} else {
seedling = arguments[i];
}
this.seed += (arguments.length - i) * seedling;
}
// If no generator function was provided, use our MT
this.mt = this.mersenne_twister(this.seed);
this.bimd5 = this.blueimp_md5();
this.random = function () {
return this.mt.random(this.seed);
};
return this;
}
Chance.prototype.VERSION = "1.0.16";
// Random helper functions
function initOptions(options, defaults) {
options = options || {};
if (defaults) {
for (var i in defaults) {
if (typeof options[i] === 'undefined') {
options[i] = defaults[i];
}
}
}
return options;
}
function range(size) {
return Array.apply(null, Array(size)).map(function (_, i) {return i;});
}
function testRange(test, errorMessage) {
if (test) {
throw new RangeError(errorMessage);
}
}
/**
* Encode the input string with Base64.
*/
var base64 = function() {
throw new Error('No Base64 encoder available.');
};
// Select proper Base64 encoder.
(function determineBase64Encoder() {
if (typeof btoa === 'function') {
base64 = btoa;
} else if (typeof Buffer === 'function') {
base64 = function(input) {
return new Buffer(input).toString('base64');
};
}
})();
// -- Basics --
/**
* Return a random bool, either true or false
*
* @param {Object} [options={ likelihood: 50 }] alter the likelihood of
* receiving a true or false value back.
* @throws {RangeError} if the likelihood is out of bounds
* @returns {Bool} either true or false
*/
Chance.prototype.bool = function (options) {
// likelihood of success (true)
options = initOptions(options, {likelihood : 50});
// Note, we could get some minor perf optimizations by checking range
// prior to initializing defaults, but that makes code a bit messier
// and the check more complicated as we have to check existence of
// the object then existence of the key before checking constraints.
// Since the options initialization should be minor computationally,
// decision made for code cleanliness intentionally. This is mentioned
// here as it's the first occurrence, will not be mentioned again.
testRange(
options.likelihood < 0 || options.likelihood > 100,
"Chance: Likelihood accepts values from 0 to 100."
);
return this.random() * 100 < options.likelihood;
};
Chance.prototype.animal = function (options){
//returns a random animal
options = initOptions(options);
if(typeof options.type !== 'undefined'){
//if user does not put in a valid animal type, user will get an error
testRange(
!this.get("animals")[options.type.toLowerCase()],
"Please pick from desert, ocean, grassland, forest, zoo, pets, farm."
);
//if user does put in valid animal type, will return a random animal of that type
return this.pick(this.get("animals")[options.type.toLowerCase()]);
}
//if user does not put in any animal type, will return a random animal regardless
animalTypeArray = ["desert","forest","ocean","zoo","farm","pet","grassland"];
return this.pick(this.get("animals")[this.pick(animalTypeArray)]);
};
/**
* Return a random character.
*
* @param {Object} [options={}] can specify a character pool, only alpha,
* only symbols, and casing (lower or upper)
* @returns {String} a single random character
* @throws {RangeError} Can only specify alpha or symbols, not both
*/
Chance.prototype.character = function (options) {
options = initOptions(options);
testRange(
options.alpha && options.symbols,
"Chance: Cannot specify both alpha and symbols."
);
var symbols = "!@#$%^&*()[]",
letters, pool;
if (options.casing === 'lower') {
letters = CHARS_LOWER;
} else if (options.casing === 'upper') {
letters = CHARS_UPPER;
} else {
letters = CHARS_LOWER + CHARS_UPPER;
}
if (options.pool) {
pool = options.pool;
} else if (options.alpha) {
pool = letters;
} else if (options.symbols) {
pool = symbols;
} else {
pool = letters + NUMBERS + symbols;
}
return pool.charAt(this.natural({max: (pool.length - 1)}));
};
// Note, wanted to use "float" or "double" but those are both JS reserved words.
// Note, fixed means N OR LESS digits after the decimal. This because
// It could be 14.9000 but in JavaScript, when this is cast as a number,
// the trailing zeroes are dropped. Left to the consumer if trailing zeroes are
// needed
/**
* Return a random floating point number
*
* @param {Object} [options={}] can specify a fixed precision, min, max
* @returns {Number} a single floating point number
* @throws {RangeError} Can only specify fixed or precision, not both. Also
* min cannot be greater than max
*/
Chance.prototype.floating = function (options) {
options = initOptions(options, {fixed : 4});
testRange(
options.fixed && options.precision,
"Chance: Cannot specify both fixed and precision."
);
var num;
var fixed = Math.pow(10, options.fixed);
var max = MAX_INT / fixed;
var min = -max;
没有合适的资源?快使用搜索试试~ 我知道了~
amis前端低代码框架 v2.8.0
共1727个文件
tsx:495个
md:248个
scss:218个
5星 · 超过95%的资源 需积分: 5 3 下载量 40 浏览量
2023-03-19
16:11:44
上传
评论
收藏 29.88MB RAR 举报
温馨提示
amis 是一个低代码前端框架,它使用 JSON 配置来生成页面,可以节省页面开发工作量,极大提升开发前端页面的效率。目前在百度广泛用于内部平台的前端开发,已有 100+ 部门使用,创建了 3w+ 页面。
资源推荐
资源详情
资源评论
收起资源包目录
amis前端低代码框架 v2.8.0 (1727个子文件)
amis.code-workspace 276B
server.conf 333B
server.conf 268B
iconfont.css 150KB
doc.css 15KB
.dockerignore 56B
.editorconfig 211B
iconfont.eot 174KB
.gitattributes 152B
.gitignore 380B
.gitignore 73B
.gitignore 70B
.gitignore 56B
.gitignore 20B
.gitignore 2B
index.html 4KB
index.html 4KB
index.html 3KB
index.html 2KB
mobile.html 2KB
index-vite.html 2KB
sdk-placeholder.html 1KB
plumeria.jpeg 62KB
4f3cb4202335.jpg 351KB
1314a2a3d3f6.jpg 317KB
bd3eb13533fa828b13b24500f31f4134960a5a44.jpg 315KB
552b175ef11d.jpg 261KB
da6376bf988c.jpg 241KB
8f2e79f82be0.jpg 148KB
0d338744ebf81a4cff2f4cd6de2a6059252da694.jpg 121KB
c9fcc3cec3fdfc03ccabb38edd3f8794a4c22630.jpg 120KB
d8e4992057f9.jpg 83KB
3893101144.jpg 21KB
ai-fake-face.jpg 19KB
chance.js 335KB
chart5.js 162KB
fis-conf.js 25KB
sample.db.js 21KB
app.js 19KB
table2.js 9KB
table.js 9KB
dynamic.js 9KB
table4.js 8KB
classList.js 7KB
schema.js 7KB
mod.js 7KB
md-parser.js 6KB
sample.js 6KB
embed-packager.js 6KB
rollup.config.js 5KB
chart1.js 5KB
rollup.config.js 4KB
rollup.config.js 4KB
search.js 4KB
task.js 4KB
departUser.js 3KB
chart2.js 2KB
chart7.js 2KB
rollup.config.js 2KB
tree.js 2KB
card.js 2KB
basic.js 2KB
chart4.js 2KB
index.js 2KB
upload2cdn.js 2KB
data.js 2KB
index.js 2KB
list.js 2KB
autoComplete.js 1KB
nav.js 1KB
jest.setup.js 1KB
generate-search-data.js 1KB
getOptions.js 1KB
generate-helper-table.js 1KB
autoUpdate.js 1KB
table3.js 1KB
chart.js 1KB
departUserSearch.js 1KB
table.js 1016B
chart2.js 1012B
level3.js 896B
level2.js 877B
chart6.js 834B
sdk-size.js 832B
var-not-in-common.js 824B
chart3.js 821B
chart1.js 819B
index.js 801B
form.js 769B
autoComplete2.js 738B
chainedOptions.js 696B
chartData.js 623B
carousel.js 598B
deferOptions.js 584B
autoComplete.js 567B
cloest.js 565B
jest.setup.js 564B
initData.js 530B
jest.setup.js 527B
random.js 503B
共 1727 条
- 1
- 2
- 3
- 4
- 5
- 6
- 18
csdn1789999
- 粉丝: 0
- 资源: 21
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
- 1
- 2
前往页