新增扫描二维码功能以及h5复制链接app中打开连接功能删除无用的node包
parent
49eb30f265
commit
8fe64bd3c6
52
App.vue
52
App.vue
|
@ -5,9 +5,16 @@
|
||||||
*/
|
*/
|
||||||
import { mapMutations } from "vuex";
|
import { mapMutations } from "vuex";
|
||||||
import APPUpdate from "@/plugins/APPUpdate";
|
import APPUpdate from "@/plugins/APPUpdate";
|
||||||
|
import { getClipboardData } from "@/js_sdk/h5-copy/h5-copy.js";
|
||||||
|
import config from "@/config/config";
|
||||||
// 悬浮球
|
// 悬浮球
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
config,
|
||||||
|
};
|
||||||
|
},
|
||||||
methods: {
|
methods: {
|
||||||
...mapMutations(["login"]),
|
...mapMutations(["login"]),
|
||||||
},
|
},
|
||||||
|
@ -21,6 +28,13 @@ export default {
|
||||||
// #endif
|
// #endif
|
||||||
},
|
},
|
||||||
|
|
||||||
|
onShow() {
|
||||||
|
// #ifndef H5
|
||||||
|
|
||||||
|
this.getClipboard();
|
||||||
|
// #endif
|
||||||
|
},
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
// 开屏广告
|
// 开屏广告
|
||||||
launch() {
|
launch() {
|
||||||
|
@ -59,7 +73,41 @@ export default {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
// 获取h5跳转app的链接并跳转
|
|
||||||
|
/**
|
||||||
|
* 获取粘贴板数据
|
||||||
|
*/
|
||||||
|
async getClipboard() {
|
||||||
|
let res = await getClipboardData();
|
||||||
|
/**
|
||||||
|
* 解析粘贴板数据
|
||||||
|
*/
|
||||||
|
if (res.indexOf(config.shareLink) != -1) {
|
||||||
|
uni.showModal({
|
||||||
|
title: "提示",
|
||||||
|
content: "检测到一个分享链接是否跳转?",
|
||||||
|
confirmText: "跳转",
|
||||||
|
success: function (callback) {
|
||||||
|
if (callback.confirm) {
|
||||||
|
const path = res.split(config.shareLink)[1];
|
||||||
|
if (path.indexOf("tabbar") != -1) {
|
||||||
|
uni.switchTab({
|
||||||
|
url: path,
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
uni.navigateTo({
|
||||||
|
url: path,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* h5中打开app获取跳转app的链接并跳转
|
||||||
|
*/
|
||||||
checkArguments() {
|
checkArguments() {
|
||||||
// #ifdef APP-PLUS
|
// #ifdef APP-PLUS
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
|
@ -67,7 +115,7 @@ export default {
|
||||||
if (args) {
|
if (args) {
|
||||||
const argsStr = decodeURIComponent(args);
|
const argsStr = decodeURIComponent(args);
|
||||||
const path = argsStr.split("//")[1];
|
const path = argsStr.split("//")[1];
|
||||||
if (path.indexOf("tabbar")) {
|
if (path.indexOf("tabbar") != -1) {
|
||||||
uni.switchTab({
|
uni.switchTab({
|
||||||
url: `/${path}`,
|
url: `/${path}`,
|
||||||
});
|
});
|
||||||
|
|
|
@ -29,7 +29,7 @@
|
||||||
</u-popup>
|
</u-popup>
|
||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
import h5Copy from "@/js_sdk/h5-copy/h5-copy.js";
|
import { h5Copy } from "@/js_sdk/h5-copy/h5-copy.js";
|
||||||
import configs from "@/config/config";
|
import configs from "@/config/config";
|
||||||
import mpShare from "uview-ui/libs/mixin/mpShare.js";
|
import mpShare from "uview-ui/libs/mixin/mpShare.js";
|
||||||
|
|
||||||
|
@ -57,13 +57,7 @@ export default {
|
||||||
},
|
},
|
||||||
// 图片缩略图、 商品名称 、 type(goods,shop,pintuan) 拼团商品分享以及店铺分享
|
// 图片缩略图、 商品名称 、 type(goods,shop,pintuan) 拼团商品分享以及店铺分享
|
||||||
|
|
||||||
props: [
|
props: ["thumbnail", "goodsName", "type", "goodsId", "link"],
|
||||||
"thumbnail",
|
|
||||||
"goodsName",
|
|
||||||
"type",
|
|
||||||
"goodsId",
|
|
||||||
"link",
|
|
||||||
],
|
|
||||||
// #ifdef MP-WEIXIN
|
// #ifdef MP-WEIXIN
|
||||||
onShareAppMessage(res) {
|
onShareAppMessage(res) {
|
||||||
return {
|
return {
|
||||||
|
@ -79,7 +73,7 @@ export default {
|
||||||
// #ifdef H5
|
// #ifdef H5
|
||||||
copyLink() {
|
copyLink() {
|
||||||
let content =
|
let content =
|
||||||
this.configs.downloadLink +
|
this.configs.shareLink +
|
||||||
getCurrentPages()[getCurrentPages().length - 1].__page__.fullPath;
|
getCurrentPages()[getCurrentPages().length - 1].__page__.fullPath;
|
||||||
|
|
||||||
if (content === null || content === undefined) {
|
if (content === null || content === undefined) {
|
||||||
|
@ -104,7 +98,6 @@ export default {
|
||||||
if (val.type <= 1) {
|
if (val.type <= 1) {
|
||||||
let shareTitle;
|
let shareTitle;
|
||||||
|
|
||||||
|
|
||||||
if (this.type == "goods") {
|
if (this.type == "goods") {
|
||||||
shareTitle = `我发现了一个${this.goodsName}商品快来跟我一起看看吧`;
|
shareTitle = `我发现了一个${this.goodsName}商品快来跟我一起看看吧`;
|
||||||
} else if (this.type == "shops") {
|
} else if (this.type == "shops") {
|
||||||
|
@ -113,7 +106,6 @@ export default {
|
||||||
shareTitle = `我拼了一个${this.goodsName}快来跟我一起抢购吧!`;
|
shareTitle = `我拼了一个${this.goodsName}快来跟我一起抢购吧!`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
let scene; // "WXSenceTimeline 朋友圈 WXSceneSession 微信好友"
|
let scene; // "WXSenceTimeline 朋友圈 WXSceneSession 微信好友"
|
||||||
val.type == 1
|
val.type == 1
|
||||||
? (scene = "WXSenceTimeline")
|
? (scene = "WXSenceTimeline")
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
export default function h5Copy(content) {
|
export function h5Copy(content) {
|
||||||
|
|
||||||
if (!document.queryCommandSupported('copy')) {
|
if (!document.queryCommandSupported('copy')) {
|
||||||
// 不支持
|
// 不支持
|
||||||
|
@ -16,3 +16,27 @@ export default function h5Copy(content) {
|
||||||
return result
|
return result
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取系统剪贴板内容
|
||||||
|
*/
|
||||||
|
export function getClipboardData() {
|
||||||
|
return new Promise((success, fail) => {
|
||||||
|
// #ifndef H5
|
||||||
|
uni.getClipboardData({
|
||||||
|
success: ({ data }) => success(data),
|
||||||
|
fail
|
||||||
|
})
|
||||||
|
// #endif
|
||||||
|
|
||||||
|
// #ifdef H5
|
||||||
|
try {
|
||||||
|
navigator.clipboard.readText().then(success).catch(fail)
|
||||||
|
} catch (error) {
|
||||||
|
fail(error)
|
||||||
|
}
|
||||||
|
// #endif
|
||||||
|
})
|
||||||
|
}
|
|
@ -1,50 +0,0 @@
|
||||||
# History
|
|
||||||
----
|
|
||||||
|
|
||||||
## 1.11.3 / 2019-06-28
|
|
||||||
|
|
||||||
- support suppressWarning option when validate
|
|
||||||
|
|
||||||
## 1.11.1 / 2019-04-22
|
|
||||||
|
|
||||||
- support message as function
|
|
||||||
|
|
||||||
## 1.11.0 / 2019-03-22
|
|
||||||
|
|
||||||
- support promise usage(asyncValidator)
|
|
||||||
|
|
||||||
## 1.10.1 / 2018-12-18
|
|
||||||
|
|
||||||
- support override warning
|
|
||||||
|
|
||||||
## 1.10.0 / 2018-10-17
|
|
||||||
|
|
||||||
- revert promise
|
|
||||||
|
|
||||||
## 1.9.0 / 2018-10-10
|
|
||||||
|
|
||||||
- .validate returns promise
|
|
||||||
|
|
||||||
## 1.8.0 / 2017-08-16
|
|
||||||
|
|
||||||
- validator support return promise.
|
|
||||||
|
|
||||||
## 1.7.0 / 2017-06/09
|
|
||||||
|
|
||||||
- add es
|
|
||||||
- support string patter
|
|
||||||
|
|
||||||
## 1.6.0 / 2016-03-30
|
|
||||||
|
|
||||||
- support defaultField
|
|
||||||
|
|
||||||
## 1.5.0 / 2016-02-02
|
|
||||||
|
|
||||||
- support deep merge with default messages
|
|
||||||
- support rule message of any type(exp: jsx)
|
|
||||||
|
|
||||||
## 1.4.0 / 2015-01-12
|
|
||||||
|
|
||||||
- fix first option.
|
|
||||||
- add firstFields option.
|
|
||||||
- see tests/validator.spec.js
|
|
|
@ -1,9 +0,0 @@
|
||||||
The MIT License (MIT)
|
|
||||||
|
|
||||||
Copyright (c) 2014-present yiminghe
|
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
|
@ -1,440 +0,0 @@
|
||||||
# async-validator
|
|
||||||
---
|
|
||||||
|
|
||||||
Validate form asynchronous. A variation of https://github.com/freeformsystems/async-validate
|
|
||||||
|
|
||||||
[![NPM version][npm-image]][npm-url]
|
|
||||||
[![build status][travis-image]][travis-url]
|
|
||||||
[![Test coverage][coveralls-image]][coveralls-url]
|
|
||||||
[![gemnasium deps][gemnasium-image]][gemnasium-url]
|
|
||||||
[![node version][node-image]][node-url]
|
|
||||||
[![npm download][download-image]][download-url]
|
|
||||||
|
|
||||||
[npm-image]: http://img.shields.io/npm/v/async-validator.svg?style=flat-square
|
|
||||||
[npm-url]: http://npmjs.org/package/async-validator
|
|
||||||
[travis-image]: https://img.shields.io/travis/yiminghe/async-validator.svg?style=flat-square
|
|
||||||
[travis-url]: https://travis-ci.org/yiminghe/async-validator
|
|
||||||
[coveralls-image]: https://img.shields.io/coveralls/yiminghe/async-validator.svg?style=flat-square
|
|
||||||
[coveralls-url]: https://coveralls.io/r/yiminghe/async-validator?branch=master
|
|
||||||
[gemnasium-image]: http://img.shields.io/gemnasium/yiminghe/async-validator.svg?style=flat-square
|
|
||||||
[gemnasium-url]: https://gemnasium.com/yiminghe/async-validator
|
|
||||||
[node-image]: https://img.shields.io/badge/node.js-%3E=4.0.0-green.svg?style=flat-square
|
|
||||||
[node-url]: http://nodejs.org/download/
|
|
||||||
[download-image]: https://img.shields.io/npm/dm/async-validator.svg?style=flat-square
|
|
||||||
[download-url]: https://npmjs.org/package/async-validator
|
|
||||||
|
|
||||||
|
|
||||||
## API
|
|
||||||
|
|
||||||
The following is modified from earlier version of [async-validate](https://github.com/freeformsystems/async-validate).
|
|
||||||
|
|
||||||
### Usage
|
|
||||||
|
|
||||||
Basic usage involves defining a descriptor, assigning it to a schema and passing the object to be validated and a callback function to the `validate` method of the schema:
|
|
||||||
|
|
||||||
```javascript
|
|
||||||
var schema = require('async-validator');
|
|
||||||
var descriptor = {
|
|
||||||
name: {
|
|
||||||
type: "string",
|
|
||||||
required: true,
|
|
||||||
validator: (rule, value) => value === 'muji',
|
|
||||||
},
|
|
||||||
};
|
|
||||||
var validator = new schema(descriptor);
|
|
||||||
validator.validate({name: "muji"}, (errors, fields) => {
|
|
||||||
if(errors) {
|
|
||||||
// validation failed, errors is an array of all errors
|
|
||||||
// fields is an object keyed by field name with an array of
|
|
||||||
// errors per field
|
|
||||||
return handleErrors(errors, fields);
|
|
||||||
}
|
|
||||||
// validation passed
|
|
||||||
});
|
|
||||||
|
|
||||||
// PROMISE USAGE
|
|
||||||
validator.validate({
|
|
||||||
name: "muji",
|
|
||||||
asyncValidator: (rule, value) => axios.post('/nameValidator', { name: value }),
|
|
||||||
}, (errors, fields) => {
|
|
||||||
if(errors) {
|
|
||||||
// validation failed, errors is an array of all errors
|
|
||||||
// fields is an object keyed by field name with an array of
|
|
||||||
// errors per field
|
|
||||||
return handleErrors(errors, fields);
|
|
||||||
}
|
|
||||||
// validation passed
|
|
||||||
})
|
|
||||||
.then(() => {
|
|
||||||
// validation passed
|
|
||||||
})
|
|
||||||
.catch(({ errors, fields }) => {
|
|
||||||
return handleErrors(errors, fields);
|
|
||||||
})
|
|
||||||
```
|
|
||||||
|
|
||||||
### Validate
|
|
||||||
|
|
||||||
```javascript
|
|
||||||
function(source, [options], callback): Promise
|
|
||||||
```
|
|
||||||
|
|
||||||
* `source`: The object to validate (required).
|
|
||||||
* `options`: An object describing processing options for the validation (optional).
|
|
||||||
* `callback`: A callback function to invoke when validation completes (required).
|
|
||||||
|
|
||||||
The method will return a Promise object like:
|
|
||||||
* `then()`,validation passed
|
|
||||||
* `catch({ errors, fields })`,validation failed, errors is an array of all errors, fields is an object keyed by field name with an array of
|
|
||||||
|
|
||||||
### Options
|
|
||||||
|
|
||||||
* `suppressWarning`: Boolean, whether to suppress internal warning about invalid value.
|
|
||||||
|
|
||||||
* `first`: Boolean, Invoke `callback` when the first validation rule generates an error,
|
|
||||||
no more validation rules are processed.
|
|
||||||
If your validation involves multiple asynchronous calls (for example, database queries) and you only need the first error use this option.
|
|
||||||
|
|
||||||
* `firstFields`: Boolean|String[], Invoke `callback` when the first validation rule of the specified field generates an error,
|
|
||||||
no more validation rules of the same field are processed. `true` means all fields.
|
|
||||||
|
|
||||||
### Rules
|
|
||||||
|
|
||||||
Rules may be functions that perform validation.
|
|
||||||
|
|
||||||
```javascript
|
|
||||||
function(rule, value, callback, source, options)
|
|
||||||
```
|
|
||||||
|
|
||||||
* `rule`: The validation rule in the source descriptor that corresponds to the field name being validated. It is always assigned a `field` property with the name of the field being validated.
|
|
||||||
* `value`: The value of the source object property being validated.
|
|
||||||
* `callback`: A callback function to invoke once validation is complete. It expects to be passed an array of `Error` instances to indicate validation failure. If the check is synchronous, you can directly return a ` false ` or ` Error ` or ` Error Array `.
|
|
||||||
* `source`: The source object that was passed to the `validate` method.
|
|
||||||
* `options`: Additional options.
|
|
||||||
* `options.messages`: The object containing validation error messages, will be deep merged with defaultMessages.
|
|
||||||
|
|
||||||
The options passed to `validate` or `asyncValidate` are passed on to the validation functions so that you may reference transient data (such as model references) in validation functions. However, some option names are reserved; if you use these properties of the options object they are overwritten. The reserved properties are `messages`, `exception` and `error`.
|
|
||||||
|
|
||||||
```javascript
|
|
||||||
var schema = require('async-validator');
|
|
||||||
var descriptor = {
|
|
||||||
name(rule, value, callback, source, options) {
|
|
||||||
var errors = [];
|
|
||||||
if(!/^[a-z0-9]+$/.test(value)) {
|
|
||||||
errors.push(
|
|
||||||
new Error(
|
|
||||||
util.format("%s must be lowercase alphanumeric characters",
|
|
||||||
rule.field)));
|
|
||||||
}
|
|
||||||
return errors;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
var validator = new schema(descriptor);
|
|
||||||
validator.validate({name: "Firstname"}, (errors, fields) => {
|
|
||||||
if(errors) {
|
|
||||||
return handleErrors(errors, fields);
|
|
||||||
}
|
|
||||||
// validation passed
|
|
||||||
});
|
|
||||||
```
|
|
||||||
|
|
||||||
It is often useful to test against multiple validation rules for a single field, to do so make the rule an array of objects, for example:
|
|
||||||
|
|
||||||
```javascript
|
|
||||||
var descriptor = {
|
|
||||||
email: [
|
|
||||||
{type: "string", required: true, pattern: schema.pattern.email},
|
|
||||||
{validator(rule, value, callback, source, options) {
|
|
||||||
var errors = [];
|
|
||||||
// test if email address already exists in a database
|
|
||||||
// and add a validation error to the errors array if it does
|
|
||||||
return errors;
|
|
||||||
}}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
#### Type
|
|
||||||
|
|
||||||
Indicates the `type` of validator to use. Recognised type values are:
|
|
||||||
|
|
||||||
* `string`: Must be of type `string`. `This is the default type.`
|
|
||||||
* `number`: Must be of type `number`.
|
|
||||||
* `boolean`: Must be of type `boolean`.
|
|
||||||
* `method`: Must be of type `function`.
|
|
||||||
* `regexp`: Must be an instance of `RegExp` or a string that does not generate an exception when creating a new `RegExp`.
|
|
||||||
* `integer`: Must be of type `number` and an integer.
|
|
||||||
* `float`: Must be of type `number` and a floating point number.
|
|
||||||
* `array`: Must be an array as determined by `Array.isArray`.
|
|
||||||
* `object`: Must be of type `object` and not `Array.isArray`.
|
|
||||||
* `enum`: Value must exist in the `enum`.
|
|
||||||
* `date`: Value must be valid as determined by `Date`
|
|
||||||
* `url`: Must be of type `url`.
|
|
||||||
* `hex`: Must be of type `hex`.
|
|
||||||
* `email`: Must be of type `email`.
|
|
||||||
|
|
||||||
#### Required
|
|
||||||
|
|
||||||
The `required` rule property indicates that the field must exist on the source object being validated.
|
|
||||||
|
|
||||||
#### Pattern
|
|
||||||
|
|
||||||
The `pattern` rule property indicates a regular expression that the value must match to pass validation.
|
|
||||||
|
|
||||||
#### Range
|
|
||||||
|
|
||||||
A range is defined using the `min` and `max` properties. For `string` and `array` types comparison is performed against the `length`, for `number` types the number must not be less than `min` nor greater than `max`.
|
|
||||||
|
|
||||||
#### Length
|
|
||||||
|
|
||||||
To validate an exact length of a field specify the `len` property. For `string` and `array` types comparison is performed on the `length` property, for the `number` type this property indicates an exact match for the `number`, ie, it may only be strictly equal to `len`.
|
|
||||||
|
|
||||||
If the `len` property is combined with the `min` and `max` range properties, `len` takes precedence.
|
|
||||||
|
|
||||||
#### Enumerable
|
|
||||||
|
|
||||||
To validate a value from a list of possible values use the `enum` type with a `enum` property listing the valid values for the field, for example:
|
|
||||||
|
|
||||||
```javascript
|
|
||||||
var descriptor = {
|
|
||||||
role: {type: "enum", enum: ['admin', 'user', 'guest']}
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
#### Whitespace
|
|
||||||
|
|
||||||
It is typical to treat required fields that only contain whitespace as errors. To add an additional test for a string that consists solely of whitespace add a `whitespace` property to a rule with a value of `true`. The rule must be a `string` type.
|
|
||||||
|
|
||||||
You may wish to sanitize user input instead of testing for whitespace, see [transform](#transform) for an example that would allow you to strip whitespace.
|
|
||||||
|
|
||||||
|
|
||||||
#### Deep Rules
|
|
||||||
|
|
||||||
If you need to validate deep object properties you may do so for validation rules that are of the `object` or `array` type by assigning nested rules to a `fields` property of the rule.
|
|
||||||
|
|
||||||
```javascript
|
|
||||||
var descriptor = {
|
|
||||||
address: {
|
|
||||||
type: "object", required: true,
|
|
||||||
fields: {
|
|
||||||
street: {type: "string", required: true},
|
|
||||||
city: {type: "string", required: true},
|
|
||||||
zip: {type: "string", required: true, len: 8, message: "invalid zip"}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
name: {type: "string", required: true}
|
|
||||||
}
|
|
||||||
var validator = new schema(descriptor);
|
|
||||||
validator.validate({ address: {} }, (errors, fields) => {
|
|
||||||
// errors for address.street, address.city, address.zip
|
|
||||||
});
|
|
||||||
```
|
|
||||||
|
|
||||||
Note that if you do not specify the `required` property on the parent rule it is perfectly valid for the field not to be declared on the source object and the deep validation rules will not be executed as there is nothing to validate against.
|
|
||||||
|
|
||||||
Deep rule validation creates a schema for the nested rules so you can also specify the `options` passed to the `schema.validate()` method.
|
|
||||||
|
|
||||||
```javascript
|
|
||||||
var descriptor = {
|
|
||||||
address: {
|
|
||||||
type: "object", required: true, options: {single: true, first: true},
|
|
||||||
fields: {
|
|
||||||
street: {type: "string", required: true},
|
|
||||||
city: {type: "string", required: true},
|
|
||||||
zip: {type: "string", required: true, len: 8, message: "invalid zip"}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
name: {type: "string", required: true}
|
|
||||||
}
|
|
||||||
var validator = new schema(descriptor);
|
|
||||||
|
|
||||||
validator.validate({ address: {} })
|
|
||||||
.catch(({ errors, fields }) => {
|
|
||||||
// now only errors for street and name
|
|
||||||
});
|
|
||||||
```
|
|
||||||
|
|
||||||
The parent rule is also validated so if you have a set of rules such as:
|
|
||||||
|
|
||||||
```javascript
|
|
||||||
var descriptor = {
|
|
||||||
roles: {
|
|
||||||
type: "array", required: true, len: 3,
|
|
||||||
fields: {
|
|
||||||
0: {type: "string", required: true},
|
|
||||||
1: {type: "string", required: true},
|
|
||||||
2: {type: "string", required: true}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
And supply a source object of `{roles: ["admin", "user"]}` then two errors will be created. One for the array length mismatch and one for the missing required array entry at index 2.
|
|
||||||
|
|
||||||
#### defaultField
|
|
||||||
|
|
||||||
The `defaultField` property can be used with the `array` or `object` type for validating all values of the container.
|
|
||||||
It may be an `object` or `array` containing validation rules. For example:
|
|
||||||
|
|
||||||
```javascript
|
|
||||||
var descriptor = {
|
|
||||||
urls: {
|
|
||||||
type: "array", required: true,
|
|
||||||
defaultField: {type: "url"}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
Note that `defaultField` is expanded to `fields`, see [deep rules](#deep-rules).
|
|
||||||
|
|
||||||
#### Transform
|
|
||||||
|
|
||||||
Sometimes it is necessary to transform a value before validation, possibly to coerce the value or to sanitize it in some way. To do this add a `transform` function to the validation rule. The property is transformed prior to validation and re-assigned to the source object to mutate the value of the property in place.
|
|
||||||
|
|
||||||
```javascript
|
|
||||||
var schema = require('async-validator');
|
|
||||||
var sanitize = require('validator').sanitize;
|
|
||||||
var descriptor = {
|
|
||||||
name: {
|
|
||||||
type: "string",
|
|
||||||
required: true, pattern: /^[a-z]+$/,
|
|
||||||
transform(value) {
|
|
||||||
return sanitize(value).trim();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
var validator = new schema(descriptor);
|
|
||||||
var source = {name: " user "};
|
|
||||||
validator.validate(source)
|
|
||||||
.then(() => assert.equal(source.name, "user"));
|
|
||||||
```
|
|
||||||
|
|
||||||
Without the `transform` function validation would fail due to the pattern not matching as the input contains leading and trailing whitespace, but by adding the transform function validation passes and the field value is sanitized at the same time.
|
|
||||||
|
|
||||||
|
|
||||||
### Messages
|
|
||||||
|
|
||||||
Depending upon your application requirements, you may need i18n support or you may prefer different validation error messages.
|
|
||||||
|
|
||||||
The easiest way to achieve this is to assign a `message` to a rule:
|
|
||||||
|
|
||||||
```javascript
|
|
||||||
{name:{type: "string", required: true, message: "Name is required"}}
|
|
||||||
```
|
|
||||||
|
|
||||||
Message can be any type, such as jsx format.
|
|
||||||
|
|
||||||
```javascript
|
|
||||||
{name:{type: "string", required: true, message: <b>Name is required</b>}}
|
|
||||||
```
|
|
||||||
|
|
||||||
Message can also be a function, e.g. if you use vue-i18n:
|
|
||||||
```javascript
|
|
||||||
{name:{type: "string", required: true, message: () => this.$t( 'name is required' )}}
|
|
||||||
```
|
|
||||||
|
|
||||||
Potentially you may require the same schema validation rules for different languages, in which case duplicating the schema rules for each language does not make sense.
|
|
||||||
|
|
||||||
In this scenario you could just provide your own messages for the language and assign it to the schema:
|
|
||||||
|
|
||||||
```javascript
|
|
||||||
var schema = require('async-validator');
|
|
||||||
var cn = {
|
|
||||||
required: '%s 必填',
|
|
||||||
};
|
|
||||||
var descriptor = {name:{type: "string", required: true}};
|
|
||||||
var validator = new schema(descriptor);
|
|
||||||
// deep merge with defaultMessages
|
|
||||||
validator.messages(cn);
|
|
||||||
...
|
|
||||||
```
|
|
||||||
|
|
||||||
If you are defining your own validation functions it is better practice to assign the message strings to a messages object and then access the messages via the `options.messages` property within the validation function.
|
|
||||||
|
|
||||||
### asyncValidator
|
|
||||||
|
|
||||||
You can customize the asynchronous validation function for the specified field:
|
|
||||||
|
|
||||||
```js
|
|
||||||
const fields = {
|
|
||||||
asyncField:{
|
|
||||||
asyncValidator(rule,value,callback){
|
|
||||||
ajax({
|
|
||||||
url:'xx',
|
|
||||||
value:value
|
|
||||||
}).then(function(data){
|
|
||||||
callback();
|
|
||||||
},function(error){
|
|
||||||
callback(new Error(error))
|
|
||||||
});
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
promiseField:{
|
|
||||||
asyncValidator(rule, value){
|
|
||||||
return ajax({
|
|
||||||
url:'xx',
|
|
||||||
value:value
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
```
|
|
||||||
|
|
||||||
### validator
|
|
||||||
|
|
||||||
you can custom validate function for specified field:
|
|
||||||
|
|
||||||
```js
|
|
||||||
const fields = {
|
|
||||||
field:{
|
|
||||||
validator(rule,value,callback){
|
|
||||||
return value === 'test';
|
|
||||||
},
|
|
||||||
message: 'Value is not equal to "test".',
|
|
||||||
},
|
|
||||||
|
|
||||||
field2:{
|
|
||||||
validator(rule,value,callback){
|
|
||||||
return new Error(`'${value} is not equal to "test".'`);
|
|
||||||
},
|
|
||||||
},
|
|
||||||
|
|
||||||
arrField:{
|
|
||||||
validator(rule, value){
|
|
||||||
return [
|
|
||||||
new Error('Message 1'),
|
|
||||||
new Error('Message 2'),
|
|
||||||
];
|
|
||||||
}
|
|
||||||
},
|
|
||||||
};
|
|
||||||
```
|
|
||||||
|
|
||||||
## FAQ
|
|
||||||
|
|
||||||
### How to avoid warning
|
|
||||||
|
|
||||||
```js
|
|
||||||
var Schema = require('async-validator');
|
|
||||||
Schema.warning = function(){};
|
|
||||||
```
|
|
||||||
|
|
||||||
## Test Case
|
|
||||||
|
|
||||||
```
|
|
||||||
npm test
|
|
||||||
npm run chrome-test
|
|
||||||
```
|
|
||||||
|
|
||||||
## Coverage
|
|
||||||
|
|
||||||
```
|
|
||||||
npm run coverage
|
|
||||||
```
|
|
||||||
|
|
||||||
open coverage/ dir
|
|
||||||
|
|
||||||
## License
|
|
||||||
|
|
||||||
Everything is [MIT](http://en.wikipedia.org/wiki/MIT_License).
|
|
|
@ -1,298 +0,0 @@
|
||||||
'use strict';
|
|
||||||
|
|
||||||
Object.defineProperty(exports, "__esModule", {
|
|
||||||
value: true
|
|
||||||
});
|
|
||||||
|
|
||||||
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
|
|
||||||
|
|
||||||
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
|
|
||||||
|
|
||||||
var _util = require('./util');
|
|
||||||
|
|
||||||
var _validator = require('./validator/');
|
|
||||||
|
|
||||||
var _validator2 = _interopRequireDefault(_validator);
|
|
||||||
|
|
||||||
var _messages2 = require('./messages');
|
|
||||||
|
|
||||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Encapsulates a validation schema.
|
|
||||||
*
|
|
||||||
* @param descriptor An object declaring validation rules
|
|
||||||
* for this schema.
|
|
||||||
*/
|
|
||||||
function Schema(descriptor) {
|
|
||||||
this.rules = null;
|
|
||||||
this._messages = _messages2.messages;
|
|
||||||
this.define(descriptor);
|
|
||||||
}
|
|
||||||
|
|
||||||
Schema.prototype = {
|
|
||||||
messages: function messages(_messages) {
|
|
||||||
if (_messages) {
|
|
||||||
this._messages = (0, _util.deepMerge)((0, _messages2.newMessages)(), _messages);
|
|
||||||
}
|
|
||||||
return this._messages;
|
|
||||||
},
|
|
||||||
define: function define(rules) {
|
|
||||||
if (!rules) {
|
|
||||||
throw new Error('Cannot configure a schema with no rules');
|
|
||||||
}
|
|
||||||
if ((typeof rules === 'undefined' ? 'undefined' : _typeof(rules)) !== 'object' || Array.isArray(rules)) {
|
|
||||||
throw new Error('Rules must be an object');
|
|
||||||
}
|
|
||||||
this.rules = {};
|
|
||||||
var z = void 0;
|
|
||||||
var item = void 0;
|
|
||||||
for (z in rules) {
|
|
||||||
if (rules.hasOwnProperty(z)) {
|
|
||||||
item = rules[z];
|
|
||||||
this.rules[z] = Array.isArray(item) ? item : [item];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
validate: function validate(source_) {
|
|
||||||
var _this = this;
|
|
||||||
|
|
||||||
var o = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
||||||
var oc = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : function () {};
|
|
||||||
|
|
||||||
var source = source_;
|
|
||||||
var options = o;
|
|
||||||
var callback = oc;
|
|
||||||
if (typeof options === 'function') {
|
|
||||||
callback = options;
|
|
||||||
options = {};
|
|
||||||
}
|
|
||||||
if (!this.rules || Object.keys(this.rules).length === 0) {
|
|
||||||
if (callback) {
|
|
||||||
callback();
|
|
||||||
}
|
|
||||||
return Promise.resolve();
|
|
||||||
}
|
|
||||||
|
|
||||||
function complete(results) {
|
|
||||||
var i = void 0;
|
|
||||||
var errors = [];
|
|
||||||
var fields = {};
|
|
||||||
|
|
||||||
function add(e) {
|
|
||||||
if (Array.isArray(e)) {
|
|
||||||
var _errors;
|
|
||||||
|
|
||||||
errors = (_errors = errors).concat.apply(_errors, e);
|
|
||||||
} else {
|
|
||||||
errors.push(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (i = 0; i < results.length; i++) {
|
|
||||||
add(results[i]);
|
|
||||||
}
|
|
||||||
if (!errors.length) {
|
|
||||||
errors = null;
|
|
||||||
fields = null;
|
|
||||||
} else {
|
|
||||||
fields = (0, _util.convertFieldsError)(errors);
|
|
||||||
}
|
|
||||||
callback(errors, fields);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (options.messages) {
|
|
||||||
var messages = this.messages();
|
|
||||||
if (messages === _messages2.messages) {
|
|
||||||
messages = (0, _messages2.newMessages)();
|
|
||||||
}
|
|
||||||
(0, _util.deepMerge)(messages, options.messages);
|
|
||||||
options.messages = messages;
|
|
||||||
} else {
|
|
||||||
options.messages = this.messages();
|
|
||||||
}
|
|
||||||
var arr = void 0;
|
|
||||||
var value = void 0;
|
|
||||||
var series = {};
|
|
||||||
var keys = options.keys || Object.keys(this.rules);
|
|
||||||
keys.forEach(function (z) {
|
|
||||||
arr = _this.rules[z];
|
|
||||||
value = source[z];
|
|
||||||
arr.forEach(function (r) {
|
|
||||||
var rule = r;
|
|
||||||
if (typeof rule.transform === 'function') {
|
|
||||||
if (source === source_) {
|
|
||||||
source = _extends({}, source);
|
|
||||||
}
|
|
||||||
value = source[z] = rule.transform(value);
|
|
||||||
}
|
|
||||||
if (typeof rule === 'function') {
|
|
||||||
rule = {
|
|
||||||
validator: rule
|
|
||||||
};
|
|
||||||
} else {
|
|
||||||
rule = _extends({}, rule);
|
|
||||||
}
|
|
||||||
rule.validator = _this.getValidationMethod(rule);
|
|
||||||
rule.field = z;
|
|
||||||
rule.fullField = rule.fullField || z;
|
|
||||||
rule.type = _this.getType(rule);
|
|
||||||
if (!rule.validator) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
series[z] = series[z] || [];
|
|
||||||
series[z].push({
|
|
||||||
rule: rule,
|
|
||||||
value: value,
|
|
||||||
source: source,
|
|
||||||
field: z
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
var errorFields = {};
|
|
||||||
return (0, _util.asyncMap)(series, options, function (data, doIt) {
|
|
||||||
var rule = data.rule;
|
|
||||||
var deep = (rule.type === 'object' || rule.type === 'array') && (_typeof(rule.fields) === 'object' || _typeof(rule.defaultField) === 'object');
|
|
||||||
deep = deep && (rule.required || !rule.required && data.value);
|
|
||||||
rule.field = data.field;
|
|
||||||
|
|
||||||
function addFullfield(key, schema) {
|
|
||||||
return _extends({}, schema, {
|
|
||||||
fullField: rule.fullField + '.' + key
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function cb() {
|
|
||||||
var e = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
||||||
|
|
||||||
var errors = e;
|
|
||||||
if (!Array.isArray(errors)) {
|
|
||||||
errors = [errors];
|
|
||||||
}
|
|
||||||
if (!options.suppressWarning && errors.length) {
|
|
||||||
Schema.warning('async-validator:', errors);
|
|
||||||
}
|
|
||||||
if (errors.length && rule.message) {
|
|
||||||
errors = [].concat(rule.message);
|
|
||||||
}
|
|
||||||
|
|
||||||
errors = errors.map((0, _util.complementError)(rule));
|
|
||||||
|
|
||||||
if (options.first && errors.length) {
|
|
||||||
errorFields[rule.field] = 1;
|
|
||||||
return doIt(errors);
|
|
||||||
}
|
|
||||||
if (!deep) {
|
|
||||||
doIt(errors);
|
|
||||||
} else {
|
|
||||||
// if rule is required but the target object
|
|
||||||
// does not exist fail at the rule level and don't
|
|
||||||
// go deeper
|
|
||||||
if (rule.required && !data.value) {
|
|
||||||
if (rule.message) {
|
|
||||||
errors = [].concat(rule.message).map((0, _util.complementError)(rule));
|
|
||||||
} else if (options.error) {
|
|
||||||
errors = [options.error(rule, (0, _util.format)(options.messages.required, rule.field))];
|
|
||||||
} else {
|
|
||||||
errors = [];
|
|
||||||
}
|
|
||||||
return doIt(errors);
|
|
||||||
}
|
|
||||||
|
|
||||||
var fieldsSchema = {};
|
|
||||||
if (rule.defaultField) {
|
|
||||||
for (var k in data.value) {
|
|
||||||
if (data.value.hasOwnProperty(k)) {
|
|
||||||
fieldsSchema[k] = rule.defaultField;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fieldsSchema = _extends({}, fieldsSchema, data.rule.fields);
|
|
||||||
for (var f in fieldsSchema) {
|
|
||||||
if (fieldsSchema.hasOwnProperty(f)) {
|
|
||||||
var fieldSchema = Array.isArray(fieldsSchema[f]) ? fieldsSchema[f] : [fieldsSchema[f]];
|
|
||||||
fieldsSchema[f] = fieldSchema.map(addFullfield.bind(null, f));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
var schema = new Schema(fieldsSchema);
|
|
||||||
schema.messages(options.messages);
|
|
||||||
if (data.rule.options) {
|
|
||||||
data.rule.options.messages = options.messages;
|
|
||||||
data.rule.options.error = options.error;
|
|
||||||
}
|
|
||||||
schema.validate(data.value, data.rule.options || options, function (errs) {
|
|
||||||
var finalErrors = [];
|
|
||||||
if (errors && errors.length) {
|
|
||||||
finalErrors.push.apply(finalErrors, errors);
|
|
||||||
}
|
|
||||||
if (errs && errs.length) {
|
|
||||||
finalErrors.push.apply(finalErrors, errs);
|
|
||||||
}
|
|
||||||
doIt(finalErrors.length ? finalErrors : null);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var res = void 0;
|
|
||||||
if (rule.asyncValidator) {
|
|
||||||
res = rule.asyncValidator(rule, data.value, cb, data.source, options);
|
|
||||||
} else if (rule.validator) {
|
|
||||||
res = rule.validator(rule, data.value, cb, data.source, options);
|
|
||||||
if (res === true) {
|
|
||||||
cb();
|
|
||||||
} else if (res === false) {
|
|
||||||
cb(rule.message || rule.field + ' fails');
|
|
||||||
} else if (res instanceof Array) {
|
|
||||||
cb(res);
|
|
||||||
} else if (res instanceof Error) {
|
|
||||||
cb(res.message);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (res && res.then) {
|
|
||||||
res.then(function () {
|
|
||||||
return cb();
|
|
||||||
}, function (e) {
|
|
||||||
return cb(e);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}, function (results) {
|
|
||||||
complete(results);
|
|
||||||
});
|
|
||||||
},
|
|
||||||
getType: function getType(rule) {
|
|
||||||
if (rule.type === undefined && rule.pattern instanceof RegExp) {
|
|
||||||
rule.type = 'pattern';
|
|
||||||
}
|
|
||||||
if (typeof rule.validator !== 'function' && rule.type && !_validator2['default'].hasOwnProperty(rule.type)) {
|
|
||||||
throw new Error((0, _util.format)('Unknown rule type %s', rule.type));
|
|
||||||
}
|
|
||||||
return rule.type || 'string';
|
|
||||||
},
|
|
||||||
getValidationMethod: function getValidationMethod(rule) {
|
|
||||||
if (typeof rule.validator === 'function') {
|
|
||||||
return rule.validator;
|
|
||||||
}
|
|
||||||
var keys = Object.keys(rule);
|
|
||||||
var messageIndex = keys.indexOf('message');
|
|
||||||
if (messageIndex !== -1) {
|
|
||||||
keys.splice(messageIndex, 1);
|
|
||||||
}
|
|
||||||
if (keys.length === 1 && keys[0] === 'required') {
|
|
||||||
return _validator2['default'].required;
|
|
||||||
}
|
|
||||||
return _validator2['default'][this.getType(rule)] || false;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
Schema.register = function register(type, validator) {
|
|
||||||
if (typeof validator !== 'function') {
|
|
||||||
throw new Error('Cannot register a validator by type, validator is not a function');
|
|
||||||
}
|
|
||||||
_validator2['default'][type] = validator;
|
|
||||||
};
|
|
||||||
|
|
||||||
Schema.warning = _util.warning;
|
|
||||||
|
|
||||||
Schema.messages = _messages2.messages;
|
|
||||||
|
|
||||||
exports['default'] = Schema;
|
|
|
@ -1,62 +0,0 @@
|
||||||
'use strict';
|
|
||||||
|
|
||||||
Object.defineProperty(exports, "__esModule", {
|
|
||||||
value: true
|
|
||||||
});
|
|
||||||
exports.newMessages = newMessages;
|
|
||||||
function newMessages() {
|
|
||||||
return {
|
|
||||||
'default': 'Validation error on field %s',
|
|
||||||
required: '%s is required',
|
|
||||||
'enum': '%s must be one of %s',
|
|
||||||
whitespace: '%s cannot be empty',
|
|
||||||
date: {
|
|
||||||
format: '%s date %s is invalid for format %s',
|
|
||||||
parse: '%s date could not be parsed, %s is invalid ',
|
|
||||||
invalid: '%s date %s is invalid'
|
|
||||||
},
|
|
||||||
types: {
|
|
||||||
string: '%s is not a %s',
|
|
||||||
method: '%s is not a %s (function)',
|
|
||||||
array: '%s is not an %s',
|
|
||||||
object: '%s is not an %s',
|
|
||||||
number: '%s is not a %s',
|
|
||||||
date: '%s is not a %s',
|
|
||||||
boolean: '%s is not a %s',
|
|
||||||
integer: '%s is not an %s',
|
|
||||||
float: '%s is not a %s',
|
|
||||||
regexp: '%s is not a valid %s',
|
|
||||||
email: '%s is not a valid %s',
|
|
||||||
url: '%s is not a valid %s',
|
|
||||||
hex: '%s is not a valid %s'
|
|
||||||
},
|
|
||||||
string: {
|
|
||||||
len: '%s must be exactly %s characters',
|
|
||||||
min: '%s must be at least %s characters',
|
|
||||||
max: '%s cannot be longer than %s characters',
|
|
||||||
range: '%s must be between %s and %s characters'
|
|
||||||
},
|
|
||||||
number: {
|
|
||||||
len: '%s must equal %s',
|
|
||||||
min: '%s cannot be less than %s',
|
|
||||||
max: '%s cannot be greater than %s',
|
|
||||||
range: '%s must be between %s and %s'
|
|
||||||
},
|
|
||||||
array: {
|
|
||||||
len: '%s must be exactly %s in length',
|
|
||||||
min: '%s cannot be less than %s in length',
|
|
||||||
max: '%s cannot be greater than %s in length',
|
|
||||||
range: '%s must be between %s and %s in length'
|
|
||||||
},
|
|
||||||
pattern: {
|
|
||||||
mismatch: '%s value %s does not match pattern %s'
|
|
||||||
},
|
|
||||||
clone: function clone() {
|
|
||||||
var cloned = JSON.parse(JSON.stringify(this));
|
|
||||||
cloned.clone = this.clone;
|
|
||||||
return cloned;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
var messages = exports.messages = newMessages();
|
|
|
@ -1,33 +0,0 @@
|
||||||
'use strict';
|
|
||||||
|
|
||||||
Object.defineProperty(exports, "__esModule", {
|
|
||||||
value: true
|
|
||||||
});
|
|
||||||
|
|
||||||
var _util = require('../util');
|
|
||||||
|
|
||||||
var util = _interopRequireWildcard(_util);
|
|
||||||
|
|
||||||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj['default'] = obj; return newObj; } }
|
|
||||||
|
|
||||||
var ENUM = 'enum';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Rule for validating a value exists in an enumerable list.
|
|
||||||
*
|
|
||||||
* @param rule The validation rule.
|
|
||||||
* @param value The value of the field on the source object.
|
|
||||||
* @param source The source object being validated.
|
|
||||||
* @param errors An array of errors that this rule may add
|
|
||||||
* validation errors to.
|
|
||||||
* @param options The validation options.
|
|
||||||
* @param options.messages The validation messages.
|
|
||||||
*/
|
|
||||||
function enumerable(rule, value, source, errors, options) {
|
|
||||||
rule[ENUM] = Array.isArray(rule[ENUM]) ? rule[ENUM] : [];
|
|
||||||
if (rule[ENUM].indexOf(value) === -1) {
|
|
||||||
errors.push(util.format(options.messages[ENUM], rule.fullField, rule[ENUM].join(', ')));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
exports['default'] = enumerable;
|
|
|
@ -1,40 +0,0 @@
|
||||||
'use strict';
|
|
||||||
|
|
||||||
Object.defineProperty(exports, "__esModule", {
|
|
||||||
value: true
|
|
||||||
});
|
|
||||||
|
|
||||||
var _required = require('./required');
|
|
||||||
|
|
||||||
var _required2 = _interopRequireDefault(_required);
|
|
||||||
|
|
||||||
var _whitespace = require('./whitespace');
|
|
||||||
|
|
||||||
var _whitespace2 = _interopRequireDefault(_whitespace);
|
|
||||||
|
|
||||||
var _type = require('./type');
|
|
||||||
|
|
||||||
var _type2 = _interopRequireDefault(_type);
|
|
||||||
|
|
||||||
var _range = require('./range');
|
|
||||||
|
|
||||||
var _range2 = _interopRequireDefault(_range);
|
|
||||||
|
|
||||||
var _enum = require('./enum');
|
|
||||||
|
|
||||||
var _enum2 = _interopRequireDefault(_enum);
|
|
||||||
|
|
||||||
var _pattern = require('./pattern');
|
|
||||||
|
|
||||||
var _pattern2 = _interopRequireDefault(_pattern);
|
|
||||||
|
|
||||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
|
|
||||||
|
|
||||||
exports['default'] = {
|
|
||||||
required: _required2['default'],
|
|
||||||
whitespace: _whitespace2['default'],
|
|
||||||
type: _type2['default'],
|
|
||||||
range: _range2['default'],
|
|
||||||
'enum': _enum2['default'],
|
|
||||||
pattern: _pattern2['default']
|
|
||||||
};
|
|
|
@ -1,43 +0,0 @@
|
||||||
'use strict';
|
|
||||||
|
|
||||||
Object.defineProperty(exports, "__esModule", {
|
|
||||||
value: true
|
|
||||||
});
|
|
||||||
|
|
||||||
var _util = require('../util');
|
|
||||||
|
|
||||||
var util = _interopRequireWildcard(_util);
|
|
||||||
|
|
||||||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj['default'] = obj; return newObj; } }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Rule for validating a regular expression pattern.
|
|
||||||
*
|
|
||||||
* @param rule The validation rule.
|
|
||||||
* @param value The value of the field on the source object.
|
|
||||||
* @param source The source object being validated.
|
|
||||||
* @param errors An array of errors that this rule may add
|
|
||||||
* validation errors to.
|
|
||||||
* @param options The validation options.
|
|
||||||
* @param options.messages The validation messages.
|
|
||||||
*/
|
|
||||||
function pattern(rule, value, source, errors, options) {
|
|
||||||
if (rule.pattern) {
|
|
||||||
if (rule.pattern instanceof RegExp) {
|
|
||||||
// if a RegExp instance is passed, reset `lastIndex` in case its `global`
|
|
||||||
// flag is accidentally set to `true`, which in a validation scenario
|
|
||||||
// is not necessary and the result might be misleading
|
|
||||||
rule.pattern.lastIndex = 0;
|
|
||||||
if (!rule.pattern.test(value)) {
|
|
||||||
errors.push(util.format(options.messages.pattern.mismatch, rule.fullField, value, rule.pattern));
|
|
||||||
}
|
|
||||||
} else if (typeof rule.pattern === 'string') {
|
|
||||||
var _pattern = new RegExp(rule.pattern);
|
|
||||||
if (!_pattern.test(value)) {
|
|
||||||
errors.push(util.format(options.messages.pattern.mismatch, rule.fullField, value, rule.pattern));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
exports['default'] = pattern;
|
|
|
@ -1,68 +0,0 @@
|
||||||
'use strict';
|
|
||||||
|
|
||||||
Object.defineProperty(exports, "__esModule", {
|
|
||||||
value: true
|
|
||||||
});
|
|
||||||
|
|
||||||
var _util = require('../util');
|
|
||||||
|
|
||||||
var util = _interopRequireWildcard(_util);
|
|
||||||
|
|
||||||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj['default'] = obj; return newObj; } }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Rule for validating minimum and maximum allowed values.
|
|
||||||
*
|
|
||||||
* @param rule The validation rule.
|
|
||||||
* @param value The value of the field on the source object.
|
|
||||||
* @param source The source object being validated.
|
|
||||||
* @param errors An array of errors that this rule may add
|
|
||||||
* validation errors to.
|
|
||||||
* @param options The validation options.
|
|
||||||
* @param options.messages The validation messages.
|
|
||||||
*/
|
|
||||||
function range(rule, value, source, errors, options) {
|
|
||||||
var len = typeof rule.len === 'number';
|
|
||||||
var min = typeof rule.min === 'number';
|
|
||||||
var max = typeof rule.max === 'number';
|
|
||||||
// 正则匹配码点范围从U+010000一直到U+10FFFF的文字(补充平面Supplementary Plane)
|
|
||||||
var spRegexp = /[\uD800-\uDBFF][\uDC00-\uDFFF]/g;
|
|
||||||
var val = value;
|
|
||||||
var key = null;
|
|
||||||
var num = typeof value === 'number';
|
|
||||||
var str = typeof value === 'string';
|
|
||||||
var arr = Array.isArray(value);
|
|
||||||
if (num) {
|
|
||||||
key = 'number';
|
|
||||||
} else if (str) {
|
|
||||||
key = 'string';
|
|
||||||
} else if (arr) {
|
|
||||||
key = 'array';
|
|
||||||
}
|
|
||||||
// if the value is not of a supported type for range validation
|
|
||||||
// the validation rule rule should use the
|
|
||||||
// type property to also test for a particular type
|
|
||||||
if (!key) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (arr) {
|
|
||||||
val = value.length;
|
|
||||||
}
|
|
||||||
if (str) {
|
|
||||||
// 处理码点大于U+010000的文字length属性不准确的bug,如"𠮷𠮷𠮷".lenght !== 3
|
|
||||||
val = value.replace(spRegexp, '_').length;
|
|
||||||
}
|
|
||||||
if (len) {
|
|
||||||
if (val !== rule.len) {
|
|
||||||
errors.push(util.format(options.messages[key].len, rule.fullField, rule.len));
|
|
||||||
}
|
|
||||||
} else if (min && !max && val < rule.min) {
|
|
||||||
errors.push(util.format(options.messages[key].min, rule.fullField, rule.min));
|
|
||||||
} else if (max && !min && val > rule.max) {
|
|
||||||
errors.push(util.format(options.messages[key].max, rule.fullField, rule.max));
|
|
||||||
} else if (min && max && (val < rule.min || val > rule.max)) {
|
|
||||||
errors.push(util.format(options.messages[key].range, rule.fullField, rule.min, rule.max));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
exports['default'] = range;
|
|
|
@ -1,30 +0,0 @@
|
||||||
'use strict';
|
|
||||||
|
|
||||||
Object.defineProperty(exports, "__esModule", {
|
|
||||||
value: true
|
|
||||||
});
|
|
||||||
|
|
||||||
var _util = require('../util');
|
|
||||||
|
|
||||||
var util = _interopRequireWildcard(_util);
|
|
||||||
|
|
||||||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj['default'] = obj; return newObj; } }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Rule for validating required fields.
|
|
||||||
*
|
|
||||||
* @param rule The validation rule.
|
|
||||||
* @param value The value of the field on the source object.
|
|
||||||
* @param source The source object being validated.
|
|
||||||
* @param errors An array of errors that this rule may add
|
|
||||||
* validation errors to.
|
|
||||||
* @param options The validation options.
|
|
||||||
* @param options.messages The validation messages.
|
|
||||||
*/
|
|
||||||
function required(rule, value, source, errors, options, type) {
|
|
||||||
if (rule.required && (!source.hasOwnProperty(rule.field) || util.isEmptyValue(value, type || rule.type))) {
|
|
||||||
errors.push(util.format(options.messages.required, rule.fullField));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
exports['default'] = required;
|
|
|
@ -1,104 +0,0 @@
|
||||||
'use strict';
|
|
||||||
|
|
||||||
Object.defineProperty(exports, "__esModule", {
|
|
||||||
value: true
|
|
||||||
});
|
|
||||||
|
|
||||||
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
|
|
||||||
|
|
||||||
var _util = require('../util');
|
|
||||||
|
|
||||||
var util = _interopRequireWildcard(_util);
|
|
||||||
|
|
||||||
var _required = require('./required');
|
|
||||||
|
|
||||||
var _required2 = _interopRequireDefault(_required);
|
|
||||||
|
|
||||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
|
|
||||||
|
|
||||||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj['default'] = obj; return newObj; } }
|
|
||||||
|
|
||||||
/* eslint max-len:0 */
|
|
||||||
|
|
||||||
var pattern = {
|
|
||||||
// http://emailregex.com/
|
|
||||||
email: /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/,
|
|
||||||
url: new RegExp('^(?!mailto:)(?:(?:http|https|ftp)://|//)(?:\\S+(?::\\S*)?@)?(?:(?:(?:[1-9]\\d?|1\\d\\d|2[01]\\d|22[0-3])(?:\\.(?:1?\\d{1,2}|2[0-4]\\d|25[0-5])){2}(?:\\.(?:[0-9]\\d?|1\\d\\d|2[0-4]\\d|25[0-4]))|(?:(?:[a-z\\u00a1-\\uffff0-9]+-?)*[a-z\\u00a1-\\uffff0-9]+)(?:\\.(?:[a-z\\u00a1-\\uffff0-9]+-?)*[a-z\\u00a1-\\uffff0-9]+)*(?:\\.(?:[a-z\\u00a1-\\uffff]{2,})))|localhost)(?::\\d{2,5})?(?:(/|\\?|#)[^\\s]*)?$', 'i'),
|
|
||||||
hex: /^#?([a-f0-9]{6}|[a-f0-9]{3})$/i
|
|
||||||
};
|
|
||||||
|
|
||||||
var types = {
|
|
||||||
integer: function integer(value) {
|
|
||||||
return types.number(value) && parseInt(value, 10) === value;
|
|
||||||
},
|
|
||||||
float: function float(value) {
|
|
||||||
return types.number(value) && !types.integer(value);
|
|
||||||
},
|
|
||||||
array: function array(value) {
|
|
||||||
return Array.isArray(value);
|
|
||||||
},
|
|
||||||
regexp: function regexp(value) {
|
|
||||||
if (value instanceof RegExp) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
return !!new RegExp(value);
|
|
||||||
} catch (e) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
date: function date(value) {
|
|
||||||
return typeof value.getTime === 'function' && typeof value.getMonth === 'function' && typeof value.getYear === 'function';
|
|
||||||
},
|
|
||||||
number: function number(value) {
|
|
||||||
if (isNaN(value)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return typeof value === 'number';
|
|
||||||
},
|
|
||||||
object: function object(value) {
|
|
||||||
return (typeof value === 'undefined' ? 'undefined' : _typeof(value)) === 'object' && !types.array(value);
|
|
||||||
},
|
|
||||||
method: function method(value) {
|
|
||||||
return typeof value === 'function';
|
|
||||||
},
|
|
||||||
email: function email(value) {
|
|
||||||
return typeof value === 'string' && !!value.match(pattern.email) && value.length < 255;
|
|
||||||
},
|
|
||||||
url: function url(value) {
|
|
||||||
return typeof value === 'string' && !!value.match(pattern.url);
|
|
||||||
},
|
|
||||||
hex: function hex(value) {
|
|
||||||
return typeof value === 'string' && !!value.match(pattern.hex);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Rule for validating the type of a value.
|
|
||||||
*
|
|
||||||
* @param rule The validation rule.
|
|
||||||
* @param value The value of the field on the source object.
|
|
||||||
* @param source The source object being validated.
|
|
||||||
* @param errors An array of errors that this rule may add
|
|
||||||
* validation errors to.
|
|
||||||
* @param options The validation options.
|
|
||||||
* @param options.messages The validation messages.
|
|
||||||
*/
|
|
||||||
function type(rule, value, source, errors, options) {
|
|
||||||
if (rule.required && value === undefined) {
|
|
||||||
(0, _required2['default'])(rule, value, source, errors, options);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
var custom = ['integer', 'float', 'array', 'regexp', 'object', 'method', 'email', 'number', 'date', 'url', 'hex'];
|
|
||||||
var ruleType = rule.type;
|
|
||||||
if (custom.indexOf(ruleType) > -1) {
|
|
||||||
if (!types[ruleType](value)) {
|
|
||||||
errors.push(util.format(options.messages.types[ruleType], rule.fullField, rule.type));
|
|
||||||
}
|
|
||||||
// straight typeof check
|
|
||||||
} else if (ruleType && (typeof value === 'undefined' ? 'undefined' : _typeof(value)) !== rule.type) {
|
|
||||||
errors.push(util.format(options.messages.types[ruleType], rule.fullField, rule.type));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
exports['default'] = type;
|
|
|
@ -1,30 +0,0 @@
|
||||||
'use strict';
|
|
||||||
|
|
||||||
Object.defineProperty(exports, "__esModule", {
|
|
||||||
value: true
|
|
||||||
});
|
|
||||||
|
|
||||||
var _util = require('../util');
|
|
||||||
|
|
||||||
var util = _interopRequireWildcard(_util);
|
|
||||||
|
|
||||||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj['default'] = obj; return newObj; } }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Rule for validating whitespace.
|
|
||||||
*
|
|
||||||
* @param rule The validation rule.
|
|
||||||
* @param value The value of the field on the source object.
|
|
||||||
* @param source The source object being validated.
|
|
||||||
* @param errors An array of errors that this rule may add
|
|
||||||
* validation errors to.
|
|
||||||
* @param options The validation options.
|
|
||||||
* @param options.messages The validation messages.
|
|
||||||
*/
|
|
||||||
function whitespace(rule, value, source, errors, options) {
|
|
||||||
if (/^\s+$/.test(value) || value === '') {
|
|
||||||
errors.push(util.format(options.messages.whitespace, rule.fullField));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
exports['default'] = whitespace;
|
|
|
@ -1,223 +0,0 @@
|
||||||
'use strict';
|
|
||||||
|
|
||||||
Object.defineProperty(exports, "__esModule", {
|
|
||||||
value: true
|
|
||||||
});
|
|
||||||
|
|
||||||
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
|
|
||||||
|
|
||||||
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
|
|
||||||
|
|
||||||
exports.convertFieldsError = convertFieldsError;
|
|
||||||
exports.format = format;
|
|
||||||
exports.isEmptyValue = isEmptyValue;
|
|
||||||
exports.isEmptyObject = isEmptyObject;
|
|
||||||
exports.asyncMap = asyncMap;
|
|
||||||
exports.complementError = complementError;
|
|
||||||
exports.deepMerge = deepMerge;
|
|
||||||
/* eslint no-console:0 */
|
|
||||||
|
|
||||||
var formatRegExp = /%[sdj%]/g;
|
|
||||||
|
|
||||||
var warning = exports.warning = function warning() {};
|
|
||||||
|
|
||||||
// don't print warning message when in production env or node runtime
|
|
||||||
if (process.env.NODE_ENV !== 'production' && typeof window !== 'undefined' && typeof document !== 'undefined') {
|
|
||||||
exports.warning = warning = function warning(type, errors) {
|
|
||||||
if (typeof console !== 'undefined' && console.warn) {
|
|
||||||
if (errors.every(function (e) {
|
|
||||||
return typeof e === 'string';
|
|
||||||
})) {
|
|
||||||
console.warn(type, errors);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
function convertFieldsError(errors) {
|
|
||||||
if (!errors || !errors.length) return null;
|
|
||||||
var fields = {};
|
|
||||||
errors.forEach(function (error) {
|
|
||||||
var field = error.field;
|
|
||||||
fields[field] = fields[field] || [];
|
|
||||||
fields[field].push(error);
|
|
||||||
});
|
|
||||||
return fields;
|
|
||||||
}
|
|
||||||
|
|
||||||
function format() {
|
|
||||||
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
|
|
||||||
args[_key] = arguments[_key];
|
|
||||||
}
|
|
||||||
|
|
||||||
var i = 1;
|
|
||||||
var f = args[0];
|
|
||||||
var len = args.length;
|
|
||||||
if (typeof f === 'function') {
|
|
||||||
return f.apply(null, args.slice(1));
|
|
||||||
}
|
|
||||||
if (typeof f === 'string') {
|
|
||||||
var str = String(f).replace(formatRegExp, function (x) {
|
|
||||||
if (x === '%%') {
|
|
||||||
return '%';
|
|
||||||
}
|
|
||||||
if (i >= len) {
|
|
||||||
return x;
|
|
||||||
}
|
|
||||||
switch (x) {
|
|
||||||
case '%s':
|
|
||||||
return String(args[i++]);
|
|
||||||
case '%d':
|
|
||||||
return Number(args[i++]);
|
|
||||||
case '%j':
|
|
||||||
try {
|
|
||||||
return JSON.stringify(args[i++]);
|
|
||||||
} catch (_) {
|
|
||||||
return '[Circular]';
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return x;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
for (var arg = args[i]; i < len; arg = args[++i]) {
|
|
||||||
str += ' ' + arg;
|
|
||||||
}
|
|
||||||
return str;
|
|
||||||
}
|
|
||||||
return f;
|
|
||||||
}
|
|
||||||
|
|
||||||
function isNativeStringType(type) {
|
|
||||||
return type === 'string' || type === 'url' || type === 'hex' || type === 'email' || type === 'pattern';
|
|
||||||
}
|
|
||||||
|
|
||||||
function isEmptyValue(value, type) {
|
|
||||||
if (value === undefined || value === null) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (type === 'array' && Array.isArray(value) && !value.length) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (isNativeStringType(type) && typeof value === 'string' && !value) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
function isEmptyObject(obj) {
|
|
||||||
return Object.keys(obj).length === 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
function asyncParallelArray(arr, func, callback) {
|
|
||||||
var results = [];
|
|
||||||
var total = 0;
|
|
||||||
var arrLength = arr.length;
|
|
||||||
|
|
||||||
function count(errors) {
|
|
||||||
results.push.apply(results, errors);
|
|
||||||
total++;
|
|
||||||
if (total === arrLength) {
|
|
||||||
callback(results);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
arr.forEach(function (a) {
|
|
||||||
func(a, count);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function asyncSerialArray(arr, func, callback) {
|
|
||||||
var index = 0;
|
|
||||||
var arrLength = arr.length;
|
|
||||||
|
|
||||||
function next(errors) {
|
|
||||||
if (errors && errors.length) {
|
|
||||||
callback(errors);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
var original = index;
|
|
||||||
index = index + 1;
|
|
||||||
if (original < arrLength) {
|
|
||||||
func(arr[original], next);
|
|
||||||
} else {
|
|
||||||
callback([]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
next([]);
|
|
||||||
}
|
|
||||||
|
|
||||||
function flattenObjArr(objArr) {
|
|
||||||
var ret = [];
|
|
||||||
Object.keys(objArr).forEach(function (k) {
|
|
||||||
ret.push.apply(ret, objArr[k]);
|
|
||||||
});
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
function asyncMap(objArr, option, func, callback) {
|
|
||||||
if (option.first) {
|
|
||||||
var flattenArr = flattenObjArr(objArr);
|
|
||||||
return asyncSerialArray(flattenArr, func, callback);
|
|
||||||
}
|
|
||||||
var firstFields = option.firstFields || [];
|
|
||||||
if (firstFields === true) {
|
|
||||||
firstFields = Object.keys(objArr);
|
|
||||||
}
|
|
||||||
var objArrKeys = Object.keys(objArr);
|
|
||||||
var objArrLength = objArrKeys.length;
|
|
||||||
var total = 0;
|
|
||||||
var results = [];
|
|
||||||
var pending = new Promise(function (resolve, reject) {
|
|
||||||
var next = function next(errors) {
|
|
||||||
results.push.apply(results, errors);
|
|
||||||
total++;
|
|
||||||
if (total === objArrLength) {
|
|
||||||
callback(results);
|
|
||||||
return results.length ? reject({ errors: results, fields: convertFieldsError(results) }) : resolve();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
objArrKeys.forEach(function (key) {
|
|
||||||
var arr = objArr[key];
|
|
||||||
if (firstFields.indexOf(key) !== -1) {
|
|
||||||
asyncSerialArray(arr, func, next);
|
|
||||||
} else {
|
|
||||||
asyncParallelArray(arr, func, next);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
pending['catch'](function (e) {
|
|
||||||
return e;
|
|
||||||
});
|
|
||||||
return pending;
|
|
||||||
}
|
|
||||||
|
|
||||||
function complementError(rule) {
|
|
||||||
return function (oe) {
|
|
||||||
if (oe && oe.message) {
|
|
||||||
oe.field = oe.field || rule.fullField;
|
|
||||||
return oe;
|
|
||||||
}
|
|
||||||
return {
|
|
||||||
message: typeof oe === 'function' ? oe() : oe,
|
|
||||||
field: oe.field || rule.fullField
|
|
||||||
};
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
function deepMerge(target, source) {
|
|
||||||
if (source) {
|
|
||||||
for (var s in source) {
|
|
||||||
if (source.hasOwnProperty(s)) {
|
|
||||||
var value = source[s];
|
|
||||||
if ((typeof value === 'undefined' ? 'undefined' : _typeof(value)) === 'object' && _typeof(target[s]) === 'object') {
|
|
||||||
target[s] = _extends({}, target[s], value);
|
|
||||||
} else {
|
|
||||||
target[s] = value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return target;
|
|
||||||
}
|
|
|
@ -1,41 +0,0 @@
|
||||||
'use strict';
|
|
||||||
|
|
||||||
Object.defineProperty(exports, "__esModule", {
|
|
||||||
value: true
|
|
||||||
});
|
|
||||||
|
|
||||||
var _rule = require('../rule/');
|
|
||||||
|
|
||||||
var _rule2 = _interopRequireDefault(_rule);
|
|
||||||
|
|
||||||
var _util = require('../util');
|
|
||||||
|
|
||||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Validates an array.
|
|
||||||
*
|
|
||||||
* @param rule The validation rule.
|
|
||||||
* @param value The value of the field on the source object.
|
|
||||||
* @param callback The callback function.
|
|
||||||
* @param source The source object being validated.
|
|
||||||
* @param options The validation options.
|
|
||||||
* @param options.messages The validation messages.
|
|
||||||
*/
|
|
||||||
function array(rule, value, callback, source, options) {
|
|
||||||
var errors = [];
|
|
||||||
var validate = rule.required || !rule.required && source.hasOwnProperty(rule.field);
|
|
||||||
if (validate) {
|
|
||||||
if ((0, _util.isEmptyValue)(value, 'array') && !rule.required) {
|
|
||||||
return callback();
|
|
||||||
}
|
|
||||||
_rule2['default'].required(rule, value, source, errors, options, 'array');
|
|
||||||
if (!(0, _util.isEmptyValue)(value, 'array')) {
|
|
||||||
_rule2['default'].type(rule, value, source, errors, options);
|
|
||||||
_rule2['default'].range(rule, value, source, errors, options);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
callback(errors);
|
|
||||||
}
|
|
||||||
|
|
||||||
exports['default'] = array;
|
|
|
@ -1,40 +0,0 @@
|
||||||
'use strict';
|
|
||||||
|
|
||||||
Object.defineProperty(exports, "__esModule", {
|
|
||||||
value: true
|
|
||||||
});
|
|
||||||
|
|
||||||
var _util = require('../util');
|
|
||||||
|
|
||||||
var _rule = require('../rule/');
|
|
||||||
|
|
||||||
var _rule2 = _interopRequireDefault(_rule);
|
|
||||||
|
|
||||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Validates a boolean.
|
|
||||||
*
|
|
||||||
* @param rule The validation rule.
|
|
||||||
* @param value The value of the field on the source object.
|
|
||||||
* @param callback The callback function.
|
|
||||||
* @param source The source object being validated.
|
|
||||||
* @param options The validation options.
|
|
||||||
* @param options.messages The validation messages.
|
|
||||||
*/
|
|
||||||
function boolean(rule, value, callback, source, options) {
|
|
||||||
var errors = [];
|
|
||||||
var validate = rule.required || !rule.required && source.hasOwnProperty(rule.field);
|
|
||||||
if (validate) {
|
|
||||||
if ((0, _util.isEmptyValue)(value) && !rule.required) {
|
|
||||||
return callback();
|
|
||||||
}
|
|
||||||
_rule2['default'].required(rule, value, source, errors, options);
|
|
||||||
if (value !== undefined) {
|
|
||||||
_rule2['default'].type(rule, value, source, errors, options);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
callback(errors);
|
|
||||||
}
|
|
||||||
|
|
||||||
exports['default'] = boolean;
|
|
|
@ -1,43 +0,0 @@
|
||||||
'use strict';
|
|
||||||
|
|
||||||
Object.defineProperty(exports, "__esModule", {
|
|
||||||
value: true
|
|
||||||
});
|
|
||||||
|
|
||||||
var _rule = require('../rule/');
|
|
||||||
|
|
||||||
var _rule2 = _interopRequireDefault(_rule);
|
|
||||||
|
|
||||||
var _util = require('../util');
|
|
||||||
|
|
||||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
|
|
||||||
|
|
||||||
function date(rule, value, callback, source, options) {
|
|
||||||
// console.log('integer rule called %j', rule);
|
|
||||||
var errors = [];
|
|
||||||
var validate = rule.required || !rule.required && source.hasOwnProperty(rule.field);
|
|
||||||
// console.log('validate on %s value', value);
|
|
||||||
if (validate) {
|
|
||||||
if ((0, _util.isEmptyValue)(value) && !rule.required) {
|
|
||||||
return callback();
|
|
||||||
}
|
|
||||||
_rule2['default'].required(rule, value, source, errors, options);
|
|
||||||
if (!(0, _util.isEmptyValue)(value)) {
|
|
||||||
var dateObject = void 0;
|
|
||||||
|
|
||||||
if (typeof value === 'number') {
|
|
||||||
dateObject = new Date(value);
|
|
||||||
} else {
|
|
||||||
dateObject = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
_rule2['default'].type(rule, dateObject, source, errors, options);
|
|
||||||
if (dateObject) {
|
|
||||||
_rule2['default'].range(rule, dateObject.getTime(), source, errors, options);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
callback(errors);
|
|
||||||
}
|
|
||||||
|
|
||||||
exports['default'] = date;
|
|
|
@ -1,42 +0,0 @@
|
||||||
'use strict';
|
|
||||||
|
|
||||||
Object.defineProperty(exports, "__esModule", {
|
|
||||||
value: true
|
|
||||||
});
|
|
||||||
|
|
||||||
var _rule = require('../rule/');
|
|
||||||
|
|
||||||
var _rule2 = _interopRequireDefault(_rule);
|
|
||||||
|
|
||||||
var _util = require('../util');
|
|
||||||
|
|
||||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
|
|
||||||
|
|
||||||
var ENUM = 'enum';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Validates an enumerable list.
|
|
||||||
*
|
|
||||||
* @param rule The validation rule.
|
|
||||||
* @param value The value of the field on the source object.
|
|
||||||
* @param callback The callback function.
|
|
||||||
* @param source The source object being validated.
|
|
||||||
* @param options The validation options.
|
|
||||||
* @param options.messages The validation messages.
|
|
||||||
*/
|
|
||||||
function enumerable(rule, value, callback, source, options) {
|
|
||||||
var errors = [];
|
|
||||||
var validate = rule.required || !rule.required && source.hasOwnProperty(rule.field);
|
|
||||||
if (validate) {
|
|
||||||
if ((0, _util.isEmptyValue)(value) && !rule.required) {
|
|
||||||
return callback();
|
|
||||||
}
|
|
||||||
_rule2['default'].required(rule, value, source, errors, options);
|
|
||||||
if (value) {
|
|
||||||
_rule2['default'][ENUM](rule, value, source, errors, options);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
callback(errors);
|
|
||||||
}
|
|
||||||
|
|
||||||
exports['default'] = enumerable;
|
|
|
@ -1,41 +0,0 @@
|
||||||
'use strict';
|
|
||||||
|
|
||||||
Object.defineProperty(exports, "__esModule", {
|
|
||||||
value: true
|
|
||||||
});
|
|
||||||
|
|
||||||
var _rule = require('../rule/');
|
|
||||||
|
|
||||||
var _rule2 = _interopRequireDefault(_rule);
|
|
||||||
|
|
||||||
var _util = require('../util');
|
|
||||||
|
|
||||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Validates a number is a floating point number.
|
|
||||||
*
|
|
||||||
* @param rule The validation rule.
|
|
||||||
* @param value The value of the field on the source object.
|
|
||||||
* @param callback The callback function.
|
|
||||||
* @param source The source object being validated.
|
|
||||||
* @param options The validation options.
|
|
||||||
* @param options.messages The validation messages.
|
|
||||||
*/
|
|
||||||
function floatFn(rule, value, callback, source, options) {
|
|
||||||
var errors = [];
|
|
||||||
var validate = rule.required || !rule.required && source.hasOwnProperty(rule.field);
|
|
||||||
if (validate) {
|
|
||||||
if ((0, _util.isEmptyValue)(value) && !rule.required) {
|
|
||||||
return callback();
|
|
||||||
}
|
|
||||||
_rule2['default'].required(rule, value, source, errors, options);
|
|
||||||
if (value !== undefined) {
|
|
||||||
_rule2['default'].type(rule, value, source, errors, options);
|
|
||||||
_rule2['default'].range(rule, value, source, errors, options);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
callback(errors);
|
|
||||||
}
|
|
||||||
|
|
||||||
exports['default'] = floatFn;
|
|
|
@ -1,82 +0,0 @@
|
||||||
'use strict';
|
|
||||||
|
|
||||||
Object.defineProperty(exports, "__esModule", {
|
|
||||||
value: true
|
|
||||||
});
|
|
||||||
|
|
||||||
var _string = require('./string');
|
|
||||||
|
|
||||||
var _string2 = _interopRequireDefault(_string);
|
|
||||||
|
|
||||||
var _method = require('./method');
|
|
||||||
|
|
||||||
var _method2 = _interopRequireDefault(_method);
|
|
||||||
|
|
||||||
var _number = require('./number');
|
|
||||||
|
|
||||||
var _number2 = _interopRequireDefault(_number);
|
|
||||||
|
|
||||||
var _boolean = require('./boolean');
|
|
||||||
|
|
||||||
var _boolean2 = _interopRequireDefault(_boolean);
|
|
||||||
|
|
||||||
var _regexp = require('./regexp');
|
|
||||||
|
|
||||||
var _regexp2 = _interopRequireDefault(_regexp);
|
|
||||||
|
|
||||||
var _integer = require('./integer');
|
|
||||||
|
|
||||||
var _integer2 = _interopRequireDefault(_integer);
|
|
||||||
|
|
||||||
var _float = require('./float');
|
|
||||||
|
|
||||||
var _float2 = _interopRequireDefault(_float);
|
|
||||||
|
|
||||||
var _array = require('./array');
|
|
||||||
|
|
||||||
var _array2 = _interopRequireDefault(_array);
|
|
||||||
|
|
||||||
var _object = require('./object');
|
|
||||||
|
|
||||||
var _object2 = _interopRequireDefault(_object);
|
|
||||||
|
|
||||||
var _enum = require('./enum');
|
|
||||||
|
|
||||||
var _enum2 = _interopRequireDefault(_enum);
|
|
||||||
|
|
||||||
var _pattern = require('./pattern');
|
|
||||||
|
|
||||||
var _pattern2 = _interopRequireDefault(_pattern);
|
|
||||||
|
|
||||||
var _date = require('./date');
|
|
||||||
|
|
||||||
var _date2 = _interopRequireDefault(_date);
|
|
||||||
|
|
||||||
var _required = require('./required');
|
|
||||||
|
|
||||||
var _required2 = _interopRequireDefault(_required);
|
|
||||||
|
|
||||||
var _type = require('./type');
|
|
||||||
|
|
||||||
var _type2 = _interopRequireDefault(_type);
|
|
||||||
|
|
||||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
|
|
||||||
|
|
||||||
exports['default'] = {
|
|
||||||
string: _string2['default'],
|
|
||||||
method: _method2['default'],
|
|
||||||
number: _number2['default'],
|
|
||||||
boolean: _boolean2['default'],
|
|
||||||
regexp: _regexp2['default'],
|
|
||||||
integer: _integer2['default'],
|
|
||||||
float: _float2['default'],
|
|
||||||
array: _array2['default'],
|
|
||||||
object: _object2['default'],
|
|
||||||
'enum': _enum2['default'],
|
|
||||||
pattern: _pattern2['default'],
|
|
||||||
date: _date2['default'],
|
|
||||||
url: _type2['default'],
|
|
||||||
hex: _type2['default'],
|
|
||||||
email: _type2['default'],
|
|
||||||
required: _required2['default']
|
|
||||||
};
|
|
|
@ -1,41 +0,0 @@
|
||||||
'use strict';
|
|
||||||
|
|
||||||
Object.defineProperty(exports, "__esModule", {
|
|
||||||
value: true
|
|
||||||
});
|
|
||||||
|
|
||||||
var _rule = require('../rule/');
|
|
||||||
|
|
||||||
var _rule2 = _interopRequireDefault(_rule);
|
|
||||||
|
|
||||||
var _util = require('../util');
|
|
||||||
|
|
||||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Validates a number is an integer.
|
|
||||||
*
|
|
||||||
* @param rule The validation rule.
|
|
||||||
* @param value The value of the field on the source object.
|
|
||||||
* @param callback The callback function.
|
|
||||||
* @param source The source object being validated.
|
|
||||||
* @param options The validation options.
|
|
||||||
* @param options.messages The validation messages.
|
|
||||||
*/
|
|
||||||
function integer(rule, value, callback, source, options) {
|
|
||||||
var errors = [];
|
|
||||||
var validate = rule.required || !rule.required && source.hasOwnProperty(rule.field);
|
|
||||||
if (validate) {
|
|
||||||
if ((0, _util.isEmptyValue)(value) && !rule.required) {
|
|
||||||
return callback();
|
|
||||||
}
|
|
||||||
_rule2['default'].required(rule, value, source, errors, options);
|
|
||||||
if (value !== undefined) {
|
|
||||||
_rule2['default'].type(rule, value, source, errors, options);
|
|
||||||
_rule2['default'].range(rule, value, source, errors, options);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
callback(errors);
|
|
||||||
}
|
|
||||||
|
|
||||||
exports['default'] = integer;
|
|
|
@ -1,40 +0,0 @@
|
||||||
'use strict';
|
|
||||||
|
|
||||||
Object.defineProperty(exports, "__esModule", {
|
|
||||||
value: true
|
|
||||||
});
|
|
||||||
|
|
||||||
var _rule = require('../rule/');
|
|
||||||
|
|
||||||
var _rule2 = _interopRequireDefault(_rule);
|
|
||||||
|
|
||||||
var _util = require('../util');
|
|
||||||
|
|
||||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Validates a function.
|
|
||||||
*
|
|
||||||
* @param rule The validation rule.
|
|
||||||
* @param value The value of the field on the source object.
|
|
||||||
* @param callback The callback function.
|
|
||||||
* @param source The source object being validated.
|
|
||||||
* @param options The validation options.
|
|
||||||
* @param options.messages The validation messages.
|
|
||||||
*/
|
|
||||||
function method(rule, value, callback, source, options) {
|
|
||||||
var errors = [];
|
|
||||||
var validate = rule.required || !rule.required && source.hasOwnProperty(rule.field);
|
|
||||||
if (validate) {
|
|
||||||
if ((0, _util.isEmptyValue)(value) && !rule.required) {
|
|
||||||
return callback();
|
|
||||||
}
|
|
||||||
_rule2['default'].required(rule, value, source, errors, options);
|
|
||||||
if (value !== undefined) {
|
|
||||||
_rule2['default'].type(rule, value, source, errors, options);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
callback(errors);
|
|
||||||
}
|
|
||||||
|
|
||||||
exports['default'] = method;
|
|
|
@ -1,44 +0,0 @@
|
||||||
'use strict';
|
|
||||||
|
|
||||||
Object.defineProperty(exports, "__esModule", {
|
|
||||||
value: true
|
|
||||||
});
|
|
||||||
|
|
||||||
var _rule = require('../rule/');
|
|
||||||
|
|
||||||
var _rule2 = _interopRequireDefault(_rule);
|
|
||||||
|
|
||||||
var _util = require('../util');
|
|
||||||
|
|
||||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Validates a number.
|
|
||||||
*
|
|
||||||
* @param rule The validation rule.
|
|
||||||
* @param value The value of the field on the source object.
|
|
||||||
* @param callback The callback function.
|
|
||||||
* @param source The source object being validated.
|
|
||||||
* @param options The validation options.
|
|
||||||
* @param options.messages The validation messages.
|
|
||||||
*/
|
|
||||||
function number(rule, value, callback, source, options) {
|
|
||||||
var errors = [];
|
|
||||||
var validate = rule.required || !rule.required && source.hasOwnProperty(rule.field);
|
|
||||||
if (validate) {
|
|
||||||
if (value === '') {
|
|
||||||
value = undefined;
|
|
||||||
}
|
|
||||||
if ((0, _util.isEmptyValue)(value) && !rule.required) {
|
|
||||||
return callback();
|
|
||||||
}
|
|
||||||
_rule2['default'].required(rule, value, source, errors, options);
|
|
||||||
if (value !== undefined) {
|
|
||||||
_rule2['default'].type(rule, value, source, errors, options);
|
|
||||||
_rule2['default'].range(rule, value, source, errors, options);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
callback(errors);
|
|
||||||
}
|
|
||||||
|
|
||||||
exports['default'] = number;
|
|
|
@ -1,40 +0,0 @@
|
||||||
'use strict';
|
|
||||||
|
|
||||||
Object.defineProperty(exports, "__esModule", {
|
|
||||||
value: true
|
|
||||||
});
|
|
||||||
|
|
||||||
var _rule = require('../rule/');
|
|
||||||
|
|
||||||
var _rule2 = _interopRequireDefault(_rule);
|
|
||||||
|
|
||||||
var _util = require('../util');
|
|
||||||
|
|
||||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Validates an object.
|
|
||||||
*
|
|
||||||
* @param rule The validation rule.
|
|
||||||
* @param value The value of the field on the source object.
|
|
||||||
* @param callback The callback function.
|
|
||||||
* @param source The source object being validated.
|
|
||||||
* @param options The validation options.
|
|
||||||
* @param options.messages The validation messages.
|
|
||||||
*/
|
|
||||||
function object(rule, value, callback, source, options) {
|
|
||||||
var errors = [];
|
|
||||||
var validate = rule.required || !rule.required && source.hasOwnProperty(rule.field);
|
|
||||||
if (validate) {
|
|
||||||
if ((0, _util.isEmptyValue)(value) && !rule.required) {
|
|
||||||
return callback();
|
|
||||||
}
|
|
||||||
_rule2['default'].required(rule, value, source, errors, options);
|
|
||||||
if (value !== undefined) {
|
|
||||||
_rule2['default'].type(rule, value, source, errors, options);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
callback(errors);
|
|
||||||
}
|
|
||||||
|
|
||||||
exports['default'] = object;
|
|
|
@ -1,43 +0,0 @@
|
||||||
'use strict';
|
|
||||||
|
|
||||||
Object.defineProperty(exports, "__esModule", {
|
|
||||||
value: true
|
|
||||||
});
|
|
||||||
|
|
||||||
var _rule = require('../rule/');
|
|
||||||
|
|
||||||
var _rule2 = _interopRequireDefault(_rule);
|
|
||||||
|
|
||||||
var _util = require('../util');
|
|
||||||
|
|
||||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Validates a regular expression pattern.
|
|
||||||
*
|
|
||||||
* Performs validation when a rule only contains
|
|
||||||
* a pattern property but is not declared as a string type.
|
|
||||||
*
|
|
||||||
* @param rule The validation rule.
|
|
||||||
* @param value The value of the field on the source object.
|
|
||||||
* @param callback The callback function.
|
|
||||||
* @param source The source object being validated.
|
|
||||||
* @param options The validation options.
|
|
||||||
* @param options.messages The validation messages.
|
|
||||||
*/
|
|
||||||
function pattern(rule, value, callback, source, options) {
|
|
||||||
var errors = [];
|
|
||||||
var validate = rule.required || !rule.required && source.hasOwnProperty(rule.field);
|
|
||||||
if (validate) {
|
|
||||||
if ((0, _util.isEmptyValue)(value, 'string') && !rule.required) {
|
|
||||||
return callback();
|
|
||||||
}
|
|
||||||
_rule2['default'].required(rule, value, source, errors, options);
|
|
||||||
if (!(0, _util.isEmptyValue)(value, 'string')) {
|
|
||||||
_rule2['default'].pattern(rule, value, source, errors, options);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
callback(errors);
|
|
||||||
}
|
|
||||||
|
|
||||||
exports['default'] = pattern;
|
|
|
@ -1,40 +0,0 @@
|
||||||
'use strict';
|
|
||||||
|
|
||||||
Object.defineProperty(exports, "__esModule", {
|
|
||||||
value: true
|
|
||||||
});
|
|
||||||
|
|
||||||
var _rule = require('../rule/');
|
|
||||||
|
|
||||||
var _rule2 = _interopRequireDefault(_rule);
|
|
||||||
|
|
||||||
var _util = require('../util');
|
|
||||||
|
|
||||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Validates the regular expression type.
|
|
||||||
*
|
|
||||||
* @param rule The validation rule.
|
|
||||||
* @param value The value of the field on the source object.
|
|
||||||
* @param callback The callback function.
|
|
||||||
* @param source The source object being validated.
|
|
||||||
* @param options The validation options.
|
|
||||||
* @param options.messages The validation messages.
|
|
||||||
*/
|
|
||||||
function regexp(rule, value, callback, source, options) {
|
|
||||||
var errors = [];
|
|
||||||
var validate = rule.required || !rule.required && source.hasOwnProperty(rule.field);
|
|
||||||
if (validate) {
|
|
||||||
if ((0, _util.isEmptyValue)(value) && !rule.required) {
|
|
||||||
return callback();
|
|
||||||
}
|
|
||||||
_rule2['default'].required(rule, value, source, errors, options);
|
|
||||||
if (!(0, _util.isEmptyValue)(value)) {
|
|
||||||
_rule2['default'].type(rule, value, source, errors, options);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
callback(errors);
|
|
||||||
}
|
|
||||||
|
|
||||||
exports['default'] = regexp;
|
|
|
@ -1,22 +0,0 @@
|
||||||
'use strict';
|
|
||||||
|
|
||||||
Object.defineProperty(exports, "__esModule", {
|
|
||||||
value: true
|
|
||||||
});
|
|
||||||
|
|
||||||
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
|
|
||||||
|
|
||||||
var _rule = require('../rule/');
|
|
||||||
|
|
||||||
var _rule2 = _interopRequireDefault(_rule);
|
|
||||||
|
|
||||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
|
|
||||||
|
|
||||||
function required(rule, value, callback, source, options) {
|
|
||||||
var errors = [];
|
|
||||||
var type = Array.isArray(value) ? 'array' : typeof value === 'undefined' ? 'undefined' : _typeof(value);
|
|
||||||
_rule2['default'].required(rule, value, source, errors, options, type);
|
|
||||||
callback(errors);
|
|
||||||
}
|
|
||||||
|
|
||||||
exports['default'] = required;
|
|
|
@ -1,45 +0,0 @@
|
||||||
'use strict';
|
|
||||||
|
|
||||||
Object.defineProperty(exports, "__esModule", {
|
|
||||||
value: true
|
|
||||||
});
|
|
||||||
|
|
||||||
var _rule = require('../rule/');
|
|
||||||
|
|
||||||
var _rule2 = _interopRequireDefault(_rule);
|
|
||||||
|
|
||||||
var _util = require('../util');
|
|
||||||
|
|
||||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Performs validation for string types.
|
|
||||||
*
|
|
||||||
* @param rule The validation rule.
|
|
||||||
* @param value The value of the field on the source object.
|
|
||||||
* @param callback The callback function.
|
|
||||||
* @param source The source object being validated.
|
|
||||||
* @param options The validation options.
|
|
||||||
* @param options.messages The validation messages.
|
|
||||||
*/
|
|
||||||
function string(rule, value, callback, source, options) {
|
|
||||||
var errors = [];
|
|
||||||
var validate = rule.required || !rule.required && source.hasOwnProperty(rule.field);
|
|
||||||
if (validate) {
|
|
||||||
if ((0, _util.isEmptyValue)(value, 'string') && !rule.required) {
|
|
||||||
return callback();
|
|
||||||
}
|
|
||||||
_rule2['default'].required(rule, value, source, errors, options, 'string');
|
|
||||||
if (!(0, _util.isEmptyValue)(value, 'string')) {
|
|
||||||
_rule2['default'].type(rule, value, source, errors, options);
|
|
||||||
_rule2['default'].range(rule, value, source, errors, options);
|
|
||||||
_rule2['default'].pattern(rule, value, source, errors, options);
|
|
||||||
if (rule.whitespace === true) {
|
|
||||||
_rule2['default'].whitespace(rule, value, source, errors, options);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
callback(errors);
|
|
||||||
}
|
|
||||||
|
|
||||||
exports['default'] = string;
|
|
|
@ -1,31 +0,0 @@
|
||||||
'use strict';
|
|
||||||
|
|
||||||
Object.defineProperty(exports, "__esModule", {
|
|
||||||
value: true
|
|
||||||
});
|
|
||||||
|
|
||||||
var _rule = require('../rule/');
|
|
||||||
|
|
||||||
var _rule2 = _interopRequireDefault(_rule);
|
|
||||||
|
|
||||||
var _util = require('../util');
|
|
||||||
|
|
||||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
|
|
||||||
|
|
||||||
function type(rule, value, callback, source, options) {
|
|
||||||
var ruleType = rule.type;
|
|
||||||
var errors = [];
|
|
||||||
var validate = rule.required || !rule.required && source.hasOwnProperty(rule.field);
|
|
||||||
if (validate) {
|
|
||||||
if ((0, _util.isEmptyValue)(value, ruleType) && !rule.required) {
|
|
||||||
return callback();
|
|
||||||
}
|
|
||||||
_rule2['default'].required(rule, value, source, errors, options, ruleType);
|
|
||||||
if (!(0, _util.isEmptyValue)(value, ruleType)) {
|
|
||||||
_rule2['default'].type(rule, value, source, errors, options);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
callback(errors);
|
|
||||||
}
|
|
||||||
|
|
||||||
exports['default'] = type;
|
|
|
@ -1,297 +0,0 @@
|
||||||
'use strict';
|
|
||||||
|
|
||||||
exports.__esModule = true;
|
|
||||||
|
|
||||||
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
|
|
||||||
|
|
||||||
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
|
|
||||||
|
|
||||||
var _util = require('./util');
|
|
||||||
|
|
||||||
var _validator = require('./validator/');
|
|
||||||
|
|
||||||
var _validator2 = _interopRequireDefault(_validator);
|
|
||||||
|
|
||||||
var _messages2 = require('./messages');
|
|
||||||
|
|
||||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Encapsulates a validation schema.
|
|
||||||
*
|
|
||||||
* @param descriptor An object declaring validation rules
|
|
||||||
* for this schema.
|
|
||||||
*/
|
|
||||||
function Schema(descriptor) {
|
|
||||||
this.rules = null;
|
|
||||||
this._messages = _messages2.messages;
|
|
||||||
this.define(descriptor);
|
|
||||||
}
|
|
||||||
|
|
||||||
Schema.prototype = {
|
|
||||||
messages: function messages(_messages) {
|
|
||||||
if (_messages) {
|
|
||||||
this._messages = (0, _util.deepMerge)((0, _messages2.newMessages)(), _messages);
|
|
||||||
}
|
|
||||||
return this._messages;
|
|
||||||
},
|
|
||||||
define: function define(rules) {
|
|
||||||
if (!rules) {
|
|
||||||
throw new Error('Cannot configure a schema with no rules');
|
|
||||||
}
|
|
||||||
if ((typeof rules === 'undefined' ? 'undefined' : _typeof(rules)) !== 'object' || Array.isArray(rules)) {
|
|
||||||
throw new Error('Rules must be an object');
|
|
||||||
}
|
|
||||||
this.rules = {};
|
|
||||||
var z = void 0;
|
|
||||||
var item = void 0;
|
|
||||||
for (z in rules) {
|
|
||||||
if (rules.hasOwnProperty(z)) {
|
|
||||||
item = rules[z];
|
|
||||||
this.rules[z] = Array.isArray(item) ? item : [item];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
validate: function validate(source_) {
|
|
||||||
var _this = this;
|
|
||||||
|
|
||||||
var o = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
||||||
var oc = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : function () {};
|
|
||||||
|
|
||||||
var source = source_;
|
|
||||||
var options = o;
|
|
||||||
var callback = oc;
|
|
||||||
if (typeof options === 'function') {
|
|
||||||
callback = options;
|
|
||||||
options = {};
|
|
||||||
}
|
|
||||||
if (!this.rules || Object.keys(this.rules).length === 0) {
|
|
||||||
if (callback) {
|
|
||||||
callback();
|
|
||||||
}
|
|
||||||
return Promise.resolve();
|
|
||||||
}
|
|
||||||
|
|
||||||
function complete(results) {
|
|
||||||
var i = void 0;
|
|
||||||
var errors = [];
|
|
||||||
var fields = {};
|
|
||||||
|
|
||||||
function add(e) {
|
|
||||||
if (Array.isArray(e)) {
|
|
||||||
var _errors;
|
|
||||||
|
|
||||||
errors = (_errors = errors).concat.apply(_errors, e);
|
|
||||||
} else {
|
|
||||||
errors.push(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (i = 0; i < results.length; i++) {
|
|
||||||
add(results[i]);
|
|
||||||
}
|
|
||||||
if (!errors.length) {
|
|
||||||
errors = null;
|
|
||||||
fields = null;
|
|
||||||
} else {
|
|
||||||
fields = (0, _util.convertFieldsError)(errors);
|
|
||||||
}
|
|
||||||
callback(errors, fields);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (options.messages) {
|
|
||||||
var messages = this.messages();
|
|
||||||
if (messages === _messages2.messages) {
|
|
||||||
messages = (0, _messages2.newMessages)();
|
|
||||||
}
|
|
||||||
(0, _util.deepMerge)(messages, options.messages);
|
|
||||||
options.messages = messages;
|
|
||||||
} else {
|
|
||||||
options.messages = this.messages();
|
|
||||||
}
|
|
||||||
var arr = void 0;
|
|
||||||
var value = void 0;
|
|
||||||
var series = {};
|
|
||||||
var keys = options.keys || Object.keys(this.rules);
|
|
||||||
keys.forEach(function (z) {
|
|
||||||
arr = _this.rules[z];
|
|
||||||
value = source[z];
|
|
||||||
arr.forEach(function (r) {
|
|
||||||
var rule = r;
|
|
||||||
if (typeof rule.transform === 'function') {
|
|
||||||
if (source === source_) {
|
|
||||||
source = _extends({}, source);
|
|
||||||
}
|
|
||||||
value = source[z] = rule.transform(value);
|
|
||||||
}
|
|
||||||
if (typeof rule === 'function') {
|
|
||||||
rule = {
|
|
||||||
validator: rule
|
|
||||||
};
|
|
||||||
} else {
|
|
||||||
rule = _extends({}, rule);
|
|
||||||
}
|
|
||||||
rule.validator = _this.getValidationMethod(rule);
|
|
||||||
rule.field = z;
|
|
||||||
rule.fullField = rule.fullField || z;
|
|
||||||
rule.type = _this.getType(rule);
|
|
||||||
if (!rule.validator) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
series[z] = series[z] || [];
|
|
||||||
series[z].push({
|
|
||||||
rule: rule,
|
|
||||||
value: value,
|
|
||||||
source: source,
|
|
||||||
field: z
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
var errorFields = {};
|
|
||||||
return (0, _util.asyncMap)(series, options, function (data, doIt) {
|
|
||||||
var rule = data.rule;
|
|
||||||
var deep = (rule.type === 'object' || rule.type === 'array') && (_typeof(rule.fields) === 'object' || _typeof(rule.defaultField) === 'object');
|
|
||||||
deep = deep && (rule.required || !rule.required && data.value);
|
|
||||||
rule.field = data.field;
|
|
||||||
|
|
||||||
function addFullfield(key, schema) {
|
|
||||||
return _extends({}, schema, {
|
|
||||||
fullField: rule.fullField + '.' + key
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function cb() {
|
|
||||||
var e = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
||||||
|
|
||||||
var errors = e;
|
|
||||||
if (!Array.isArray(errors)) {
|
|
||||||
errors = [errors];
|
|
||||||
}
|
|
||||||
if (!options.suppressWarning && errors.length) {
|
|
||||||
Schema.warning('async-validator:', errors);
|
|
||||||
}
|
|
||||||
if (errors.length && rule.message) {
|
|
||||||
errors = [].concat(rule.message);
|
|
||||||
}
|
|
||||||
|
|
||||||
errors = errors.map((0, _util.complementError)(rule));
|
|
||||||
|
|
||||||
if (options.first && errors.length) {
|
|
||||||
errorFields[rule.field] = 1;
|
|
||||||
return doIt(errors);
|
|
||||||
}
|
|
||||||
if (!deep) {
|
|
||||||
doIt(errors);
|
|
||||||
} else {
|
|
||||||
// if rule is required but the target object
|
|
||||||
// does not exist fail at the rule level and don't
|
|
||||||
// go deeper
|
|
||||||
if (rule.required && !data.value) {
|
|
||||||
if (rule.message) {
|
|
||||||
errors = [].concat(rule.message).map((0, _util.complementError)(rule));
|
|
||||||
} else if (options.error) {
|
|
||||||
errors = [options.error(rule, (0, _util.format)(options.messages.required, rule.field))];
|
|
||||||
} else {
|
|
||||||
errors = [];
|
|
||||||
}
|
|
||||||
return doIt(errors);
|
|
||||||
}
|
|
||||||
|
|
||||||
var fieldsSchema = {};
|
|
||||||
if (rule.defaultField) {
|
|
||||||
for (var k in data.value) {
|
|
||||||
if (data.value.hasOwnProperty(k)) {
|
|
||||||
fieldsSchema[k] = rule.defaultField;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fieldsSchema = _extends({}, fieldsSchema, data.rule.fields);
|
|
||||||
for (var f in fieldsSchema) {
|
|
||||||
if (fieldsSchema.hasOwnProperty(f)) {
|
|
||||||
var fieldSchema = Array.isArray(fieldsSchema[f]) ? fieldsSchema[f] : [fieldsSchema[f]];
|
|
||||||
fieldsSchema[f] = fieldSchema.map(addFullfield.bind(null, f));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
var schema = new Schema(fieldsSchema);
|
|
||||||
schema.messages(options.messages);
|
|
||||||
if (data.rule.options) {
|
|
||||||
data.rule.options.messages = options.messages;
|
|
||||||
data.rule.options.error = options.error;
|
|
||||||
}
|
|
||||||
schema.validate(data.value, data.rule.options || options, function (errs) {
|
|
||||||
var finalErrors = [];
|
|
||||||
if (errors && errors.length) {
|
|
||||||
finalErrors.push.apply(finalErrors, errors);
|
|
||||||
}
|
|
||||||
if (errs && errs.length) {
|
|
||||||
finalErrors.push.apply(finalErrors, errs);
|
|
||||||
}
|
|
||||||
doIt(finalErrors.length ? finalErrors : null);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var res = void 0;
|
|
||||||
if (rule.asyncValidator) {
|
|
||||||
res = rule.asyncValidator(rule, data.value, cb, data.source, options);
|
|
||||||
} else if (rule.validator) {
|
|
||||||
res = rule.validator(rule, data.value, cb, data.source, options);
|
|
||||||
if (res === true) {
|
|
||||||
cb();
|
|
||||||
} else if (res === false) {
|
|
||||||
cb(rule.message || rule.field + ' fails');
|
|
||||||
} else if (res instanceof Array) {
|
|
||||||
cb(res);
|
|
||||||
} else if (res instanceof Error) {
|
|
||||||
cb(res.message);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (res && res.then) {
|
|
||||||
res.then(function () {
|
|
||||||
return cb();
|
|
||||||
}, function (e) {
|
|
||||||
return cb(e);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}, function (results) {
|
|
||||||
complete(results);
|
|
||||||
});
|
|
||||||
},
|
|
||||||
getType: function getType(rule) {
|
|
||||||
if (rule.type === undefined && rule.pattern instanceof RegExp) {
|
|
||||||
rule.type = 'pattern';
|
|
||||||
}
|
|
||||||
if (typeof rule.validator !== 'function' && rule.type && !_validator2['default'].hasOwnProperty(rule.type)) {
|
|
||||||
throw new Error((0, _util.format)('Unknown rule type %s', rule.type));
|
|
||||||
}
|
|
||||||
return rule.type || 'string';
|
|
||||||
},
|
|
||||||
getValidationMethod: function getValidationMethod(rule) {
|
|
||||||
if (typeof rule.validator === 'function') {
|
|
||||||
return rule.validator;
|
|
||||||
}
|
|
||||||
var keys = Object.keys(rule);
|
|
||||||
var messageIndex = keys.indexOf('message');
|
|
||||||
if (messageIndex !== -1) {
|
|
||||||
keys.splice(messageIndex, 1);
|
|
||||||
}
|
|
||||||
if (keys.length === 1 && keys[0] === 'required') {
|
|
||||||
return _validator2['default'].required;
|
|
||||||
}
|
|
||||||
return _validator2['default'][this.getType(rule)] || false;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
Schema.register = function register(type, validator) {
|
|
||||||
if (typeof validator !== 'function') {
|
|
||||||
throw new Error('Cannot register a validator by type, validator is not a function');
|
|
||||||
}
|
|
||||||
_validator2['default'][type] = validator;
|
|
||||||
};
|
|
||||||
|
|
||||||
Schema.warning = _util.warning;
|
|
||||||
|
|
||||||
Schema.messages = _messages2.messages;
|
|
||||||
|
|
||||||
exports['default'] = Schema;
|
|
||||||
module.exports = exports['default'];
|
|
|
@ -1,60 +0,0 @@
|
||||||
'use strict';
|
|
||||||
|
|
||||||
exports.__esModule = true;
|
|
||||||
exports.newMessages = newMessages;
|
|
||||||
function newMessages() {
|
|
||||||
return {
|
|
||||||
'default': 'Validation error on field %s',
|
|
||||||
required: '%s is required',
|
|
||||||
'enum': '%s must be one of %s',
|
|
||||||
whitespace: '%s cannot be empty',
|
|
||||||
date: {
|
|
||||||
format: '%s date %s is invalid for format %s',
|
|
||||||
parse: '%s date could not be parsed, %s is invalid ',
|
|
||||||
invalid: '%s date %s is invalid'
|
|
||||||
},
|
|
||||||
types: {
|
|
||||||
string: '%s is not a %s',
|
|
||||||
method: '%s is not a %s (function)',
|
|
||||||
array: '%s is not an %s',
|
|
||||||
object: '%s is not an %s',
|
|
||||||
number: '%s is not a %s',
|
|
||||||
date: '%s is not a %s',
|
|
||||||
boolean: '%s is not a %s',
|
|
||||||
integer: '%s is not an %s',
|
|
||||||
float: '%s is not a %s',
|
|
||||||
regexp: '%s is not a valid %s',
|
|
||||||
email: '%s is not a valid %s',
|
|
||||||
url: '%s is not a valid %s',
|
|
||||||
hex: '%s is not a valid %s'
|
|
||||||
},
|
|
||||||
string: {
|
|
||||||
len: '%s must be exactly %s characters',
|
|
||||||
min: '%s must be at least %s characters',
|
|
||||||
max: '%s cannot be longer than %s characters',
|
|
||||||
range: '%s must be between %s and %s characters'
|
|
||||||
},
|
|
||||||
number: {
|
|
||||||
len: '%s must equal %s',
|
|
||||||
min: '%s cannot be less than %s',
|
|
||||||
max: '%s cannot be greater than %s',
|
|
||||||
range: '%s must be between %s and %s'
|
|
||||||
},
|
|
||||||
array: {
|
|
||||||
len: '%s must be exactly %s in length',
|
|
||||||
min: '%s cannot be less than %s in length',
|
|
||||||
max: '%s cannot be greater than %s in length',
|
|
||||||
range: '%s must be between %s and %s in length'
|
|
||||||
},
|
|
||||||
pattern: {
|
|
||||||
mismatch: '%s value %s does not match pattern %s'
|
|
||||||
},
|
|
||||||
clone: function clone() {
|
|
||||||
var cloned = JSON.parse(JSON.stringify(this));
|
|
||||||
cloned.clone = this.clone;
|
|
||||||
return cloned;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
var messages = exports.messages = newMessages();
|
|
|
@ -1,32 +0,0 @@
|
||||||
'use strict';
|
|
||||||
|
|
||||||
exports.__esModule = true;
|
|
||||||
|
|
||||||
var _util = require('../util');
|
|
||||||
|
|
||||||
var util = _interopRequireWildcard(_util);
|
|
||||||
|
|
||||||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj['default'] = obj; return newObj; } }
|
|
||||||
|
|
||||||
var ENUM = 'enum';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Rule for validating a value exists in an enumerable list.
|
|
||||||
*
|
|
||||||
* @param rule The validation rule.
|
|
||||||
* @param value The value of the field on the source object.
|
|
||||||
* @param source The source object being validated.
|
|
||||||
* @param errors An array of errors that this rule may add
|
|
||||||
* validation errors to.
|
|
||||||
* @param options The validation options.
|
|
||||||
* @param options.messages The validation messages.
|
|
||||||
*/
|
|
||||||
function enumerable(rule, value, source, errors, options) {
|
|
||||||
rule[ENUM] = Array.isArray(rule[ENUM]) ? rule[ENUM] : [];
|
|
||||||
if (rule[ENUM].indexOf(value) === -1) {
|
|
||||||
errors.push(util.format(options.messages[ENUM], rule.fullField, rule[ENUM].join(', ')));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
exports['default'] = enumerable;
|
|
||||||
module.exports = exports['default'];
|
|
|
@ -1,39 +0,0 @@
|
||||||
'use strict';
|
|
||||||
|
|
||||||
exports.__esModule = true;
|
|
||||||
|
|
||||||
var _required = require('./required');
|
|
||||||
|
|
||||||
var _required2 = _interopRequireDefault(_required);
|
|
||||||
|
|
||||||
var _whitespace = require('./whitespace');
|
|
||||||
|
|
||||||
var _whitespace2 = _interopRequireDefault(_whitespace);
|
|
||||||
|
|
||||||
var _type = require('./type');
|
|
||||||
|
|
||||||
var _type2 = _interopRequireDefault(_type);
|
|
||||||
|
|
||||||
var _range = require('./range');
|
|
||||||
|
|
||||||
var _range2 = _interopRequireDefault(_range);
|
|
||||||
|
|
||||||
var _enum = require('./enum');
|
|
||||||
|
|
||||||
var _enum2 = _interopRequireDefault(_enum);
|
|
||||||
|
|
||||||
var _pattern = require('./pattern');
|
|
||||||
|
|
||||||
var _pattern2 = _interopRequireDefault(_pattern);
|
|
||||||
|
|
||||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
|
|
||||||
|
|
||||||
exports['default'] = {
|
|
||||||
required: _required2['default'],
|
|
||||||
whitespace: _whitespace2['default'],
|
|
||||||
type: _type2['default'],
|
|
||||||
range: _range2['default'],
|
|
||||||
'enum': _enum2['default'],
|
|
||||||
pattern: _pattern2['default']
|
|
||||||
};
|
|
||||||
module.exports = exports['default'];
|
|
|
@ -1,42 +0,0 @@
|
||||||
'use strict';
|
|
||||||
|
|
||||||
exports.__esModule = true;
|
|
||||||
|
|
||||||
var _util = require('../util');
|
|
||||||
|
|
||||||
var util = _interopRequireWildcard(_util);
|
|
||||||
|
|
||||||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj['default'] = obj; return newObj; } }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Rule for validating a regular expression pattern.
|
|
||||||
*
|
|
||||||
* @param rule The validation rule.
|
|
||||||
* @param value The value of the field on the source object.
|
|
||||||
* @param source The source object being validated.
|
|
||||||
* @param errors An array of errors that this rule may add
|
|
||||||
* validation errors to.
|
|
||||||
* @param options The validation options.
|
|
||||||
* @param options.messages The validation messages.
|
|
||||||
*/
|
|
||||||
function pattern(rule, value, source, errors, options) {
|
|
||||||
if (rule.pattern) {
|
|
||||||
if (rule.pattern instanceof RegExp) {
|
|
||||||
// if a RegExp instance is passed, reset `lastIndex` in case its `global`
|
|
||||||
// flag is accidentally set to `true`, which in a validation scenario
|
|
||||||
// is not necessary and the result might be misleading
|
|
||||||
rule.pattern.lastIndex = 0;
|
|
||||||
if (!rule.pattern.test(value)) {
|
|
||||||
errors.push(util.format(options.messages.pattern.mismatch, rule.fullField, value, rule.pattern));
|
|
||||||
}
|
|
||||||
} else if (typeof rule.pattern === 'string') {
|
|
||||||
var _pattern = new RegExp(rule.pattern);
|
|
||||||
if (!_pattern.test(value)) {
|
|
||||||
errors.push(util.format(options.messages.pattern.mismatch, rule.fullField, value, rule.pattern));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
exports['default'] = pattern;
|
|
||||||
module.exports = exports['default'];
|
|
|
@ -1,67 +0,0 @@
|
||||||
'use strict';
|
|
||||||
|
|
||||||
exports.__esModule = true;
|
|
||||||
|
|
||||||
var _util = require('../util');
|
|
||||||
|
|
||||||
var util = _interopRequireWildcard(_util);
|
|
||||||
|
|
||||||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj['default'] = obj; return newObj; } }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Rule for validating minimum and maximum allowed values.
|
|
||||||
*
|
|
||||||
* @param rule The validation rule.
|
|
||||||
* @param value The value of the field on the source object.
|
|
||||||
* @param source The source object being validated.
|
|
||||||
* @param errors An array of errors that this rule may add
|
|
||||||
* validation errors to.
|
|
||||||
* @param options The validation options.
|
|
||||||
* @param options.messages The validation messages.
|
|
||||||
*/
|
|
||||||
function range(rule, value, source, errors, options) {
|
|
||||||
var len = typeof rule.len === 'number';
|
|
||||||
var min = typeof rule.min === 'number';
|
|
||||||
var max = typeof rule.max === 'number';
|
|
||||||
// 正则匹配码点范围从U+010000一直到U+10FFFF的文字(补充平面Supplementary Plane)
|
|
||||||
var spRegexp = /[\uD800-\uDBFF][\uDC00-\uDFFF]/g;
|
|
||||||
var val = value;
|
|
||||||
var key = null;
|
|
||||||
var num = typeof value === 'number';
|
|
||||||
var str = typeof value === 'string';
|
|
||||||
var arr = Array.isArray(value);
|
|
||||||
if (num) {
|
|
||||||
key = 'number';
|
|
||||||
} else if (str) {
|
|
||||||
key = 'string';
|
|
||||||
} else if (arr) {
|
|
||||||
key = 'array';
|
|
||||||
}
|
|
||||||
// if the value is not of a supported type for range validation
|
|
||||||
// the validation rule rule should use the
|
|
||||||
// type property to also test for a particular type
|
|
||||||
if (!key) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (arr) {
|
|
||||||
val = value.length;
|
|
||||||
}
|
|
||||||
if (str) {
|
|
||||||
// 处理码点大于U+010000的文字length属性不准确的bug,如"𠮷𠮷𠮷".lenght !== 3
|
|
||||||
val = value.replace(spRegexp, '_').length;
|
|
||||||
}
|
|
||||||
if (len) {
|
|
||||||
if (val !== rule.len) {
|
|
||||||
errors.push(util.format(options.messages[key].len, rule.fullField, rule.len));
|
|
||||||
}
|
|
||||||
} else if (min && !max && val < rule.min) {
|
|
||||||
errors.push(util.format(options.messages[key].min, rule.fullField, rule.min));
|
|
||||||
} else if (max && !min && val > rule.max) {
|
|
||||||
errors.push(util.format(options.messages[key].max, rule.fullField, rule.max));
|
|
||||||
} else if (min && max && (val < rule.min || val > rule.max)) {
|
|
||||||
errors.push(util.format(options.messages[key].range, rule.fullField, rule.min, rule.max));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
exports['default'] = range;
|
|
||||||
module.exports = exports['default'];
|
|
|
@ -1,29 +0,0 @@
|
||||||
'use strict';
|
|
||||||
|
|
||||||
exports.__esModule = true;
|
|
||||||
|
|
||||||
var _util = require('../util');
|
|
||||||
|
|
||||||
var util = _interopRequireWildcard(_util);
|
|
||||||
|
|
||||||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj['default'] = obj; return newObj; } }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Rule for validating required fields.
|
|
||||||
*
|
|
||||||
* @param rule The validation rule.
|
|
||||||
* @param value The value of the field on the source object.
|
|
||||||
* @param source The source object being validated.
|
|
||||||
* @param errors An array of errors that this rule may add
|
|
||||||
* validation errors to.
|
|
||||||
* @param options The validation options.
|
|
||||||
* @param options.messages The validation messages.
|
|
||||||
*/
|
|
||||||
function required(rule, value, source, errors, options, type) {
|
|
||||||
if (rule.required && (!source.hasOwnProperty(rule.field) || util.isEmptyValue(value, type || rule.type))) {
|
|
||||||
errors.push(util.format(options.messages.required, rule.fullField));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
exports['default'] = required;
|
|
||||||
module.exports = exports['default'];
|
|
|
@ -1,103 +0,0 @@
|
||||||
'use strict';
|
|
||||||
|
|
||||||
exports.__esModule = true;
|
|
||||||
|
|
||||||
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
|
|
||||||
|
|
||||||
var _util = require('../util');
|
|
||||||
|
|
||||||
var util = _interopRequireWildcard(_util);
|
|
||||||
|
|
||||||
var _required = require('./required');
|
|
||||||
|
|
||||||
var _required2 = _interopRequireDefault(_required);
|
|
||||||
|
|
||||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
|
|
||||||
|
|
||||||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj['default'] = obj; return newObj; } }
|
|
||||||
|
|
||||||
/* eslint max-len:0 */
|
|
||||||
|
|
||||||
var pattern = {
|
|
||||||
// http://emailregex.com/
|
|
||||||
email: /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/,
|
|
||||||
url: new RegExp('^(?!mailto:)(?:(?:http|https|ftp)://|//)(?:\\S+(?::\\S*)?@)?(?:(?:(?:[1-9]\\d?|1\\d\\d|2[01]\\d|22[0-3])(?:\\.(?:1?\\d{1,2}|2[0-4]\\d|25[0-5])){2}(?:\\.(?:[0-9]\\d?|1\\d\\d|2[0-4]\\d|25[0-4]))|(?:(?:[a-z\\u00a1-\\uffff0-9]+-?)*[a-z\\u00a1-\\uffff0-9]+)(?:\\.(?:[a-z\\u00a1-\\uffff0-9]+-?)*[a-z\\u00a1-\\uffff0-9]+)*(?:\\.(?:[a-z\\u00a1-\\uffff]{2,})))|localhost)(?::\\d{2,5})?(?:(/|\\?|#)[^\\s]*)?$', 'i'),
|
|
||||||
hex: /^#?([a-f0-9]{6}|[a-f0-9]{3})$/i
|
|
||||||
};
|
|
||||||
|
|
||||||
var types = {
|
|
||||||
integer: function integer(value) {
|
|
||||||
return types.number(value) && parseInt(value, 10) === value;
|
|
||||||
},
|
|
||||||
float: function float(value) {
|
|
||||||
return types.number(value) && !types.integer(value);
|
|
||||||
},
|
|
||||||
array: function array(value) {
|
|
||||||
return Array.isArray(value);
|
|
||||||
},
|
|
||||||
regexp: function regexp(value) {
|
|
||||||
if (value instanceof RegExp) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
return !!new RegExp(value);
|
|
||||||
} catch (e) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
date: function date(value) {
|
|
||||||
return typeof value.getTime === 'function' && typeof value.getMonth === 'function' && typeof value.getYear === 'function';
|
|
||||||
},
|
|
||||||
number: function number(value) {
|
|
||||||
if (isNaN(value)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return typeof value === 'number';
|
|
||||||
},
|
|
||||||
object: function object(value) {
|
|
||||||
return (typeof value === 'undefined' ? 'undefined' : _typeof(value)) === 'object' && !types.array(value);
|
|
||||||
},
|
|
||||||
method: function method(value) {
|
|
||||||
return typeof value === 'function';
|
|
||||||
},
|
|
||||||
email: function email(value) {
|
|
||||||
return typeof value === 'string' && !!value.match(pattern.email) && value.length < 255;
|
|
||||||
},
|
|
||||||
url: function url(value) {
|
|
||||||
return typeof value === 'string' && !!value.match(pattern.url);
|
|
||||||
},
|
|
||||||
hex: function hex(value) {
|
|
||||||
return typeof value === 'string' && !!value.match(pattern.hex);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Rule for validating the type of a value.
|
|
||||||
*
|
|
||||||
* @param rule The validation rule.
|
|
||||||
* @param value The value of the field on the source object.
|
|
||||||
* @param source The source object being validated.
|
|
||||||
* @param errors An array of errors that this rule may add
|
|
||||||
* validation errors to.
|
|
||||||
* @param options The validation options.
|
|
||||||
* @param options.messages The validation messages.
|
|
||||||
*/
|
|
||||||
function type(rule, value, source, errors, options) {
|
|
||||||
if (rule.required && value === undefined) {
|
|
||||||
(0, _required2['default'])(rule, value, source, errors, options);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
var custom = ['integer', 'float', 'array', 'regexp', 'object', 'method', 'email', 'number', 'date', 'url', 'hex'];
|
|
||||||
var ruleType = rule.type;
|
|
||||||
if (custom.indexOf(ruleType) > -1) {
|
|
||||||
if (!types[ruleType](value)) {
|
|
||||||
errors.push(util.format(options.messages.types[ruleType], rule.fullField, rule.type));
|
|
||||||
}
|
|
||||||
// straight typeof check
|
|
||||||
} else if (ruleType && (typeof value === 'undefined' ? 'undefined' : _typeof(value)) !== rule.type) {
|
|
||||||
errors.push(util.format(options.messages.types[ruleType], rule.fullField, rule.type));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
exports['default'] = type;
|
|
||||||
module.exports = exports['default'];
|
|
|
@ -1,29 +0,0 @@
|
||||||
'use strict';
|
|
||||||
|
|
||||||
exports.__esModule = true;
|
|
||||||
|
|
||||||
var _util = require('../util');
|
|
||||||
|
|
||||||
var util = _interopRequireWildcard(_util);
|
|
||||||
|
|
||||||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj['default'] = obj; return newObj; } }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Rule for validating whitespace.
|
|
||||||
*
|
|
||||||
* @param rule The validation rule.
|
|
||||||
* @param value The value of the field on the source object.
|
|
||||||
* @param source The source object being validated.
|
|
||||||
* @param errors An array of errors that this rule may add
|
|
||||||
* validation errors to.
|
|
||||||
* @param options The validation options.
|
|
||||||
* @param options.messages The validation messages.
|
|
||||||
*/
|
|
||||||
function whitespace(rule, value, source, errors, options) {
|
|
||||||
if (/^\s+$/.test(value) || value === '') {
|
|
||||||
errors.push(util.format(options.messages.whitespace, rule.fullField));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
exports['default'] = whitespace;
|
|
||||||
module.exports = exports['default'];
|
|
|
@ -1,221 +0,0 @@
|
||||||
'use strict';
|
|
||||||
|
|
||||||
exports.__esModule = true;
|
|
||||||
|
|
||||||
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
|
|
||||||
|
|
||||||
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
|
|
||||||
|
|
||||||
exports.convertFieldsError = convertFieldsError;
|
|
||||||
exports.format = format;
|
|
||||||
exports.isEmptyValue = isEmptyValue;
|
|
||||||
exports.isEmptyObject = isEmptyObject;
|
|
||||||
exports.asyncMap = asyncMap;
|
|
||||||
exports.complementError = complementError;
|
|
||||||
exports.deepMerge = deepMerge;
|
|
||||||
/* eslint no-console:0 */
|
|
||||||
|
|
||||||
var formatRegExp = /%[sdj%]/g;
|
|
||||||
|
|
||||||
var warning = exports.warning = function warning() {};
|
|
||||||
|
|
||||||
// don't print warning message when in production env or node runtime
|
|
||||||
if (process.env.NODE_ENV !== 'production' && typeof window !== 'undefined' && typeof document !== 'undefined') {
|
|
||||||
exports.warning = warning = function warning(type, errors) {
|
|
||||||
if (typeof console !== 'undefined' && console.warn) {
|
|
||||||
if (errors.every(function (e) {
|
|
||||||
return typeof e === 'string';
|
|
||||||
})) {
|
|
||||||
console.warn(type, errors);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
function convertFieldsError(errors) {
|
|
||||||
if (!errors || !errors.length) return null;
|
|
||||||
var fields = {};
|
|
||||||
errors.forEach(function (error) {
|
|
||||||
var field = error.field;
|
|
||||||
fields[field] = fields[field] || [];
|
|
||||||
fields[field].push(error);
|
|
||||||
});
|
|
||||||
return fields;
|
|
||||||
}
|
|
||||||
|
|
||||||
function format() {
|
|
||||||
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
|
|
||||||
args[_key] = arguments[_key];
|
|
||||||
}
|
|
||||||
|
|
||||||
var i = 1;
|
|
||||||
var f = args[0];
|
|
||||||
var len = args.length;
|
|
||||||
if (typeof f === 'function') {
|
|
||||||
return f.apply(null, args.slice(1));
|
|
||||||
}
|
|
||||||
if (typeof f === 'string') {
|
|
||||||
var str = String(f).replace(formatRegExp, function (x) {
|
|
||||||
if (x === '%%') {
|
|
||||||
return '%';
|
|
||||||
}
|
|
||||||
if (i >= len) {
|
|
||||||
return x;
|
|
||||||
}
|
|
||||||
switch (x) {
|
|
||||||
case '%s':
|
|
||||||
return String(args[i++]);
|
|
||||||
case '%d':
|
|
||||||
return Number(args[i++]);
|
|
||||||
case '%j':
|
|
||||||
try {
|
|
||||||
return JSON.stringify(args[i++]);
|
|
||||||
} catch (_) {
|
|
||||||
return '[Circular]';
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return x;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
for (var arg = args[i]; i < len; arg = args[++i]) {
|
|
||||||
str += ' ' + arg;
|
|
||||||
}
|
|
||||||
return str;
|
|
||||||
}
|
|
||||||
return f;
|
|
||||||
}
|
|
||||||
|
|
||||||
function isNativeStringType(type) {
|
|
||||||
return type === 'string' || type === 'url' || type === 'hex' || type === 'email' || type === 'pattern';
|
|
||||||
}
|
|
||||||
|
|
||||||
function isEmptyValue(value, type) {
|
|
||||||
if (value === undefined || value === null) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (type === 'array' && Array.isArray(value) && !value.length) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (isNativeStringType(type) && typeof value === 'string' && !value) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
function isEmptyObject(obj) {
|
|
||||||
return Object.keys(obj).length === 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
function asyncParallelArray(arr, func, callback) {
|
|
||||||
var results = [];
|
|
||||||
var total = 0;
|
|
||||||
var arrLength = arr.length;
|
|
||||||
|
|
||||||
function count(errors) {
|
|
||||||
results.push.apply(results, errors);
|
|
||||||
total++;
|
|
||||||
if (total === arrLength) {
|
|
||||||
callback(results);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
arr.forEach(function (a) {
|
|
||||||
func(a, count);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function asyncSerialArray(arr, func, callback) {
|
|
||||||
var index = 0;
|
|
||||||
var arrLength = arr.length;
|
|
||||||
|
|
||||||
function next(errors) {
|
|
||||||
if (errors && errors.length) {
|
|
||||||
callback(errors);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
var original = index;
|
|
||||||
index = index + 1;
|
|
||||||
if (original < arrLength) {
|
|
||||||
func(arr[original], next);
|
|
||||||
} else {
|
|
||||||
callback([]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
next([]);
|
|
||||||
}
|
|
||||||
|
|
||||||
function flattenObjArr(objArr) {
|
|
||||||
var ret = [];
|
|
||||||
Object.keys(objArr).forEach(function (k) {
|
|
||||||
ret.push.apply(ret, objArr[k]);
|
|
||||||
});
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
function asyncMap(objArr, option, func, callback) {
|
|
||||||
if (option.first) {
|
|
||||||
var flattenArr = flattenObjArr(objArr);
|
|
||||||
return asyncSerialArray(flattenArr, func, callback);
|
|
||||||
}
|
|
||||||
var firstFields = option.firstFields || [];
|
|
||||||
if (firstFields === true) {
|
|
||||||
firstFields = Object.keys(objArr);
|
|
||||||
}
|
|
||||||
var objArrKeys = Object.keys(objArr);
|
|
||||||
var objArrLength = objArrKeys.length;
|
|
||||||
var total = 0;
|
|
||||||
var results = [];
|
|
||||||
var pending = new Promise(function (resolve, reject) {
|
|
||||||
var next = function next(errors) {
|
|
||||||
results.push.apply(results, errors);
|
|
||||||
total++;
|
|
||||||
if (total === objArrLength) {
|
|
||||||
callback(results);
|
|
||||||
return results.length ? reject({ errors: results, fields: convertFieldsError(results) }) : resolve();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
objArrKeys.forEach(function (key) {
|
|
||||||
var arr = objArr[key];
|
|
||||||
if (firstFields.indexOf(key) !== -1) {
|
|
||||||
asyncSerialArray(arr, func, next);
|
|
||||||
} else {
|
|
||||||
asyncParallelArray(arr, func, next);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
pending['catch'](function (e) {
|
|
||||||
return e;
|
|
||||||
});
|
|
||||||
return pending;
|
|
||||||
}
|
|
||||||
|
|
||||||
function complementError(rule) {
|
|
||||||
return function (oe) {
|
|
||||||
if (oe && oe.message) {
|
|
||||||
oe.field = oe.field || rule.fullField;
|
|
||||||
return oe;
|
|
||||||
}
|
|
||||||
return {
|
|
||||||
message: typeof oe === 'function' ? oe() : oe,
|
|
||||||
field: oe.field || rule.fullField
|
|
||||||
};
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
function deepMerge(target, source) {
|
|
||||||
if (source) {
|
|
||||||
for (var s in source) {
|
|
||||||
if (source.hasOwnProperty(s)) {
|
|
||||||
var value = source[s];
|
|
||||||
if ((typeof value === 'undefined' ? 'undefined' : _typeof(value)) === 'object' && _typeof(target[s]) === 'object') {
|
|
||||||
target[s] = _extends({}, target[s], value);
|
|
||||||
} else {
|
|
||||||
target[s] = value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return target;
|
|
||||||
}
|
|
|
@ -1,40 +0,0 @@
|
||||||
'use strict';
|
|
||||||
|
|
||||||
exports.__esModule = true;
|
|
||||||
|
|
||||||
var _rule = require('../rule/');
|
|
||||||
|
|
||||||
var _rule2 = _interopRequireDefault(_rule);
|
|
||||||
|
|
||||||
var _util = require('../util');
|
|
||||||
|
|
||||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Validates an array.
|
|
||||||
*
|
|
||||||
* @param rule The validation rule.
|
|
||||||
* @param value The value of the field on the source object.
|
|
||||||
* @param callback The callback function.
|
|
||||||
* @param source The source object being validated.
|
|
||||||
* @param options The validation options.
|
|
||||||
* @param options.messages The validation messages.
|
|
||||||
*/
|
|
||||||
function array(rule, value, callback, source, options) {
|
|
||||||
var errors = [];
|
|
||||||
var validate = rule.required || !rule.required && source.hasOwnProperty(rule.field);
|
|
||||||
if (validate) {
|
|
||||||
if ((0, _util.isEmptyValue)(value, 'array') && !rule.required) {
|
|
||||||
return callback();
|
|
||||||
}
|
|
||||||
_rule2['default'].required(rule, value, source, errors, options, 'array');
|
|
||||||
if (!(0, _util.isEmptyValue)(value, 'array')) {
|
|
||||||
_rule2['default'].type(rule, value, source, errors, options);
|
|
||||||
_rule2['default'].range(rule, value, source, errors, options);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
callback(errors);
|
|
||||||
}
|
|
||||||
|
|
||||||
exports['default'] = array;
|
|
||||||
module.exports = exports['default'];
|
|
|
@ -1,39 +0,0 @@
|
||||||
'use strict';
|
|
||||||
|
|
||||||
exports.__esModule = true;
|
|
||||||
|
|
||||||
var _util = require('../util');
|
|
||||||
|
|
||||||
var _rule = require('../rule/');
|
|
||||||
|
|
||||||
var _rule2 = _interopRequireDefault(_rule);
|
|
||||||
|
|
||||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Validates a boolean.
|
|
||||||
*
|
|
||||||
* @param rule The validation rule.
|
|
||||||
* @param value The value of the field on the source object.
|
|
||||||
* @param callback The callback function.
|
|
||||||
* @param source The source object being validated.
|
|
||||||
* @param options The validation options.
|
|
||||||
* @param options.messages The validation messages.
|
|
||||||
*/
|
|
||||||
function boolean(rule, value, callback, source, options) {
|
|
||||||
var errors = [];
|
|
||||||
var validate = rule.required || !rule.required && source.hasOwnProperty(rule.field);
|
|
||||||
if (validate) {
|
|
||||||
if ((0, _util.isEmptyValue)(value) && !rule.required) {
|
|
||||||
return callback();
|
|
||||||
}
|
|
||||||
_rule2['default'].required(rule, value, source, errors, options);
|
|
||||||
if (value !== undefined) {
|
|
||||||
_rule2['default'].type(rule, value, source, errors, options);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
callback(errors);
|
|
||||||
}
|
|
||||||
|
|
||||||
exports['default'] = boolean;
|
|
||||||
module.exports = exports['default'];
|
|
|
@ -1,42 +0,0 @@
|
||||||
'use strict';
|
|
||||||
|
|
||||||
exports.__esModule = true;
|
|
||||||
|
|
||||||
var _rule = require('../rule/');
|
|
||||||
|
|
||||||
var _rule2 = _interopRequireDefault(_rule);
|
|
||||||
|
|
||||||
var _util = require('../util');
|
|
||||||
|
|
||||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
|
|
||||||
|
|
||||||
function date(rule, value, callback, source, options) {
|
|
||||||
// console.log('integer rule called %j', rule);
|
|
||||||
var errors = [];
|
|
||||||
var validate = rule.required || !rule.required && source.hasOwnProperty(rule.field);
|
|
||||||
// console.log('validate on %s value', value);
|
|
||||||
if (validate) {
|
|
||||||
if ((0, _util.isEmptyValue)(value) && !rule.required) {
|
|
||||||
return callback();
|
|
||||||
}
|
|
||||||
_rule2['default'].required(rule, value, source, errors, options);
|
|
||||||
if (!(0, _util.isEmptyValue)(value)) {
|
|
||||||
var dateObject = void 0;
|
|
||||||
|
|
||||||
if (typeof value === 'number') {
|
|
||||||
dateObject = new Date(value);
|
|
||||||
} else {
|
|
||||||
dateObject = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
_rule2['default'].type(rule, dateObject, source, errors, options);
|
|
||||||
if (dateObject) {
|
|
||||||
_rule2['default'].range(rule, dateObject.getTime(), source, errors, options);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
callback(errors);
|
|
||||||
}
|
|
||||||
|
|
||||||
exports['default'] = date;
|
|
||||||
module.exports = exports['default'];
|
|
|
@ -1,41 +0,0 @@
|
||||||
'use strict';
|
|
||||||
|
|
||||||
exports.__esModule = true;
|
|
||||||
|
|
||||||
var _rule = require('../rule/');
|
|
||||||
|
|
||||||
var _rule2 = _interopRequireDefault(_rule);
|
|
||||||
|
|
||||||
var _util = require('../util');
|
|
||||||
|
|
||||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
|
|
||||||
|
|
||||||
var ENUM = 'enum';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Validates an enumerable list.
|
|
||||||
*
|
|
||||||
* @param rule The validation rule.
|
|
||||||
* @param value The value of the field on the source object.
|
|
||||||
* @param callback The callback function.
|
|
||||||
* @param source The source object being validated.
|
|
||||||
* @param options The validation options.
|
|
||||||
* @param options.messages The validation messages.
|
|
||||||
*/
|
|
||||||
function enumerable(rule, value, callback, source, options) {
|
|
||||||
var errors = [];
|
|
||||||
var validate = rule.required || !rule.required && source.hasOwnProperty(rule.field);
|
|
||||||
if (validate) {
|
|
||||||
if ((0, _util.isEmptyValue)(value) && !rule.required) {
|
|
||||||
return callback();
|
|
||||||
}
|
|
||||||
_rule2['default'].required(rule, value, source, errors, options);
|
|
||||||
if (value) {
|
|
||||||
_rule2['default'][ENUM](rule, value, source, errors, options);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
callback(errors);
|
|
||||||
}
|
|
||||||
|
|
||||||
exports['default'] = enumerable;
|
|
||||||
module.exports = exports['default'];
|
|
|
@ -1,40 +0,0 @@
|
||||||
'use strict';
|
|
||||||
|
|
||||||
exports.__esModule = true;
|
|
||||||
|
|
||||||
var _rule = require('../rule/');
|
|
||||||
|
|
||||||
var _rule2 = _interopRequireDefault(_rule);
|
|
||||||
|
|
||||||
var _util = require('../util');
|
|
||||||
|
|
||||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Validates a number is a floating point number.
|
|
||||||
*
|
|
||||||
* @param rule The validation rule.
|
|
||||||
* @param value The value of the field on the source object.
|
|
||||||
* @param callback The callback function.
|
|
||||||
* @param source The source object being validated.
|
|
||||||
* @param options The validation options.
|
|
||||||
* @param options.messages The validation messages.
|
|
||||||
*/
|
|
||||||
function floatFn(rule, value, callback, source, options) {
|
|
||||||
var errors = [];
|
|
||||||
var validate = rule.required || !rule.required && source.hasOwnProperty(rule.field);
|
|
||||||
if (validate) {
|
|
||||||
if ((0, _util.isEmptyValue)(value) && !rule.required) {
|
|
||||||
return callback();
|
|
||||||
}
|
|
||||||
_rule2['default'].required(rule, value, source, errors, options);
|
|
||||||
if (value !== undefined) {
|
|
||||||
_rule2['default'].type(rule, value, source, errors, options);
|
|
||||||
_rule2['default'].range(rule, value, source, errors, options);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
callback(errors);
|
|
||||||
}
|
|
||||||
|
|
||||||
exports['default'] = floatFn;
|
|
||||||
module.exports = exports['default'];
|
|
|
@ -1,81 +0,0 @@
|
||||||
'use strict';
|
|
||||||
|
|
||||||
exports.__esModule = true;
|
|
||||||
|
|
||||||
var _string = require('./string');
|
|
||||||
|
|
||||||
var _string2 = _interopRequireDefault(_string);
|
|
||||||
|
|
||||||
var _method = require('./method');
|
|
||||||
|
|
||||||
var _method2 = _interopRequireDefault(_method);
|
|
||||||
|
|
||||||
var _number = require('./number');
|
|
||||||
|
|
||||||
var _number2 = _interopRequireDefault(_number);
|
|
||||||
|
|
||||||
var _boolean = require('./boolean');
|
|
||||||
|
|
||||||
var _boolean2 = _interopRequireDefault(_boolean);
|
|
||||||
|
|
||||||
var _regexp = require('./regexp');
|
|
||||||
|
|
||||||
var _regexp2 = _interopRequireDefault(_regexp);
|
|
||||||
|
|
||||||
var _integer = require('./integer');
|
|
||||||
|
|
||||||
var _integer2 = _interopRequireDefault(_integer);
|
|
||||||
|
|
||||||
var _float = require('./float');
|
|
||||||
|
|
||||||
var _float2 = _interopRequireDefault(_float);
|
|
||||||
|
|
||||||
var _array = require('./array');
|
|
||||||
|
|
||||||
var _array2 = _interopRequireDefault(_array);
|
|
||||||
|
|
||||||
var _object = require('./object');
|
|
||||||
|
|
||||||
var _object2 = _interopRequireDefault(_object);
|
|
||||||
|
|
||||||
var _enum = require('./enum');
|
|
||||||
|
|
||||||
var _enum2 = _interopRequireDefault(_enum);
|
|
||||||
|
|
||||||
var _pattern = require('./pattern');
|
|
||||||
|
|
||||||
var _pattern2 = _interopRequireDefault(_pattern);
|
|
||||||
|
|
||||||
var _date = require('./date');
|
|
||||||
|
|
||||||
var _date2 = _interopRequireDefault(_date);
|
|
||||||
|
|
||||||
var _required = require('./required');
|
|
||||||
|
|
||||||
var _required2 = _interopRequireDefault(_required);
|
|
||||||
|
|
||||||
var _type = require('./type');
|
|
||||||
|
|
||||||
var _type2 = _interopRequireDefault(_type);
|
|
||||||
|
|
||||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
|
|
||||||
|
|
||||||
exports['default'] = {
|
|
||||||
string: _string2['default'],
|
|
||||||
method: _method2['default'],
|
|
||||||
number: _number2['default'],
|
|
||||||
boolean: _boolean2['default'],
|
|
||||||
regexp: _regexp2['default'],
|
|
||||||
integer: _integer2['default'],
|
|
||||||
float: _float2['default'],
|
|
||||||
array: _array2['default'],
|
|
||||||
object: _object2['default'],
|
|
||||||
'enum': _enum2['default'],
|
|
||||||
pattern: _pattern2['default'],
|
|
||||||
date: _date2['default'],
|
|
||||||
url: _type2['default'],
|
|
||||||
hex: _type2['default'],
|
|
||||||
email: _type2['default'],
|
|
||||||
required: _required2['default']
|
|
||||||
};
|
|
||||||
module.exports = exports['default'];
|
|
|
@ -1,40 +0,0 @@
|
||||||
'use strict';
|
|
||||||
|
|
||||||
exports.__esModule = true;
|
|
||||||
|
|
||||||
var _rule = require('../rule/');
|
|
||||||
|
|
||||||
var _rule2 = _interopRequireDefault(_rule);
|
|
||||||
|
|
||||||
var _util = require('../util');
|
|
||||||
|
|
||||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Validates a number is an integer.
|
|
||||||
*
|
|
||||||
* @param rule The validation rule.
|
|
||||||
* @param value The value of the field on the source object.
|
|
||||||
* @param callback The callback function.
|
|
||||||
* @param source The source object being validated.
|
|
||||||
* @param options The validation options.
|
|
||||||
* @param options.messages The validation messages.
|
|
||||||
*/
|
|
||||||
function integer(rule, value, callback, source, options) {
|
|
||||||
var errors = [];
|
|
||||||
var validate = rule.required || !rule.required && source.hasOwnProperty(rule.field);
|
|
||||||
if (validate) {
|
|
||||||
if ((0, _util.isEmptyValue)(value) && !rule.required) {
|
|
||||||
return callback();
|
|
||||||
}
|
|
||||||
_rule2['default'].required(rule, value, source, errors, options);
|
|
||||||
if (value !== undefined) {
|
|
||||||
_rule2['default'].type(rule, value, source, errors, options);
|
|
||||||
_rule2['default'].range(rule, value, source, errors, options);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
callback(errors);
|
|
||||||
}
|
|
||||||
|
|
||||||
exports['default'] = integer;
|
|
||||||
module.exports = exports['default'];
|
|
|
@ -1,39 +0,0 @@
|
||||||
'use strict';
|
|
||||||
|
|
||||||
exports.__esModule = true;
|
|
||||||
|
|
||||||
var _rule = require('../rule/');
|
|
||||||
|
|
||||||
var _rule2 = _interopRequireDefault(_rule);
|
|
||||||
|
|
||||||
var _util = require('../util');
|
|
||||||
|
|
||||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Validates a function.
|
|
||||||
*
|
|
||||||
* @param rule The validation rule.
|
|
||||||
* @param value The value of the field on the source object.
|
|
||||||
* @param callback The callback function.
|
|
||||||
* @param source The source object being validated.
|
|
||||||
* @param options The validation options.
|
|
||||||
* @param options.messages The validation messages.
|
|
||||||
*/
|
|
||||||
function method(rule, value, callback, source, options) {
|
|
||||||
var errors = [];
|
|
||||||
var validate = rule.required || !rule.required && source.hasOwnProperty(rule.field);
|
|
||||||
if (validate) {
|
|
||||||
if ((0, _util.isEmptyValue)(value) && !rule.required) {
|
|
||||||
return callback();
|
|
||||||
}
|
|
||||||
_rule2['default'].required(rule, value, source, errors, options);
|
|
||||||
if (value !== undefined) {
|
|
||||||
_rule2['default'].type(rule, value, source, errors, options);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
callback(errors);
|
|
||||||
}
|
|
||||||
|
|
||||||
exports['default'] = method;
|
|
||||||
module.exports = exports['default'];
|
|
|
@ -1,43 +0,0 @@
|
||||||
'use strict';
|
|
||||||
|
|
||||||
exports.__esModule = true;
|
|
||||||
|
|
||||||
var _rule = require('../rule/');
|
|
||||||
|
|
||||||
var _rule2 = _interopRequireDefault(_rule);
|
|
||||||
|
|
||||||
var _util = require('../util');
|
|
||||||
|
|
||||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Validates a number.
|
|
||||||
*
|
|
||||||
* @param rule The validation rule.
|
|
||||||
* @param value The value of the field on the source object.
|
|
||||||
* @param callback The callback function.
|
|
||||||
* @param source The source object being validated.
|
|
||||||
* @param options The validation options.
|
|
||||||
* @param options.messages The validation messages.
|
|
||||||
*/
|
|
||||||
function number(rule, value, callback, source, options) {
|
|
||||||
var errors = [];
|
|
||||||
var validate = rule.required || !rule.required && source.hasOwnProperty(rule.field);
|
|
||||||
if (validate) {
|
|
||||||
if (value === '') {
|
|
||||||
value = undefined;
|
|
||||||
}
|
|
||||||
if ((0, _util.isEmptyValue)(value) && !rule.required) {
|
|
||||||
return callback();
|
|
||||||
}
|
|
||||||
_rule2['default'].required(rule, value, source, errors, options);
|
|
||||||
if (value !== undefined) {
|
|
||||||
_rule2['default'].type(rule, value, source, errors, options);
|
|
||||||
_rule2['default'].range(rule, value, source, errors, options);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
callback(errors);
|
|
||||||
}
|
|
||||||
|
|
||||||
exports['default'] = number;
|
|
||||||
module.exports = exports['default'];
|
|
|
@ -1,39 +0,0 @@
|
||||||
'use strict';
|
|
||||||
|
|
||||||
exports.__esModule = true;
|
|
||||||
|
|
||||||
var _rule = require('../rule/');
|
|
||||||
|
|
||||||
var _rule2 = _interopRequireDefault(_rule);
|
|
||||||
|
|
||||||
var _util = require('../util');
|
|
||||||
|
|
||||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Validates an object.
|
|
||||||
*
|
|
||||||
* @param rule The validation rule.
|
|
||||||
* @param value The value of the field on the source object.
|
|
||||||
* @param callback The callback function.
|
|
||||||
* @param source The source object being validated.
|
|
||||||
* @param options The validation options.
|
|
||||||
* @param options.messages The validation messages.
|
|
||||||
*/
|
|
||||||
function object(rule, value, callback, source, options) {
|
|
||||||
var errors = [];
|
|
||||||
var validate = rule.required || !rule.required && source.hasOwnProperty(rule.field);
|
|
||||||
if (validate) {
|
|
||||||
if ((0, _util.isEmptyValue)(value) && !rule.required) {
|
|
||||||
return callback();
|
|
||||||
}
|
|
||||||
_rule2['default'].required(rule, value, source, errors, options);
|
|
||||||
if (value !== undefined) {
|
|
||||||
_rule2['default'].type(rule, value, source, errors, options);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
callback(errors);
|
|
||||||
}
|
|
||||||
|
|
||||||
exports['default'] = object;
|
|
||||||
module.exports = exports['default'];
|
|
|
@ -1,42 +0,0 @@
|
||||||
'use strict';
|
|
||||||
|
|
||||||
exports.__esModule = true;
|
|
||||||
|
|
||||||
var _rule = require('../rule/');
|
|
||||||
|
|
||||||
var _rule2 = _interopRequireDefault(_rule);
|
|
||||||
|
|
||||||
var _util = require('../util');
|
|
||||||
|
|
||||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Validates a regular expression pattern.
|
|
||||||
*
|
|
||||||
* Performs validation when a rule only contains
|
|
||||||
* a pattern property but is not declared as a string type.
|
|
||||||
*
|
|
||||||
* @param rule The validation rule.
|
|
||||||
* @param value The value of the field on the source object.
|
|
||||||
* @param callback The callback function.
|
|
||||||
* @param source The source object being validated.
|
|
||||||
* @param options The validation options.
|
|
||||||
* @param options.messages The validation messages.
|
|
||||||
*/
|
|
||||||
function pattern(rule, value, callback, source, options) {
|
|
||||||
var errors = [];
|
|
||||||
var validate = rule.required || !rule.required && source.hasOwnProperty(rule.field);
|
|
||||||
if (validate) {
|
|
||||||
if ((0, _util.isEmptyValue)(value, 'string') && !rule.required) {
|
|
||||||
return callback();
|
|
||||||
}
|
|
||||||
_rule2['default'].required(rule, value, source, errors, options);
|
|
||||||
if (!(0, _util.isEmptyValue)(value, 'string')) {
|
|
||||||
_rule2['default'].pattern(rule, value, source, errors, options);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
callback(errors);
|
|
||||||
}
|
|
||||||
|
|
||||||
exports['default'] = pattern;
|
|
||||||
module.exports = exports['default'];
|
|
|
@ -1,39 +0,0 @@
|
||||||
'use strict';
|
|
||||||
|
|
||||||
exports.__esModule = true;
|
|
||||||
|
|
||||||
var _rule = require('../rule/');
|
|
||||||
|
|
||||||
var _rule2 = _interopRequireDefault(_rule);
|
|
||||||
|
|
||||||
var _util = require('../util');
|
|
||||||
|
|
||||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Validates the regular expression type.
|
|
||||||
*
|
|
||||||
* @param rule The validation rule.
|
|
||||||
* @param value The value of the field on the source object.
|
|
||||||
* @param callback The callback function.
|
|
||||||
* @param source The source object being validated.
|
|
||||||
* @param options The validation options.
|
|
||||||
* @param options.messages The validation messages.
|
|
||||||
*/
|
|
||||||
function regexp(rule, value, callback, source, options) {
|
|
||||||
var errors = [];
|
|
||||||
var validate = rule.required || !rule.required && source.hasOwnProperty(rule.field);
|
|
||||||
if (validate) {
|
|
||||||
if ((0, _util.isEmptyValue)(value) && !rule.required) {
|
|
||||||
return callback();
|
|
||||||
}
|
|
||||||
_rule2['default'].required(rule, value, source, errors, options);
|
|
||||||
if (!(0, _util.isEmptyValue)(value)) {
|
|
||||||
_rule2['default'].type(rule, value, source, errors, options);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
callback(errors);
|
|
||||||
}
|
|
||||||
|
|
||||||
exports['default'] = regexp;
|
|
||||||
module.exports = exports['default'];
|
|
|
@ -1,21 +0,0 @@
|
||||||
'use strict';
|
|
||||||
|
|
||||||
exports.__esModule = true;
|
|
||||||
|
|
||||||
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
|
|
||||||
|
|
||||||
var _rule = require('../rule/');
|
|
||||||
|
|
||||||
var _rule2 = _interopRequireDefault(_rule);
|
|
||||||
|
|
||||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
|
|
||||||
|
|
||||||
function required(rule, value, callback, source, options) {
|
|
||||||
var errors = [];
|
|
||||||
var type = Array.isArray(value) ? 'array' : typeof value === 'undefined' ? 'undefined' : _typeof(value);
|
|
||||||
_rule2['default'].required(rule, value, source, errors, options, type);
|
|
||||||
callback(errors);
|
|
||||||
}
|
|
||||||
|
|
||||||
exports['default'] = required;
|
|
||||||
module.exports = exports['default'];
|
|
|
@ -1,44 +0,0 @@
|
||||||
'use strict';
|
|
||||||
|
|
||||||
exports.__esModule = true;
|
|
||||||
|
|
||||||
var _rule = require('../rule/');
|
|
||||||
|
|
||||||
var _rule2 = _interopRequireDefault(_rule);
|
|
||||||
|
|
||||||
var _util = require('../util');
|
|
||||||
|
|
||||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Performs validation for string types.
|
|
||||||
*
|
|
||||||
* @param rule The validation rule.
|
|
||||||
* @param value The value of the field on the source object.
|
|
||||||
* @param callback The callback function.
|
|
||||||
* @param source The source object being validated.
|
|
||||||
* @param options The validation options.
|
|
||||||
* @param options.messages The validation messages.
|
|
||||||
*/
|
|
||||||
function string(rule, value, callback, source, options) {
|
|
||||||
var errors = [];
|
|
||||||
var validate = rule.required || !rule.required && source.hasOwnProperty(rule.field);
|
|
||||||
if (validate) {
|
|
||||||
if ((0, _util.isEmptyValue)(value, 'string') && !rule.required) {
|
|
||||||
return callback();
|
|
||||||
}
|
|
||||||
_rule2['default'].required(rule, value, source, errors, options, 'string');
|
|
||||||
if (!(0, _util.isEmptyValue)(value, 'string')) {
|
|
||||||
_rule2['default'].type(rule, value, source, errors, options);
|
|
||||||
_rule2['default'].range(rule, value, source, errors, options);
|
|
||||||
_rule2['default'].pattern(rule, value, source, errors, options);
|
|
||||||
if (rule.whitespace === true) {
|
|
||||||
_rule2['default'].whitespace(rule, value, source, errors, options);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
callback(errors);
|
|
||||||
}
|
|
||||||
|
|
||||||
exports['default'] = string;
|
|
||||||
module.exports = exports['default'];
|
|
|
@ -1,30 +0,0 @@
|
||||||
'use strict';
|
|
||||||
|
|
||||||
exports.__esModule = true;
|
|
||||||
|
|
||||||
var _rule = require('../rule/');
|
|
||||||
|
|
||||||
var _rule2 = _interopRequireDefault(_rule);
|
|
||||||
|
|
||||||
var _util = require('../util');
|
|
||||||
|
|
||||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
|
|
||||||
|
|
||||||
function type(rule, value, callback, source, options) {
|
|
||||||
var ruleType = rule.type;
|
|
||||||
var errors = [];
|
|
||||||
var validate = rule.required || !rule.required && source.hasOwnProperty(rule.field);
|
|
||||||
if (validate) {
|
|
||||||
if ((0, _util.isEmptyValue)(value, ruleType) && !rule.required) {
|
|
||||||
return callback();
|
|
||||||
}
|
|
||||||
_rule2['default'].required(rule, value, source, errors, options, ruleType);
|
|
||||||
if (!(0, _util.isEmptyValue)(value, ruleType)) {
|
|
||||||
_rule2['default'].type(rule, value, source, errors, options);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
callback(errors);
|
|
||||||
}
|
|
||||||
|
|
||||||
exports['default'] = type;
|
|
||||||
module.exports = exports['default'];
|
|
|
@ -1,83 +0,0 @@
|
||||||
{
|
|
||||||
"_from": "async-validator@^1.7.1",
|
|
||||||
"_id": "async-validator@1.12.2",
|
|
||||||
"_inBundle": false,
|
|
||||||
"_integrity": "sha512-57EETfCPFiB7M4QscvQzWSGNsmtkjjzZv318SK1CBlstk+hycV72ocjriMOOM48HjvmoAoJGpJNjC7Z76RlnZA==",
|
|
||||||
"_location": "/async-validator",
|
|
||||||
"_phantomChildren": {},
|
|
||||||
"_requested": {
|
|
||||||
"type": "range",
|
|
||||||
"registry": true,
|
|
||||||
"raw": "async-validator@^1.7.1",
|
|
||||||
"name": "async-validator",
|
|
||||||
"escapedName": "async-validator",
|
|
||||||
"rawSpec": "^1.7.1",
|
|
||||||
"saveSpec": null,
|
|
||||||
"fetchSpec": "^1.7.1"
|
|
||||||
},
|
|
||||||
"_requiredBy": [
|
|
||||||
"/uview"
|
|
||||||
],
|
|
||||||
"_resolved": "https://registry.npmjs.org/async-validator/-/async-validator-1.12.2.tgz",
|
|
||||||
"_shasum": "beae671e7174d2938b7b4b69d2fb7e722b7fd72c",
|
|
||||||
"_spec": "async-validator@^1.7.1",
|
|
||||||
"_where": "/Users/ran/Desktop/宏业汇成/lili-shop-uniapp/node_modules/uview",
|
|
||||||
"author": {
|
|
||||||
"name": "yiminghe@gmail.com"
|
|
||||||
},
|
|
||||||
"bugs": {
|
|
||||||
"url": "http://github.com/yiminghe/async-validator/issues"
|
|
||||||
},
|
|
||||||
"bundleDependencies": false,
|
|
||||||
"config": {
|
|
||||||
"port": 8010
|
|
||||||
},
|
|
||||||
"deprecated": false,
|
|
||||||
"description": "validate form asynchronous",
|
|
||||||
"devDependencies": {
|
|
||||||
"babel-preset-env": "^1.7.0",
|
|
||||||
"coveralls": "^2.13.1",
|
|
||||||
"jest": "^23.6.0",
|
|
||||||
"pre-commit": "1.x",
|
|
||||||
"rc-tools": "7.x"
|
|
||||||
},
|
|
||||||
"files": [
|
|
||||||
"lib",
|
|
||||||
"es"
|
|
||||||
],
|
|
||||||
"homepage": "http://github.com/yiminghe/async-validator",
|
|
||||||
"jest": {
|
|
||||||
"collectCoverageFrom": [
|
|
||||||
"src/*"
|
|
||||||
],
|
|
||||||
"transform": {
|
|
||||||
"\\.jsx?$": "./node_modules/rc-tools/scripts/jestPreprocessor.js"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"keywords": [
|
|
||||||
"validator",
|
|
||||||
"validate",
|
|
||||||
"async"
|
|
||||||
],
|
|
||||||
"licenses": "MIT",
|
|
||||||
"main": "./lib/index",
|
|
||||||
"module": "./es/index",
|
|
||||||
"name": "async-validator",
|
|
||||||
"pre-commit": [
|
|
||||||
"lint"
|
|
||||||
],
|
|
||||||
"repository": {
|
|
||||||
"type": "git",
|
|
||||||
"url": "git+ssh://git@github.com/yiminghe/async-validator.git"
|
|
||||||
},
|
|
||||||
"scripts": {
|
|
||||||
"build": "rc-tools run build",
|
|
||||||
"coverage": "jest --coverage && cat ./coverage/lcov.info | coveralls",
|
|
||||||
"gh-pages": "rc-tools run gh-pages",
|
|
||||||
"lint": "rc-tools run lint",
|
|
||||||
"pub": "rc-tools run pub",
|
|
||||||
"start": "rc-tools run server",
|
|
||||||
"test": "jest"
|
|
||||||
},
|
|
||||||
"version": "1.12.2"
|
|
||||||
}
|
|
|
@ -1,706 +0,0 @@
|
||||||
## Changelog
|
|
||||||
##### 2.6.11 [LEGACY] - 2019.12.09
|
|
||||||
- Returned usage of `node -e` in `postinstall` scripts for better cross-platform compatibility, [#582](https://github.com/zloirock/core-js/issues/582)
|
|
||||||
- Improved CI detection in the `postinstall` script, [#707](https://github.com/zloirock/core-js/issues/707)
|
|
||||||
|
|
||||||
##### 2.6.10 [LEGACY] - 2019.10.13
|
|
||||||
- Show similar `postinstall` messages only once per `npm i`, [#597](https://github.com/zloirock/core-js/issues/597)
|
|
||||||
|
|
||||||
##### 2.6.9 [LEGACY] - 2019.05.27
|
|
||||||
- Some fixes and improvements of the `postinstall` script like support `npm` color config ([#556](https://github.com/zloirock/core-js/issues/556)) or adding support of `ADBLOCK` env variable
|
|
||||||
|
|
||||||
##### 2.6.8 [LEGACY] - 2019.05.22
|
|
||||||
- Added a workaround of a strange `npx` bug on `postinstall`, [#551](https://github.com/zloirock/core-js/issues/551)
|
|
||||||
|
|
||||||
##### 2.6.7 [LEGACY] - 2019.05.21
|
|
||||||
- Added one more workaround of alternative not completely correct `Symbol` polyfills, [#550](https://github.com/zloirock/core-js/issues/550), [#554](https://github.com/zloirock/core-js/issues/554)
|
|
||||||
|
|
||||||
##### 2.6.6 [LEGACY] - 2019.05.20
|
|
||||||
- Fixed IE8- non-enumerable properties support in `Object.{ assign, entries, values }`, [#541](https://github.com/zloirock/core-js/issues/541)
|
|
||||||
- Fixed support of primitives in `Object.getOwnPropertySymbols` in Chrome 38 / 39, [#539](https://github.com/zloirock/core-js/issues/539)
|
|
||||||
- Show a message on `postinstall`
|
|
||||||
|
|
||||||
##### 2.6.5 - 2019.02.15
|
|
||||||
- Fixed buggy `String#padStart` and `String#padEnd` mobile Safari implementations, [#414](https://github.com/zloirock/core-js/issues/414).
|
|
||||||
|
|
||||||
##### 2.6.4 - 2019.02.07
|
|
||||||
- Added a workaround against crushing an old IE11.0.9600.16384 build, [#485](https://github.com/zloirock/core-js/issues/485).
|
|
||||||
|
|
||||||
##### 2.6.3 - 2019.01.22
|
|
||||||
- Added a workaround for `babel-minify` bug, [#479](https://github.com/zloirock/core-js/issues/479)
|
|
||||||
|
|
||||||
##### 2.6.2 - 2019.01.10
|
|
||||||
- Fixed handling of `$` in `String#replace`, [#471](https://github.com/zloirock/core-js/issues/471)
|
|
||||||
|
|
||||||
##### 2.6.1 - 2018.12.18
|
|
||||||
- Fixed an issue with minified version, [#463](https://github.com/zloirock/core-js/issues/463)
|
|
||||||
|
|
||||||
##### 2.6.0 - 2018.12.05
|
|
||||||
- Add direct .exec calling to `RegExp#{@@replace, @@split, @@match, @@search}`. Also, added fixes for `RegExp#exec` method. [#411](https://github.com/zloirock/core-js/issues/411), [#428](https://github.com/zloirock/core-js/issues/428), [#434](https://github.com/zloirock/core-js/issues/434), [#435](https://github.com/zloirock/core-js/issues/435), [#453](https://github.com/zloirock/core-js/issues/453), [#458](https://github.com/zloirock/core-js/issues/458), thanks [**@nicolo-ribaudo**](https://github.com/nicolo-ribaudo).
|
|
||||||
|
|
||||||
##### 2.5.7 - 2018.05.26
|
|
||||||
- Get rid of reserved variable name `final`, related [#400](https://github.com/zloirock/core-js/issues/400)
|
|
||||||
|
|
||||||
##### 2.5.6 - 2018.05.07
|
|
||||||
- Forced replace native `Promise` in V8 6.6 (Node 10 and Chrome 66) because of [a bug with resolving custom thenables](https://bugs.chromium.org/p/chromium/issues/detail?id=830565)
|
|
||||||
- Added a workaround for usage buggy native LG WebOS 2 `Promise` in microtask implementation, [#396](https://github.com/zloirock/core-js/issues/396)
|
|
||||||
- Added modern version internal debugging information about used versions
|
|
||||||
|
|
||||||
##### 2.5.5 - 2018.04.08
|
|
||||||
- Fix some edge cases of `Reflect.set`, [#392](https://github.com/zloirock/core-js/issues/392) and [#393](https://github.com/zloirock/core-js/issues/393)
|
|
||||||
|
|
||||||
##### 2.5.4 - 2018.03.27
|
|
||||||
- Fixed one case of deoptimization built-in iterators in V8, related [#377](https://github.com/zloirock/core-js/issues/377)
|
|
||||||
- Fixed some cases of iterators feature detection, [#368](https://github.com/zloirock/core-js/issues/368)
|
|
||||||
- Fixed manually entered NodeJS domains issue in `Promise`, [#367](https://github.com/zloirock/core-js/issues/367)
|
|
||||||
- Fixed `Number.{parseInt, parseFloat}` entry points
|
|
||||||
- Fixed `__(define|lookup)[GS]etter__` import in the `library` version
|
|
||||||
|
|
||||||
##### 2.5.3 - 2017.12.12
|
|
||||||
- Fixed calling `onunhandledrejectionhandler` multiple times for one `Promise` chain, [#318](https://github.com/zloirock/core-js/issues/318)
|
|
||||||
- Forced replacement of `String#{padStart, padEnd}` in Safari 10 because of [a bug](https://bugs.webkit.org/show_bug.cgi?id=161944), [#280](https://github.com/zloirock/core-js/issues/280)
|
|
||||||
- Fixed `Array#@@iterator` in a very rare version of `WebKit`, [#236](https://github.com/zloirock/core-js/issues/236) and [#237](https://github.com/zloirock/core-js/issues/237)
|
|
||||||
- One more [#345](https://github.com/zloirock/core-js/issues/345)-related fix
|
|
||||||
|
|
||||||
##### 2.5.2 - 2017.12.09
|
|
||||||
- `MutationObserver` no longer used for microtask implementation in iOS Safari because of bug with scrolling, [#339](https://github.com/zloirock/core-js/issues/339)
|
|
||||||
- Fixed `JSON.stringify(undefined, replacer)` case in the wrapper from the `Symbol` polyfill, [#345](https://github.com/zloirock/core-js/issues/345)
|
|
||||||
- `Array()` calls changed to `new Array()` for V8 optimisation
|
|
||||||
|
|
||||||
##### 2.5.1 - 2017.09.01
|
|
||||||
- Updated `Promise#finally` per [tc39/proposal-promise-finally#37](https://github.com/tc39/proposal-promise-finally/issues/37)
|
|
||||||
- Optimized usage of some internal helpers for reducing size of `shim` version
|
|
||||||
- Fixed some entry points for virtual methods
|
|
||||||
|
|
||||||
##### 2.5.0 - 2017.08.05
|
|
||||||
- Added `Promise#finally` [stage 3 proposal](https://github.com/tc39/proposal-promise-finally), [#225](https://github.com/zloirock/core-js/issues/225)
|
|
||||||
- Added `Promise.try` [stage 1 proposal](https://github.com/tc39/proposal-promise-try)
|
|
||||||
- Added `Array#flatten` and `Array#flatMap` [stage 1 proposal](https://tc39.github.io/proposal-flatMap)
|
|
||||||
- Added `.of` and `.from` methods on collection constructors [stage 1 proposal](https://github.com/tc39/proposal-setmap-offrom):
|
|
||||||
- `Map.of`
|
|
||||||
- `Set.of`
|
|
||||||
- `WeakSet.of`
|
|
||||||
- `WeakMap.of`
|
|
||||||
- `Map.from`
|
|
||||||
- `Set.from`
|
|
||||||
- `WeakSet.from`
|
|
||||||
- `WeakMap.from`
|
|
||||||
- Added `Math` extensions [stage 1 proposal](https://github.com/rwaldron/proposal-math-extensions), [#226](https://github.com/zloirock/core-js/issues/226):
|
|
||||||
- `Math.clamp`
|
|
||||||
- `Math.DEG_PER_RAD`
|
|
||||||
- `Math.degrees`
|
|
||||||
- `Math.fscale`
|
|
||||||
- `Math.RAD_PER_DEG`
|
|
||||||
- `Math.radians`
|
|
||||||
- `Math.scale`
|
|
||||||
- Added `Math.signbit` [stage 1 proposal](http://jfbastien.github.io/papers/Math.signbit.html)
|
|
||||||
- Updated `global` [stage 3 proposal](https://github.com/tc39/proposal-global) - added `global` global object, `System.global` deprecated
|
|
||||||
- Updated `Object.getOwnPropertyDescriptors` to the [final version](https://tc39.github.io/ecma262/2017/#sec-object.getownpropertydescriptors) - it should not create properties if descriptors are `undefined`
|
|
||||||
- Updated the list of iterable DOM collections, [#249](https://github.com/zloirock/core-js/issues/249), added:
|
|
||||||
- `CSSStyleDeclaration#@@iterator`
|
|
||||||
- `CSSValueList#@@iterator`
|
|
||||||
- `ClientRectList#@@iterator`
|
|
||||||
- `DOMRectList#@@iterator`
|
|
||||||
- `DOMStringList#@@iterator`
|
|
||||||
- `DataTransferItemList#@@iterator`
|
|
||||||
- `FileList#@@iterator`
|
|
||||||
- `HTMLAllCollection#@@iterator`
|
|
||||||
- `HTMLCollection#@@iterator`
|
|
||||||
- `HTMLFormElement#@@iterator`
|
|
||||||
- `HTMLSelectElement#@@iterator`
|
|
||||||
- `MimeTypeArray#@@iterator`
|
|
||||||
- `NamedNodeMap#@@iterator`
|
|
||||||
- `PaintRequestList#@@iterator`
|
|
||||||
- `Plugin#@@iterator`
|
|
||||||
- `PluginArray#@@iterator`
|
|
||||||
- `SVGLengthList#@@iterator`
|
|
||||||
- `SVGNumberList#@@iterator`
|
|
||||||
- `SVGPathSegList#@@iterator`
|
|
||||||
- `SVGPointList#@@iterator`
|
|
||||||
- `SVGStringList#@@iterator`
|
|
||||||
- `SVGTransformList#@@iterator`
|
|
||||||
- `SourceBufferList#@@iterator`
|
|
||||||
- `TextTrackCueList#@@iterator`
|
|
||||||
- `TextTrackList#@@iterator`
|
|
||||||
- `TouchList#@@iterator`
|
|
||||||
- Updated stages of proposals:
|
|
||||||
- [`Object.getOwnPropertyDescriptors`](https://github.com/tc39/proposal-object-getownpropertydescriptors) to [stage 4 (ES2017)](https://tc39.github.io/ecma262/2017/#sec-object.getownpropertydescriptors)
|
|
||||||
- [String padding](https://github.com/tc39/proposal-string-pad-start-end) to [stage 4 (ES2017)](https://tc39.github.io/ecma262/2017/#sec-string.prototype.padend)
|
|
||||||
- [`global`](https://github.com/tc39/proposal-global) to [stage 3](https://github.com/rwaldron/tc39-notes/blob/master/es7/2016-09/sept-28.md#revisit-systemglobal--global)
|
|
||||||
- [String trimming](https://github.com/tc39/proposal-string-left-right-trim) to [stage 2](https://github.com/rwaldron/tc39-notes/blob/master/es7/2016-07/jul-27.md#10iic-trimstarttrimend)
|
|
||||||
- Updated typed arrays to the modern (ES2016+) arguments validation,
|
|
||||||
[#293](https://github.com/zloirock/core-js/pull/293)
|
|
||||||
- Fixed `%TypedArray%.from` Safari bug, [#285](https://github.com/zloirock/core-js/issues/285)
|
|
||||||
- Fixed compatibility with old version of Prototype.js, [#278](https://github.com/zloirock/core-js/issues/278), [#289](https://github.com/zloirock/core-js/issues/289)
|
|
||||||
- `Function#name` no longer cache the result for correct behaviour with inherited constructors, [#296](https://github.com/zloirock/core-js/issues/296)
|
|
||||||
- Added errors on incorrect context of collection methods, [#272](https://github.com/zloirock/core-js/issues/272)
|
|
||||||
- Fixed conversion typed array constructors to string, fix [#300](https://github.com/zloirock/core-js/issues/300)
|
|
||||||
- Fixed `Set#size` with debugger ReactNative for Android, [#297](https://github.com/zloirock/core-js/issues/297)
|
|
||||||
- Fixed an issue with Electron-based debugger, [#230](https://github.com/zloirock/core-js/issues/230)
|
|
||||||
- Fixed compatibility with incomplete third-party `WeakMap` polyfills, [#252](https://github.com/zloirock/core-js/pull/252)
|
|
||||||
- Added a fallback for `Date#toJSON` in engines without native `Date#toISOString`, [#220](https://github.com/zloirock/core-js/issues/220)
|
|
||||||
- Added support for Sphere Dispatch API, [#286](https://github.com/zloirock/core-js/pull/286)
|
|
||||||
- Seriously changed the coding style and the [ESLint config](https://github.com/zloirock/core-js/blob/master/.eslintrc.js)
|
|
||||||
- Updated many dev dependencies (`webpack`, `uglify`, etc)
|
|
||||||
- Some other minor fixes and optimizations
|
|
||||||
|
|
||||||
##### 2.4.1 - 2016.07.18
|
|
||||||
- Fixed `script` tag for some parsers, [#204](https://github.com/zloirock/core-js/issues/204), [#216](https://github.com/zloirock/core-js/issues/216)
|
|
||||||
- Removed some unused variables, [#217](https://github.com/zloirock/core-js/issues/217), [#218](https://github.com/zloirock/core-js/issues/218)
|
|
||||||
- Fixed MS Edge `Reflect.construct` and `Reflect.apply` - they should not allow primitive as `argumentsList` argument
|
|
||||||
|
|
||||||
##### 1.2.7 [LEGACY] - 2016.07.18
|
|
||||||
- Some fixes for issues like [#159](https://github.com/zloirock/core-js/issues/159), [#186](https://github.com/zloirock/core-js/issues/186), [#194](https://github.com/zloirock/core-js/issues/194), [#207](https://github.com/zloirock/core-js/issues/207)
|
|
||||||
|
|
||||||
##### 2.4.0 - 2016.05.08
|
|
||||||
- Added `Observable`, [stage 1 proposal](https://github.com/zenparsing/es-observable)
|
|
||||||
- Fixed behavior `Object.{getOwnPropertySymbols, getOwnPropertyDescriptor}` and `Object#propertyIsEnumerable` on `Object.prototype`
|
|
||||||
- `Reflect.construct` and `Reflect.apply` should throw an error if `argumentsList` argument is not an object, [#194](https://github.com/zloirock/core-js/issues/194)
|
|
||||||
|
|
||||||
##### 2.3.0 - 2016.04.24
|
|
||||||
- Added `asap` for enqueuing microtasks, [stage 0 proposal](https://github.com/rwaldron/tc39-notes/blob/master/es6/2014-09/sept-25.md#510-globalasap-for-enqueuing-a-microtask)
|
|
||||||
- Added well-known symbol `Symbol.asyncIterator` for [stage 2 async iteration proposal](https://github.com/tc39/proposal-async-iteration)
|
|
||||||
- Added well-known symbol `Symbol.observable` for [stage 1 observables proposal](https://github.com/zenparsing/es-observable)
|
|
||||||
- `String#{padStart, padEnd}` returns original string if filler is empty string, [TC39 meeting notes](https://github.com/rwaldron/tc39-notes/blob/master/es7/2016-03/march-29.md#stringprototypepadstartpadend)
|
|
||||||
- `Object.values` and `Object.entries` moved to stage 4 from 3, [TC39 meeting notes](https://github.com/rwaldron/tc39-notes/blob/master/es7/2016-03/march-29.md#objectvalues--objectentries)
|
|
||||||
- `System.global` moved to stage 2 from 1, [TC39 meeting notes](https://github.com/rwaldron/tc39-notes/blob/master/es7/2016-03/march-29.md#systemglobal)
|
|
||||||
- `Map#toJSON` and `Set#toJSON` rejected and will be removed from the next major release, [TC39 meeting notes](https://github.com/rwaldron/tc39-notes/blob/master/es7/2016-03/march-31.md#mapprototypetojsonsetprototypetojson)
|
|
||||||
- `Error.isError` withdrawn and will be removed from the next major release, [TC39 meeting notes](https://github.com/rwaldron/tc39-notes/blob/master/es7/2016-03/march-29.md#erroriserror)
|
|
||||||
- Added fallback for `Function#name` on non-extensible functions and functions with broken `toString` conversion, [#193](https://github.com/zloirock/core-js/issues/193)
|
|
||||||
|
|
||||||
##### 2.2.2 - 2016.04.06
|
|
||||||
- Added conversion `-0` to `+0` to `Array#{indexOf, lastIndexOf}`, [ES2016 fix](https://github.com/tc39/ecma262/pull/316)
|
|
||||||
- Added fixes for some `Math` methods in Tor Browser
|
|
||||||
- `Array.{from, of}` no longer calls prototype setters
|
|
||||||
- Added workaround over Chrome DevTools strange behavior, [#186](https://github.com/zloirock/core-js/issues/186)
|
|
||||||
|
|
||||||
##### 2.2.1 - 2016.03.19
|
|
||||||
- Fixed `Object.getOwnPropertyNames(window)` `2.1+` versions bug, [#181](https://github.com/zloirock/core-js/issues/181)
|
|
||||||
|
|
||||||
##### 2.2.0 - 2016.03.15
|
|
||||||
- Added `String#matchAll`, [proposal](https://github.com/tc39/String.prototype.matchAll)
|
|
||||||
- Added `Object#__(define|lookup)[GS]etter__`, [annex B ES2017](https://github.com/tc39/ecma262/pull/381)
|
|
||||||
- Added `@@toPrimitive` methods to `Date` and `Symbol`
|
|
||||||
- Fixed `%TypedArray%#slice` in Edge ~ 13 (throws with `@@species` and wrapped / inherited constructor)
|
|
||||||
- Some other minor fixes
|
|
||||||
|
|
||||||
##### 2.1.5 - 2016.03.12
|
|
||||||
- Improved support NodeJS domains in `Promise#then`, [#180](https://github.com/zloirock/core-js/issues/180)
|
|
||||||
- Added fallback for `Date#toJSON` bug in Qt Script, [#173](https://github.com/zloirock/core-js/issues/173#issuecomment-193972502)
|
|
||||||
|
|
||||||
##### 2.1.4 - 2016.03.08
|
|
||||||
- Added fallback for `Symbol` polyfill in Qt Script, [#173](https://github.com/zloirock/core-js/issues/173)
|
|
||||||
- Added one more fallback for IE11 `Script Access Denied` error with iframes, [#165](https://github.com/zloirock/core-js/issues/165)
|
|
||||||
|
|
||||||
##### 2.1.3 - 2016.02.29
|
|
||||||
- Added fallback for [`es6-promise` package bug](https://github.com/stefanpenner/es6-promise/issues/169), [#176](https://github.com/zloirock/core-js/issues/176)
|
|
||||||
|
|
||||||
##### 2.1.2 - 2016.02.29
|
|
||||||
- Some minor `Promise` fixes:
|
|
||||||
- Browsers `rejectionhandled` event better HTML spec complaint
|
|
||||||
- Errors in unhandled rejection handlers should not cause any problems
|
|
||||||
- Fixed typo in feature detection
|
|
||||||
|
|
||||||
##### 2.1.1 - 2016.02.22
|
|
||||||
- Some `Promise` improvements:
|
|
||||||
- Feature detection:
|
|
||||||
- **Added detection unhandled rejection tracking support - now it's available everywhere**, [#140](https://github.com/zloirock/core-js/issues/140)
|
|
||||||
- Added detection `@@species` pattern support for completely correct subclassing
|
|
||||||
- Removed usage `Object.setPrototypeOf` from feature detection and noisy console message about it in FF
|
|
||||||
- `Promise.all` fixed for some very specific cases
|
|
||||||
|
|
||||||
##### 2.1.0 - 2016.02.09
|
|
||||||
- **API**:
|
|
||||||
- ES5 polyfills are split and logic, used in other polyfills, moved to internal modules
|
|
||||||
- **All entry point works in ES3 environment like IE8- without `core-js/(library/)es5`**
|
|
||||||
- **Added all missed single entry points for ES5 polyfills**
|
|
||||||
- Separated ES5 polyfills moved to the ES6 namespace. Why?
|
|
||||||
- Mainly, for prevent duplication features in different namespaces - logic of most required ES5 polyfills changed in ES6+:
|
|
||||||
- Already added changes for: `Object` statics - should accept primitives, new whitespaces lists in `String#trim`, `parse(Int|float)`, `RegExp#toString` logic, `String#split`, etc
|
|
||||||
- Should be changed in the future: `@@species` and `ToLength` logic in `Array` methods, `Date` parsing, `Function#bind`, etc
|
|
||||||
- Should not be changed only several features like `Array.isArray` and `Date.now`
|
|
||||||
- Some ES5 polyfills required for modern engines
|
|
||||||
- All old entry points should work fine, but in the next major release API can be changed
|
|
||||||
- `Object.getOwnPropertyDescriptors` moved to the stage 3, [January TC39 meeting](https://github.com/rwaldron/tc39-notes/blob/master/es7/2016-01/2016-01-28.md#objectgetownpropertydescriptors-to-stage-3-jordan-harband-low-priority-but-super-quick)
|
|
||||||
- Added `umd` option for [custom build process](https://github.com/zloirock/core-js#custom-build-from-external-scripts), [#169](https://github.com/zloirock/core-js/issues/169)
|
|
||||||
- Returned entry points for `Array` statics, removed in `2.0`, for compatibility with `babel` `6` and for future fixes
|
|
||||||
- **Deprecated**:
|
|
||||||
- `Reflect.enumerate` deprecated and will be removed from the next major release, [January TC39 meeting](https://github.com/rwaldron/tc39-notes/blob/master/es7/2016-01/2016-01-28.md#5xix-revisit-proxy-enumerate---revisit-decision-to-exhaust-iterator)
|
|
||||||
- **New Features**:
|
|
||||||
- Added [`Reflect` metadata API](https://github.com/jonathandturner/decorators/blob/master/specs/metadata.md) as a pre-strawman feature, [#152](https://github.com/zloirock/core-js/issues/152):
|
|
||||||
- `Reflect.defineMetadata`
|
|
||||||
- `Reflect.deleteMetadata`
|
|
||||||
- `Reflect.getMetadata`
|
|
||||||
- `Reflect.getMetadataKeys`
|
|
||||||
- `Reflect.getOwnMetadata`
|
|
||||||
- `Reflect.getOwnMetadataKeys`
|
|
||||||
- `Reflect.hasMetadata`
|
|
||||||
- `Reflect.hasOwnMetadata`
|
|
||||||
- `Reflect.metadata`
|
|
||||||
- Implementation / fixes `Date#toJSON`
|
|
||||||
- Fixes for `parseInt` and `Number.parseInt`
|
|
||||||
- Fixes for `parseFloat` and `Number.parseFloat`
|
|
||||||
- Fixes for `RegExp#toString`
|
|
||||||
- Fixes for `Array#sort`
|
|
||||||
- Fixes for `Number#toFixed`
|
|
||||||
- Fixes for `Number#toPrecision`
|
|
||||||
- Additional fixes for `String#split` (`RegExp#@@split`)
|
|
||||||
- **Improvements**:
|
|
||||||
- Correct subclassing wrapped collections, `Number` and `RegExp` constructors with native class syntax
|
|
||||||
- Correct support `SharedArrayBuffer` and buffers from other realms in typed arrays wrappers
|
|
||||||
- Additional validations for `Object.{defineProperty, getOwnPropertyDescriptor}` and `Reflect.defineProperty`
|
|
||||||
- **Bug Fixes**:
|
|
||||||
- Fixed some cases `Array#lastIndexOf` with negative second argument
|
|
||||||
|
|
||||||
##### 2.0.3 - 2016.01.11
|
|
||||||
- Added fallback for V8 ~ Chrome 49 `Promise` subclassing bug causes unhandled rejection on feature detection, [#159](https://github.com/zloirock/core-js/issues/159)
|
|
||||||
- Added fix for very specific environments with global `window === null`
|
|
||||||
|
|
||||||
##### 2.0.2 - 2016.01.04
|
|
||||||
- Temporarily removed `length` validation from `Uint8Array` constructor wrapper. Reason - [bug in `ws` module](https://github.com/websockets/ws/pull/645) (-> `socket.io`) which passes to `Buffer` constructor -> `Uint8Array` float and uses [the `V8` bug](https://code.google.com/p/v8/issues/detail?id=4552) for conversion to int (by the spec should be thrown an error). [It creates problems for many people.](https://github.com/karma-runner/karma/issues/1768) I hope, it will be returned after fixing this bug in `V8`.
|
|
||||||
|
|
||||||
##### 2.0.1 - 2015.12.31
|
|
||||||
- Forced usage `Promise.resolve` polyfill in the `library` version for correct work with wrapper
|
|
||||||
- `Object.assign` should be defined in the strict mode -> throw an error on extension non-extensible objects, [#154](https://github.com/zloirock/core-js/issues/154)
|
|
||||||
|
|
||||||
##### 2.0.0 - 2015.12.24
|
|
||||||
- Added implementations and fixes [Typed Arrays](https://github.com/zloirock/core-js#ecmascript-6-typed-arrays)-related features
|
|
||||||
- `ArrayBuffer`, `ArrayBuffer.isView`, `ArrayBuffer#slice`
|
|
||||||
- `DataView` with all getter / setter methods
|
|
||||||
- `Int8Array`, `Uint8Array`, `Uint8ClampedArray`, `Int16Array`, `Uint16Array`, `Int32Array`, `Uint32Array`, `Float32Array` and `Float64Array` constructors
|
|
||||||
- `%TypedArray%.{for, of}`, `%TypedArray%#{copyWithin, every, fill, filter, find, findIndex, forEach, indexOf, includes, join, lastIndexOf, map, reduce, reduceRight, reverse, set, slice, some, sort, subarray, values, keys, entries, @@iterator, ...}`
|
|
||||||
- Added [`System.global`](https://github.com/zloirock/core-js#ecmascript-7-proposals), [proposal](https://github.com/tc39/proposal-global), [November TC39 meeting](https://github.com/rwaldron/tc39-notes/tree/master/es7/2015-11/nov-19.md#systemglobal-jhd)
|
|
||||||
- Added [`Error.isError`](https://github.com/zloirock/core-js#ecmascript-7-proposals), [proposal](https://github.com/ljharb/proposal-is-error), [November TC39 meeting](https://github.com/rwaldron/tc39-notes/tree/master/es7/2015-11/nov-19.md#jhd-erroriserror)
|
|
||||||
- Added [`Math.{iaddh, isubh, imulh, umulh}`](https://github.com/zloirock/core-js#ecmascript-7-proposals), [proposal](https://gist.github.com/BrendanEich/4294d5c212a6d2254703)
|
|
||||||
- `RegExp.escape` moved from the `es7` to the non-standard `core` namespace, [July TC39 meeting](https://github.com/rwaldron/tc39-notes/blob/master/es7/2015-07/july-28.md#62-regexpescape) - too slow, but it's condition of stability, [#116](https://github.com/zloirock/core-js/issues/116)
|
|
||||||
- [`Promise`](https://github.com/zloirock/core-js#ecmascript-6-promise)
|
|
||||||
- Some performance optimisations
|
|
||||||
- Added basic support [`rejectionHandled` event / `onrejectionhandled` handler](https://github.com/zloirock/core-js#unhandled-rejection-tracking) to the polyfill
|
|
||||||
- Removed usage `@@species` from `Promise.{all, race}`, [November TC39 meeting](https://github.com/rwaldron/tc39-notes/tree/master/es7/2015-11/nov-18.md#conclusionresolution-2)
|
|
||||||
- Some improvements [collections polyfills](https://github.com/zloirock/core-js#ecmascript-6-collections)
|
|
||||||
- `O(1)` and preventing possible leaks with frozen keys, [#134](https://github.com/zloirock/core-js/issues/134)
|
|
||||||
- Correct observable state object keys
|
|
||||||
- Renamed `String#{padLeft, padRight}` -> [`String#{padStart, padEnd}`](https://github.com/zloirock/core-js#ecmascript-7-proposals), [proposal](https://github.com/tc39/proposal-string-pad-start-end), [November TC39 meeting](https://github.com/rwaldron/tc39-notes/tree/master/es7/2015-11/nov-17.md#conclusionresolution-2) (they want to rename it on each meeting?O_o), [#132](https://github.com/zloirock/core-js/issues/132)
|
|
||||||
- Added [`String#{trimStart, trimEnd}` as aliases for `String#{trimLeft, trimRight}`](https://github.com/zloirock/core-js#ecmascript-7-proposals), [proposal](https://github.com/sebmarkbage/ecmascript-string-left-right-trim), [November TC39 meeting](https://github.com/rwaldron/tc39-notes/tree/master/es7/2015-11/nov-17.md#conclusionresolution-2)
|
|
||||||
- Added [annex B HTML methods](https://github.com/zloirock/core-js#ecmascript-6-string) - ugly, but also [the part of the spec](http://www.ecma-international.org/ecma-262/6.0/#sec-string.prototype.anchor)
|
|
||||||
- Added little fix for [`Date#toString`](https://github.com/zloirock/core-js#ecmascript-6-date) - `new Date(NaN).toString()` [should be `'Invalid Date'`](http://www.ecma-international.org/ecma-262/6.0/#sec-todatestring)
|
|
||||||
- Added [`{keys, values, entries, @@iterator}` methods to DOM collections](https://github.com/zloirock/core-js#iterable-dom-collections) which should have [iterable interface](https://heycam.github.io/webidl/#idl-iterable) or should be [inherited from `Array`](https://heycam.github.io/webidl/#LegacyArrayClass) - `NodeList`, `DOMTokenList`, `MediaList`, `StyleSheetList`, `CSSRuleList`.
|
|
||||||
- Removed Mozilla `Array` generics - [deprecated and will be removed from FF](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array#Array_generic_methods), [looks like strawman is dead](http://wiki.ecmascript.org/doku.php?id=strawman:array_statics), available [alternative shim](https://github.com/plusdude/array-generics)
|
|
||||||
- Removed `core.log` module
|
|
||||||
- CommonJS API
|
|
||||||
- Added entry points for [virtual methods](https://github.com/zloirock/core-js#commonjs-and-prototype-methods-without-global-namespace-pollution)
|
|
||||||
- Added entry points for [stages proposals](https://github.com/zloirock/core-js#ecmascript-7-proposals)
|
|
||||||
- Some other minor changes
|
|
||||||
- [Custom build from external scripts](https://github.com/zloirock/core-js#custom-build-from-external-scripts) moved to the separate package for preventing problems with dependencies
|
|
||||||
- Changed `$` prefix for internal modules file names because Team Foundation Server does not support it, [#129](https://github.com/zloirock/core-js/issues/129)
|
|
||||||
- Additional fix for `SameValueZero` in V8 ~ Chromium 39-42 collections
|
|
||||||
- Additional fix for FF27 `Array` iterator
|
|
||||||
- Removed usage shortcuts for `arguments` object - old WebKit bug, [#150](https://github.com/zloirock/core-js/issues/150)
|
|
||||||
- `{Map, Set}#forEach` non-generic, [#144](https://github.com/zloirock/core-js/issues/144)
|
|
||||||
- Many other improvements
|
|
||||||
|
|
||||||
##### 1.2.6 - 2015.11.09
|
|
||||||
* Reject with `TypeError` on attempt resolve promise itself
|
|
||||||
* Correct behavior with broken `Promise` subclass constructors / methods
|
|
||||||
* Added `Promise`-based fallback for microtask
|
|
||||||
* Fixed V8 and FF `Array#{values, @@iterator}.name`
|
|
||||||
* Fixed IE7- `[1, 2].join(undefined) -> '1,2'`
|
|
||||||
* Some other fixes / improvements / optimizations
|
|
||||||
|
|
||||||
##### 1.2.5 - 2015.11.02
|
|
||||||
* Some more `Number` constructor fixes:
|
|
||||||
* Fixed V8 ~ Node 0.8 bug: `Number('+0x1')` should be `NaN`
|
|
||||||
* Fixed `Number(' 0b1\n')` case, should be `1`
|
|
||||||
* Fixed `Number()` case, should be `0`
|
|
||||||
|
|
||||||
##### 1.2.4 - 2015.11.01
|
|
||||||
* Fixed `Number('0b12') -> NaN` case in the shim
|
|
||||||
* Fixed V8 ~ Chromium 40- bug - `Weak(Map|Set)#{delete, get, has}` should not throw errors [#124](https://github.com/zloirock/core-js/issues/124)
|
|
||||||
* Some other fixes and optimizations
|
|
||||||
|
|
||||||
##### 1.2.3 - 2015.10.23
|
|
||||||
* Fixed some problems related old V8 bug `Object('a').propertyIsEnumerable(0) // => false`, for example, `Object.assign({}, 'qwe')` from the last release
|
|
||||||
* Fixed `.name` property and `Function#toString` conversion some polyfilled methods
|
|
||||||
* Fixed `Math.imul` arity in Safari 8-
|
|
||||||
|
|
||||||
##### 1.2.2 - 2015.10.18
|
|
||||||
* Improved optimisations for V8
|
|
||||||
* Fixed build process from external packages, [#120](https://github.com/zloirock/core-js/pull/120)
|
|
||||||
* One more `Object.{assign, values, entries}` fix for [**very** specific case](https://github.com/ljharb/proposal-object-values-entries/issues/5)
|
|
||||||
|
|
||||||
##### 1.2.1 - 2015.10.02
|
|
||||||
* Replaced fix `JSON.stringify` + `Symbol` behavior from `.toJSON` method to wrapping `JSON.stringify` - little more correct, [compat-table/642](https://github.com/kangax/compat-table/pull/642)
|
|
||||||
* Fixed typo which broke tasks scheduler in WebWorkers in old FF, [#114](https://github.com/zloirock/core-js/pull/114)
|
|
||||||
|
|
||||||
##### 1.2.0 - 2015.09.27
|
|
||||||
* Added browser [`Promise` rejection hook](#unhandled-rejection-tracking), [#106](https://github.com/zloirock/core-js/issues/106)
|
|
||||||
* Added correct [`IsRegExp`](http://www.ecma-international.org/ecma-262/6.0/#sec-isregexp) logic to [`String#{includes, startsWith, endsWith}`](https://github.com/zloirock/core-js/#ecmascript-6-string) and [`RegExp` constructor](https://github.com/zloirock/core-js/#ecmascript-6-regexp), `@@match` case, [example](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/match#Disabling_the_isRegExp_check)
|
|
||||||
* Updated [`String#leftPad`](https://github.com/zloirock/core-js/#ecmascript-7-proposals) [with proposal](https://github.com/ljharb/proposal-string-pad-left-right/issues/6): string filler truncated from the right side
|
|
||||||
* Replaced V8 [`Object.assign`](https://github.com/zloirock/core-js/#ecmascript-6-object) - its properties order not only [incorrect](https://github.com/sindresorhus/object-assign/issues/22), it is non-deterministic and it causes some problems
|
|
||||||
* Fixed behavior with deleted in getters properties for `Object.{`[`assign`](https://github.com/zloirock/core-js/#ecmascript-6-object)`, `[`entries, values`](https://github.com/zloirock/core-js/#ecmascript-7-proposals)`}`, [example](http://goo.gl/iQE01c)
|
|
||||||
* Fixed [`Math.sinh`](https://github.com/zloirock/core-js/#ecmascript-6-math) with very small numbers in V8 near Chromium 38
|
|
||||||
* Some other fixes and optimizations
|
|
||||||
|
|
||||||
##### 1.1.4 - 2015.09.05
|
|
||||||
* Fixed support symbols in FF34-35 [`Object.assign`](https://github.com/zloirock/core-js/#ecmascript-6-object)
|
|
||||||
* Fixed [collections iterators](https://github.com/zloirock/core-js/#ecmascript-6-iterators) in FF25-26
|
|
||||||
* Fixed non-generic WebKit [`Array.of`](https://github.com/zloirock/core-js/#ecmascript-6-array)
|
|
||||||
* Some other fixes and optimizations
|
|
||||||
|
|
||||||
##### 1.1.3 - 2015.08.29
|
|
||||||
* Fixed support Node.js domains in [`Promise`](https://github.com/zloirock/core-js/#ecmascript-6-promise), [#103](https://github.com/zloirock/core-js/issues/103)
|
|
||||||
|
|
||||||
##### 1.1.2 - 2015.08.28
|
|
||||||
* Added `toJSON` method to [`Symbol`](https://github.com/zloirock/core-js/#ecmascript-6-symbol) polyfill and to MS Edge implementation for expected `JSON.stringify` result w/o patching this method
|
|
||||||
* Replaced [`Reflect.construct`](https://github.com/zloirock/core-js/#ecmascript-6-reflect) implementations w/o correct support third argument
|
|
||||||
* Fixed `global` detection with changed `document.domain` in ~IE8, [#100](https://github.com/zloirock/core-js/issues/100)
|
|
||||||
|
|
||||||
##### 1.1.1 - 2015.08.20
|
|
||||||
* Added more correct microtask implementation for [`Promise`](#ecmascript-6-promise)
|
|
||||||
|
|
||||||
##### 1.1.0 - 2015.08.17
|
|
||||||
* Updated [string padding](https://github.com/zloirock/core-js/#ecmascript-7-proposals) to [actual proposal](https://github.com/ljharb/proposal-string-pad-left-right) - renamed, minor internal changes:
|
|
||||||
* `String#lpad` -> `String#padLeft`
|
|
||||||
* `String#rpad` -> `String#padRight`
|
|
||||||
* Added [string trim functions](#ecmascript-7-proposals) - [proposal](https://github.com/sebmarkbage/ecmascript-string-left-right-trim), defacto standard - required only for IE11- and fixed for some old engines:
|
|
||||||
* `String#trimLeft`
|
|
||||||
* `String#trimRight`
|
|
||||||
* [`String#trim`](https://github.com/zloirock/core-js/#ecmascript-6-string) fixed for some engines by es6 spec and moved from `es5` to single `es6` module
|
|
||||||
* Splitted [`es6.object.statics-accept-primitives`](https://github.com/zloirock/core-js/#ecmascript-6-object)
|
|
||||||
* Caps for `freeze`-family `Object` methods moved from `es5` to `es6` namespace and joined with [es6 wrappers](https://github.com/zloirock/core-js/#ecmascript-6-object)
|
|
||||||
* `es5` [namespace](https://github.com/zloirock/core-js/#commonjs) also includes modules, moved to `es6` namespace - you can use it as before
|
|
||||||
* Increased `MessageChannel` priority in `$.task`, [#95](https://github.com/zloirock/core-js/issues/95)
|
|
||||||
* Does not get `global.Symbol` on each getting iterator, if you wanna use alternative `Symbol` shim - add it before `core-js`
|
|
||||||
* [`Reflect.construct`](https://github.com/zloirock/core-js/#ecmascript-6-reflect) optimized and fixed for some cases
|
|
||||||
* Simplified [`Reflect.enumerate`](https://github.com/zloirock/core-js/#ecmascript-6-reflect), see [this question](https://esdiscuss.org/topic/question-about-enumerate-and-property-decision-timing)
|
|
||||||
* Some corrections in [`Math.acosh`](https://github.com/zloirock/core-js/#ecmascript-6-math)
|
|
||||||
* Fixed [`Math.imul`](https://github.com/zloirock/core-js/#ecmascript-6-math) for old WebKit
|
|
||||||
* Some fixes in string / RegExp [well-known symbols](https://github.com/zloirock/core-js/#ecmascript-6-regexp) logic
|
|
||||||
* Some other fixes and optimizations
|
|
||||||
|
|
||||||
##### 1.0.1 - 2015.07.31
|
|
||||||
* Some fixes for final MS Edge, replaced broken native `Reflect.defineProperty`
|
|
||||||
* Some minor fixes and optimizations
|
|
||||||
* Changed compression `client/*.min.js` options for safe `Function#name` and `Function#length`, should be fixed [#92](https://github.com/zloirock/core-js/issues/92)
|
|
||||||
|
|
||||||
##### 1.0.0 - 2015.07.22
|
|
||||||
* Added logic for [well-known symbols](https://github.com/zloirock/core-js/#ecmascript-6-regexp):
|
|
||||||
* `Symbol.match`
|
|
||||||
* `Symbol.replace`
|
|
||||||
* `Symbol.split`
|
|
||||||
* `Symbol.search`
|
|
||||||
* Actualized and optimized work with iterables:
|
|
||||||
* Optimized [`Map`, `Set`, `WeakMap`, `WeakSet` constructors](https://github.com/zloirock/core-js/#ecmascript-6-collections), [`Promise.all`, `Promise.race`](https://github.com/zloirock/core-js/#ecmascript-6-promise) for default `Array Iterator`
|
|
||||||
* Optimized [`Array.from`](https://github.com/zloirock/core-js/#ecmascript-6-array) for default `Array Iterator`
|
|
||||||
* Added [`core.getIteratorMethod`](https://github.com/zloirock/core-js/#ecmascript-6-iterators) helper
|
|
||||||
* Uses enumerable properties in shimmed instances - collections, iterators, etc for optimize performance
|
|
||||||
* Added support native constructors to [`Reflect.construct`](https://github.com/zloirock/core-js/#ecmascript-6-reflect) with 2 arguments
|
|
||||||
* Added support native constructors to [`Function#bind`](https://github.com/zloirock/core-js/#ecmascript-5) shim with `new`
|
|
||||||
* Removed obsolete `.clear` methods native [`Weak`-collections](https://github.com/zloirock/core-js/#ecmascript-6-collections)
|
|
||||||
* Maximum modularity, reduced minimal custom build size, separated into submodules:
|
|
||||||
* [`es6.reflect`](https://github.com/zloirock/core-js/#ecmascript-6-reflect)
|
|
||||||
* [`es6.regexp`](https://github.com/zloirock/core-js/#ecmascript-6-regexp)
|
|
||||||
* [`es6.math`](https://github.com/zloirock/core-js/#ecmascript-6-math)
|
|
||||||
* [`es6.number`](https://github.com/zloirock/core-js/#ecmascript-6-number)
|
|
||||||
* [`es7.object.to-array`](https://github.com/zloirock/core-js/#ecmascript-7-proposals)
|
|
||||||
* [`core.object`](https://github.com/zloirock/core-js/#object)
|
|
||||||
* [`core.string`](https://github.com/zloirock/core-js/#escaping-strings)
|
|
||||||
* [`core.iter-helpers`](https://github.com/zloirock/core-js/#ecmascript-6-iterators)
|
|
||||||
* Internal modules (`$`, `$.iter`, etc)
|
|
||||||
* Many other optimizations
|
|
||||||
* Final cleaning non-standard features
|
|
||||||
* Moved `$for` to [separate library](https://github.com/zloirock/forof). This work for syntax - `for-of` loop and comprehensions
|
|
||||||
* Moved `Date#{format, formatUTC}` to [separate library](https://github.com/zloirock/dtf). Standard way for this - `ECMA-402`
|
|
||||||
* Removed `Math` methods from `Number.prototype`. Slight sugar for simple `Math` methods calling
|
|
||||||
* Removed `{Array#, Array, Dict}.turn`
|
|
||||||
* Removed `core.global`
|
|
||||||
* Uses `ToNumber` instead of `ToLength` in [`Number Iterator`](https://github.com/zloirock/core-js/#number-iterator), `Array.from(2.5)` will be `[0, 1, 2]` instead of `[0, 1]`
|
|
||||||
* Fixed [#85](https://github.com/zloirock/core-js/issues/85) - invalid `Promise` unhandled rejection message in nested `setTimeout`
|
|
||||||
* Fixed [#86](https://github.com/zloirock/core-js/issues/86) - support FF extensions
|
|
||||||
* Fixed [#89](https://github.com/zloirock/core-js/issues/89) - behavior `Number` constructor in strange case
|
|
||||||
|
|
||||||
##### 0.9.18 - 2015.06.17
|
|
||||||
* Removed `/` from [`RegExp.escape`](https://github.com/zloirock/core-js/#ecmascript-7-proposals) escaped characters
|
|
||||||
|
|
||||||
##### 0.9.17 - 2015.06.14
|
|
||||||
* Updated [`RegExp.escape`](https://github.com/zloirock/core-js/#ecmascript-7-proposals) to the [latest proposal](https://github.com/benjamingr/RexExp.escape)
|
|
||||||
* Fixed conflict with webpack dev server + IE buggy behavior
|
|
||||||
|
|
||||||
##### 0.9.16 - 2015.06.11
|
|
||||||
* More correct order resolving thenable in [`Promise`](https://github.com/zloirock/core-js/#ecmascript-6-promise) polyfill
|
|
||||||
* Uses polyfill instead of [buggy V8 `Promise`](https://github.com/zloirock/core-js/issues/78)
|
|
||||||
|
|
||||||
##### 0.9.15 - 2015.06.09
|
|
||||||
* [Collections](https://github.com/zloirock/core-js/#ecmascript-6-collections) from `library` version return wrapped native instances
|
|
||||||
* Fixed collections prototype methods in `library` version
|
|
||||||
* Optimized [`Math.hypot`](https://github.com/zloirock/core-js/#ecmascript-6-math)
|
|
||||||
|
|
||||||
##### 0.9.14 - 2015.06.04
|
|
||||||
* Updated [`Promise.resolve` behavior](https://esdiscuss.org/topic/fixing-promise-resolve)
|
|
||||||
* Added fallback for IE11 buggy `Object.getOwnPropertyNames` + iframe
|
|
||||||
* Some other fixes
|
|
||||||
|
|
||||||
##### 0.9.13 - 2015.05.25
|
|
||||||
* Added fallback for [`Symbol` polyfill](https://github.com/zloirock/core-js/#ecmascript-6-symbol) for old Android
|
|
||||||
* Some other fixes
|
|
||||||
|
|
||||||
##### 0.9.12 - 2015.05.24
|
|
||||||
* Different instances `core-js` should use / recognize the same symbols
|
|
||||||
* Some fixes
|
|
||||||
|
|
||||||
##### 0.9.11 - 2015.05.18
|
|
||||||
* Simplified [custom build](https://github.com/zloirock/core-js/#custom-build)
|
|
||||||
* Added custom build js api
|
|
||||||
* Added `grunt-cli` to `devDependencies` for `npm run grunt`
|
|
||||||
* Some fixes
|
|
||||||
|
|
||||||
##### 0.9.10 - 2015.05.16
|
|
||||||
* Wrapped `Function#toString` for correct work wrapped methods / constructors with methods similar to the [`lodash` `isNative`](https://github.com/lodash/lodash/issues/1197)
|
|
||||||
* Added proto versions of methods to export object in `default` version for consistency with `library` version
|
|
||||||
|
|
||||||
##### 0.9.9 - 2015.05.14
|
|
||||||
* Wrapped `Object#propertyIsEnumerable` for [`Symbol` polyfill](https://github.com/zloirock/core-js/#ecmascript-6-symbol)
|
|
||||||
* [Added proto versions of methods to `library` for ES7 bind syntax](https://github.com/zloirock/core-js/issues/65)
|
|
||||||
* Some other fixes
|
|
||||||
|
|
||||||
##### 0.9.8 - 2015.05.12
|
|
||||||
* Fixed [`Math.hypot`](https://github.com/zloirock/core-js/#ecmascript-6-math) with negative arguments
|
|
||||||
* Added `Object#toString.toString` as fallback for [`lodash` `isNative`](https://github.com/lodash/lodash/issues/1197)
|
|
||||||
|
|
||||||
##### 0.9.7 - 2015.05.07
|
|
||||||
* Added [support DOM collections](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/slice#Streamlining_cross-browser_behavior) to IE8- `Array#slice`
|
|
||||||
|
|
||||||
##### 0.9.6 - 2015.05.01
|
|
||||||
* Added [`String#lpad`, `String#rpad`](https://github.com/zloirock/core-js/#ecmascript-7-proposals)
|
|
||||||
|
|
||||||
##### 0.9.5 - 2015.04.30
|
|
||||||
* Added cap for `Function#@@hasInstance`
|
|
||||||
* Some fixes and optimizations
|
|
||||||
|
|
||||||
##### 0.9.4 - 2015.04.27
|
|
||||||
* Fixed `RegExp` constructor
|
|
||||||
|
|
||||||
##### 0.9.3 - 2015.04.26
|
|
||||||
* Some fixes and optimizations
|
|
||||||
|
|
||||||
##### 0.9.2 - 2015.04.25
|
|
||||||
* More correct [`Promise`](https://github.com/zloirock/core-js/#ecmascript-6-promise) unhandled rejection tracking and resolving / rejection priority
|
|
||||||
|
|
||||||
##### 0.9.1 - 2015.04.25
|
|
||||||
* Fixed `__proto__`-based [`Promise`](https://github.com/zloirock/core-js/#ecmascript-6-promise) subclassing in some environments
|
|
||||||
|
|
||||||
##### 0.9.0 - 2015.04.24
|
|
||||||
* Added correct [symbols](https://github.com/zloirock/core-js/#ecmascript-6-symbol) descriptors
|
|
||||||
* Fixed behavior `Object.{assign, create, defineProperty, defineProperties, getOwnPropertyDescriptor, getOwnPropertyDescriptors}` with symbols
|
|
||||||
* Added [single entry points](https://github.com/zloirock/core-js/#commonjs) for `Object.{create, defineProperty, defineProperties}`
|
|
||||||
* Added [`Map#toJSON`](https://github.com/zloirock/core-js/#ecmascript-7-proposals)
|
|
||||||
* Removed non-standard methods `Object#[_]` and `Function#only` - they solves syntax problems, but now in compilers available arrows and ~~in near future will be available~~ [available](http://babeljs.io/blog/2015/05/14/function-bind/) [bind syntax](https://github.com/zenparsing/es-function-bind)
|
|
||||||
* Removed non-standard undocumented methods `Symbol.{pure, set}`
|
|
||||||
* Some fixes and internal changes
|
|
||||||
|
|
||||||
##### 0.8.4 - 2015.04.18
|
|
||||||
* Uses `webpack` instead of `browserify` for browser builds - more compression-friendly result
|
|
||||||
|
|
||||||
##### 0.8.3 - 2015.04.14
|
|
||||||
* Fixed `Array` statics with single entry points
|
|
||||||
|
|
||||||
##### 0.8.2 - 2015.04.13
|
|
||||||
* [`Math.fround`](https://github.com/zloirock/core-js/#ecmascript-6-math) now also works in IE9-
|
|
||||||
* Added [`Set#toJSON`](https://github.com/zloirock/core-js/#ecmascript-7-proposals)
|
|
||||||
* Some optimizations and fixes
|
|
||||||
|
|
||||||
##### 0.8.1 - 2015.04.03
|
|
||||||
* Fixed `Symbol.keyFor`
|
|
||||||
|
|
||||||
##### 0.8.0 - 2015.04.02
|
|
||||||
* Changed [CommonJS API](https://github.com/zloirock/core-js/#commonjs)
|
|
||||||
* Splitted and renamed some modules
|
|
||||||
* Added support ES3 environment (ES5 polyfill) to **all** default versions - size increases slightly (+ ~4kb w/o gzip), many issues disappear, if you don't need it - [simply include only required namespaces / features / modules](https://github.com/zloirock/core-js/#commonjs)
|
|
||||||
* Removed [abstract references](https://github.com/zenparsing/es-abstract-refs) support - proposal has been superseded =\
|
|
||||||
* [`$for.isIterable` -> `core.isIterable`, `$for.getIterator` -> `core.getIterator`](https://github.com/zloirock/core-js/#ecmascript-6-iterators), temporary available in old namespace
|
|
||||||
* Fixed iterators support in v8 `Promise.all` and `Promise.race`
|
|
||||||
* Many other fixes
|
|
||||||
|
|
||||||
##### 0.7.2 - 2015.03.09
|
|
||||||
* Some fixes
|
|
||||||
|
|
||||||
##### 0.7.1 - 2015.03.07
|
|
||||||
* Some fixes
|
|
||||||
|
|
||||||
##### 0.7.0 - 2015.03.06
|
|
||||||
* Rewritten and splitted into [CommonJS modules](https://github.com/zloirock/core-js/#commonjs)
|
|
||||||
|
|
||||||
##### 0.6.1 - 2015.02.24
|
|
||||||
* Fixed support [`Object.defineProperty`](https://github.com/zloirock/core-js/#ecmascript-5) with accessors on DOM elements on IE8
|
|
||||||
|
|
||||||
##### 0.6.0 - 2015.02.23
|
|
||||||
* Added support safe closing iteration - calling `iterator.return` on abort iteration, if it exists
|
|
||||||
* Added basic support [`Promise`](https://github.com/zloirock/core-js/#ecmascript-6-promise) unhandled rejection tracking in shim
|
|
||||||
* Added [`Object.getOwnPropertyDescriptors`](https://github.com/zloirock/core-js/#ecmascript-7-proposals)
|
|
||||||
* Removed `console` cap - creates too many problems
|
|
||||||
* Restructuring [namespaces](https://github.com/zloirock/core-js/#custom-build)
|
|
||||||
* Some fixes
|
|
||||||
|
|
||||||
##### 0.5.4 - 2015.02.15
|
|
||||||
* Some fixes
|
|
||||||
|
|
||||||
##### 0.5.3 - 2015.02.14
|
|
||||||
* Added [support binary and octal literals](https://github.com/zloirock/core-js/#ecmascript-6-number) to `Number` constructor
|
|
||||||
* Added [`Date#toISOString`](https://github.com/zloirock/core-js/#ecmascript-5)
|
|
||||||
|
|
||||||
##### 0.5.2 - 2015.02.10
|
|
||||||
* Some fixes
|
|
||||||
|
|
||||||
##### 0.5.1 - 2015.02.09
|
|
||||||
* Some fixes
|
|
||||||
|
|
||||||
##### 0.5.0 - 2015.02.08
|
|
||||||
* Systematization of modules
|
|
||||||
* Splitted [`es6` module](https://github.com/zloirock/core-js/#ecmascript-6)
|
|
||||||
* Splitted `console` module: `web.console` - only cap for missing methods, `core.log` - bound methods & additional features
|
|
||||||
* Added [`delay` method](https://github.com/zloirock/core-js/#delay)
|
|
||||||
* Some fixes
|
|
||||||
|
|
||||||
##### 0.4.10 - 2015.01.28
|
|
||||||
* [`Object.getOwnPropertySymbols`](https://github.com/zloirock/core-js/#ecmascript-6-symbol) polyfill returns array of wrapped keys
|
|
||||||
|
|
||||||
##### 0.4.9 - 2015.01.27
|
|
||||||
* FF20-24 fix
|
|
||||||
|
|
||||||
##### 0.4.8 - 2015.01.25
|
|
||||||
* Some [collections](https://github.com/zloirock/core-js/#ecmascript-6-collections) fixes
|
|
||||||
|
|
||||||
##### 0.4.7 - 2015.01.25
|
|
||||||
* Added support frozen objects as [collections](https://github.com/zloirock/core-js/#ecmascript-6-collections) keys
|
|
||||||
|
|
||||||
##### 0.4.6 - 2015.01.21
|
|
||||||
* Added [`Object.getOwnPropertySymbols`](https://github.com/zloirock/core-js/#ecmascript-6-symbol)
|
|
||||||
* Added [`NodeList.prototype[@@iterator]`](https://github.com/zloirock/core-js/#ecmascript-6-iterators)
|
|
||||||
* Added basic `@@species` logic - getter in native constructors
|
|
||||||
* Removed `Function#by`
|
|
||||||
* Some fixes
|
|
||||||
|
|
||||||
##### 0.4.5 - 2015.01.16
|
|
||||||
* Some fixes
|
|
||||||
|
|
||||||
##### 0.4.4 - 2015.01.11
|
|
||||||
* Enabled CSP support
|
|
||||||
|
|
||||||
##### 0.4.3 - 2015.01.10
|
|
||||||
* Added `Function` instances `name` property for IE9+
|
|
||||||
|
|
||||||
##### 0.4.2 - 2015.01.10
|
|
||||||
* `Object` static methods accept primitives
|
|
||||||
* `RegExp` constructor can alter flags (IE9+)
|
|
||||||
* Added `Array.prototype[Symbol.unscopables]`
|
|
||||||
|
|
||||||
##### 0.4.1 - 2015.01.05
|
|
||||||
* Some fixes
|
|
||||||
|
|
||||||
##### 0.4.0 - 2015.01.03
|
|
||||||
* Added [`es6.reflect`](https://github.com/zloirock/core-js/#ecmascript-6-reflect) module:
|
|
||||||
* Added `Reflect.apply`
|
|
||||||
* Added `Reflect.construct`
|
|
||||||
* Added `Reflect.defineProperty`
|
|
||||||
* Added `Reflect.deleteProperty`
|
|
||||||
* Added `Reflect.enumerate`
|
|
||||||
* Added `Reflect.get`
|
|
||||||
* Added `Reflect.getOwnPropertyDescriptor`
|
|
||||||
* Added `Reflect.getPrototypeOf`
|
|
||||||
* Added `Reflect.has`
|
|
||||||
* Added `Reflect.isExtensible`
|
|
||||||
* Added `Reflect.preventExtensions`
|
|
||||||
* Added `Reflect.set`
|
|
||||||
* Added `Reflect.setPrototypeOf`
|
|
||||||
* `core-js` methods now can use external `Symbol.iterator` polyfill
|
|
||||||
* Some fixes
|
|
||||||
|
|
||||||
##### 0.3.3 - 2014.12.28
|
|
||||||
* [Console cap](https://github.com/zloirock/core-js/#console) excluded from node.js default builds
|
|
||||||
|
|
||||||
##### 0.3.2 - 2014.12.25
|
|
||||||
* Added cap for [ES5](https://github.com/zloirock/core-js/#ecmascript-5) freeze-family methods
|
|
||||||
* Fixed `console` bug
|
|
||||||
|
|
||||||
##### 0.3.1 - 2014.12.23
|
|
||||||
* Some fixes
|
|
||||||
|
|
||||||
##### 0.3.0 - 2014.12.23
|
|
||||||
* Optimize [`Map` & `Set`](https://github.com/zloirock/core-js/#ecmascript-6-collections):
|
|
||||||
* Use entries chain on hash table
|
|
||||||
* Fast & correct iteration
|
|
||||||
* Iterators moved to [`es6`](https://github.com/zloirock/core-js/#ecmascript-6) and [`es6.collections`](https://github.com/zloirock/core-js/#ecmascript-6-collections) modules
|
|
||||||
|
|
||||||
##### 0.2.5 - 2014.12.20
|
|
||||||
* `console` no longer shortcut for `console.log` (compatibility problems)
|
|
||||||
* Some fixes
|
|
||||||
|
|
||||||
##### 0.2.4 - 2014.12.17
|
|
||||||
* Better compliance of ES6
|
|
||||||
* Added [`Math.fround`](https://github.com/zloirock/core-js/#ecmascript-6-math) (IE10+)
|
|
||||||
* Some fixes
|
|
||||||
|
|
||||||
##### 0.2.3 - 2014.12.15
|
|
||||||
* [Symbols](https://github.com/zloirock/core-js/#ecmascript-6-symbol):
|
|
||||||
* Added option to disable addition setter to `Object.prototype` for Symbol polyfill:
|
|
||||||
* Added `Symbol.useSimple`
|
|
||||||
* Added `Symbol.useSetter`
|
|
||||||
* Added cap for well-known Symbols:
|
|
||||||
* Added `Symbol.hasInstance`
|
|
||||||
* Added `Symbol.isConcatSpreadable`
|
|
||||||
* Added `Symbol.match`
|
|
||||||
* Added `Symbol.replace`
|
|
||||||
* Added `Symbol.search`
|
|
||||||
* Added `Symbol.species`
|
|
||||||
* Added `Symbol.split`
|
|
||||||
* Added `Symbol.toPrimitive`
|
|
||||||
* Added `Symbol.unscopables`
|
|
||||||
|
|
||||||
##### 0.2.2 - 2014.12.13
|
|
||||||
* Added [`RegExp#flags`](https://github.com/zloirock/core-js/#ecmascript-6-regexp) ([December 2014 Draft Rev 29](http://wiki.ecmascript.org/doku.php?id=harmony:specification_drafts#december_6_2014_draft_rev_29))
|
|
||||||
* Added [`String.raw`](https://github.com/zloirock/core-js/#ecmascript-6-string)
|
|
||||||
|
|
||||||
##### 0.2.1 - 2014.12.12
|
|
||||||
* Repair converting -0 to +0 in [native collections](https://github.com/zloirock/core-js/#ecmascript-6-collections)
|
|
||||||
|
|
||||||
##### 0.2.0 - 2014.12.06
|
|
||||||
* Added [`es7.proposals`](https://github.com/zloirock/core-js/#ecmascript-7-proposals) and [`es7.abstract-refs`](https://github.com/zenparsing/es-abstract-refs) modules
|
|
||||||
* Added [`String#at`](https://github.com/zloirock/core-js/#ecmascript-7-proposals)
|
|
||||||
* Added real [`String Iterator`](https://github.com/zloirock/core-js/#ecmascript-6-iterators), older versions used Array Iterator
|
|
||||||
* Added abstract references support:
|
|
||||||
* Added `Symbol.referenceGet`
|
|
||||||
* Added `Symbol.referenceSet`
|
|
||||||
* Added `Symbol.referenceDelete`
|
|
||||||
* Added `Function#@@referenceGet`
|
|
||||||
* Added `Map#@@referenceGet`
|
|
||||||
* Added `Map#@@referenceSet`
|
|
||||||
* Added `Map#@@referenceDelete`
|
|
||||||
* Added `WeakMap#@@referenceGet`
|
|
||||||
* Added `WeakMap#@@referenceSet`
|
|
||||||
* Added `WeakMap#@@referenceDelete`
|
|
||||||
* Added `Dict.{...methods}[@@referenceGet]`
|
|
||||||
* Removed deprecated `.contains` methods
|
|
||||||
* Some fixes
|
|
||||||
|
|
||||||
##### 0.1.5 - 2014.12.01
|
|
||||||
* Added [`Array#copyWithin`](https://github.com/zloirock/core-js/#ecmascript-6-array)
|
|
||||||
* Added [`String#codePointAt`](https://github.com/zloirock/core-js/#ecmascript-6-string)
|
|
||||||
* Added [`String.fromCodePoint`](https://github.com/zloirock/core-js/#ecmascript-6-string)
|
|
||||||
|
|
||||||
##### 0.1.4 - 2014.11.27
|
|
||||||
* Added [`Dict.mapPairs`](https://github.com/zloirock/core-js/#dict)
|
|
||||||
|
|
||||||
##### 0.1.3 - 2014.11.20
|
|
||||||
* [TC39 November meeting](https://github.com/rwaldron/tc39-notes/tree/master/es6/2014-11):
|
|
||||||
* [`.contains` -> `.includes`](https://github.com/rwaldron/tc39-notes/blob/master/es6/2014-11/nov-18.md#51--44-arrayprototypecontains-and-stringprototypecontains)
|
|
||||||
* `String#contains` -> [`String#includes`](https://github.com/zloirock/core-js/#ecmascript-6-string)
|
|
||||||
* `Array#contains` -> [`Array#includes`](https://github.com/zloirock/core-js/#ecmascript-7-proposals)
|
|
||||||
* `Dict.contains` -> [`Dict.includes`](https://github.com/zloirock/core-js/#dict)
|
|
||||||
* [Removed `WeakMap#clear`](https://github.com/rwaldron/tc39-notes/blob/master/es6/2014-11/nov-19.md#412-should-weakmapweakset-have-a-clear-method-markm)
|
|
||||||
* [Removed `WeakSet#clear`](https://github.com/rwaldron/tc39-notes/blob/master/es6/2014-11/nov-19.md#412-should-weakmapweakset-have-a-clear-method-markm)
|
|
||||||
|
|
||||||
##### 0.1.2 - 2014.11.19
|
|
||||||
* `Map` & `Set` bug fix
|
|
||||||
|
|
||||||
##### 0.1.1 - 2014.11.18
|
|
||||||
* Public release
|
|
|
@ -1,3 +0,0 @@
|
||||||
require('LiveScript');
|
|
||||||
// eslint-disable-next-line import/no-unresolved
|
|
||||||
module.exports = require('./build/Gruntfile');
|
|
|
@ -1,19 +0,0 @@
|
||||||
Copyright (c) 2014-2019 Denis Pushkarev
|
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
|
||||||
in the Software without restriction, including without limitation the rights
|
|
||||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
copies of the Software, and to permit persons to whom the Software is
|
|
||||||
furnished to do so, subject to the following conditions:
|
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be included in
|
|
||||||
all copies or substantial portions of the Software.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
||||||
THE SOFTWARE.
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,49 +0,0 @@
|
||||||
{
|
|
||||||
"name": "core.js",
|
|
||||||
"main": "client/core.js",
|
|
||||||
"version": "2.6.11",
|
|
||||||
"description": "Standard Library",
|
|
||||||
"keywords": [
|
|
||||||
"ES3",
|
|
||||||
"ES5",
|
|
||||||
"ES6",
|
|
||||||
"ES7",
|
|
||||||
"ES2015",
|
|
||||||
"ES2016",
|
|
||||||
"ES2017",
|
|
||||||
"ECMAScript 3",
|
|
||||||
"ECMAScript 5",
|
|
||||||
"ECMAScript 6",
|
|
||||||
"ECMAScript 7",
|
|
||||||
"ECMAScript 2015",
|
|
||||||
"ECMAScript 2016",
|
|
||||||
"ECMAScript 2017",
|
|
||||||
"Harmony",
|
|
||||||
"Strawman",
|
|
||||||
"Map",
|
|
||||||
"Set",
|
|
||||||
"WeakMap",
|
|
||||||
"WeakSet",
|
|
||||||
"Promise",
|
|
||||||
"Symbol",
|
|
||||||
"TypedArray",
|
|
||||||
"setImmediate",
|
|
||||||
"Dict",
|
|
||||||
"polyfill",
|
|
||||||
"shim"
|
|
||||||
],
|
|
||||||
"authors": [
|
|
||||||
"Denis Pushkarev <zloirock@zloirock.ru> (http://zloirock.ru/)"
|
|
||||||
],
|
|
||||||
"license": "MIT",
|
|
||||||
"homepage": "https://github.com/zloirock/core-js",
|
|
||||||
"repository": {
|
|
||||||
"type": "git",
|
|
||||||
"url": "https://github.com/zloirock/core-js.git"
|
|
||||||
},
|
|
||||||
"ignore": [
|
|
||||||
"build",
|
|
||||||
"node_modules",
|
|
||||||
"tests"
|
|
||||||
]
|
|
||||||
}
|
|
|
@ -1,86 +0,0 @@
|
||||||
require! <[./build fs ./config]>
|
|
||||||
module.exports = (grunt)->
|
|
||||||
grunt.loadNpmTasks \grunt-contrib-clean
|
|
||||||
grunt.loadNpmTasks \grunt-contrib-copy
|
|
||||||
grunt.loadNpmTasks \grunt-contrib-uglify
|
|
||||||
grunt.loadNpmTasks \grunt-contrib-watch
|
|
||||||
grunt.loadNpmTasks \grunt-livescript
|
|
||||||
grunt.loadNpmTasks \grunt-karma
|
|
||||||
grunt.initConfig do
|
|
||||||
pkg: grunt.file.readJSON './package.json'
|
|
||||||
uglify: build:
|
|
||||||
files: '<%=grunt.option("path")%>.min.js': '<%=grunt.option("path")%>.js'
|
|
||||||
options:
|
|
||||||
mangle: {+keep_fnames}
|
|
||||||
compress: {+keep_fnames, +pure_getters}
|
|
||||||
output: {max_line_len: 32000}
|
|
||||||
ie8: on
|
|
||||||
sourceMap: on
|
|
||||||
banner: config.banner
|
|
||||||
livescript: src: files:
|
|
||||||
'./tests/helpers.js': './tests/helpers/*'
|
|
||||||
'./tests/tests.js': './tests/tests/*'
|
|
||||||
'./tests/library.js': './tests/library/*'
|
|
||||||
'./tests/es.js': './tests/tests/es*'
|
|
||||||
'./tests/experimental.js': './tests/experimental/*'
|
|
||||||
'./build/index.js': './build/build.ls*'
|
|
||||||
clean: <[./library]>
|
|
||||||
copy: lib: files:
|
|
||||||
* expand: on
|
|
||||||
cwd: './'
|
|
||||||
src: <[es5/** es6/** es7/** stage/** web/** core/** fn/** index.js shim.js]>
|
|
||||||
dest: './library/'
|
|
||||||
* expand: on
|
|
||||||
cwd: './'
|
|
||||||
src: <[modules/*]>
|
|
||||||
dest: './library/'
|
|
||||||
filter: \isFile
|
|
||||||
* expand: on
|
|
||||||
cwd: './modules/library/'
|
|
||||||
src: '*'
|
|
||||||
dest: './library/modules/'
|
|
||||||
watch:
|
|
||||||
core:
|
|
||||||
files: './modules/*'
|
|
||||||
tasks: \default
|
|
||||||
tests:
|
|
||||||
files: './tests/tests/*'
|
|
||||||
tasks: \livescript
|
|
||||||
karma:
|
|
||||||
'options':
|
|
||||||
configFile: './tests/karma.conf.js'
|
|
||||||
browsers: <[PhantomJS]>
|
|
||||||
singleRun: on
|
|
||||||
'default': {}
|
|
||||||
'library': files: <[client/library.js tests/helpers.js tests/library.js]>map -> src: it
|
|
||||||
grunt.registerTask \build (options)->
|
|
||||||
done = @async!
|
|
||||||
build {
|
|
||||||
modules: (options || 'es5,es6,es7,js,web,core')split \,
|
|
||||||
blacklist: (grunt.option(\blacklist) || '')split \,
|
|
||||||
library: grunt.option(\library) in <[yes on true]>
|
|
||||||
umd: grunt.option(\umd) not in <[no off false]>
|
|
||||||
}
|
|
||||||
.then !->
|
|
||||||
grunt.option(\path) || grunt.option(\path, './custom')
|
|
||||||
fs.writeFile grunt.option(\path) + '.js', it, done
|
|
||||||
.catch !->
|
|
||||||
console.error it
|
|
||||||
process.exit 1
|
|
||||||
grunt.registerTask \client ->
|
|
||||||
grunt.option \library ''
|
|
||||||
grunt.option \path './client/core'
|
|
||||||
grunt.task.run <[build:es5,es6,es7,js,web,core uglify]>
|
|
||||||
grunt.registerTask \library ->
|
|
||||||
grunt.option \library 'true'
|
|
||||||
grunt.option \path './client/library'
|
|
||||||
grunt.task.run <[build:es5,es6,es7,js,web,core uglify]>
|
|
||||||
grunt.registerTask \shim ->
|
|
||||||
grunt.option \library ''
|
|
||||||
grunt.option \path './client/shim'
|
|
||||||
grunt.task.run <[build:es5,es6,es7,js,web uglify]>
|
|
||||||
grunt.registerTask \e ->
|
|
||||||
grunt.option \library ''>
|
|
||||||
grunt.option \path './client/core'
|
|
||||||
grunt.task.run <[build:es5,es6,es7,js,web,core,exp uglify]>
|
|
||||||
grunt.registerTask \default <[clean copy client library shim]>
|
|
|
@ -1,62 +0,0 @@
|
||||||
require! {
|
|
||||||
'../library/fn/promise': Promise
|
|
||||||
'./config': {list, experimental, libraryBlacklist, es5SpecialCase, banner}
|
|
||||||
fs: {readFile, writeFile, unlink}
|
|
||||||
path: {basename, dirname, join}
|
|
||||||
webpack, temp
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = ({modules = [], blacklist = [], library = no, umd = on})->
|
|
||||||
resolve, reject <~! new Promise _
|
|
||||||
let @ = modules.reduce ((memo, it)-> memo[it] = on; memo), {}
|
|
||||||
if @exp => for experimental => @[..] = on
|
|
||||||
if @es5 => for es5SpecialCase => @[..] = on
|
|
||||||
for ns of @
|
|
||||||
if @[ns]
|
|
||||||
for name in list
|
|
||||||
if name.indexOf("#ns.") is 0 and name not in experimental
|
|
||||||
@[name] = on
|
|
||||||
|
|
||||||
if library => blacklist ++= libraryBlacklist
|
|
||||||
for ns in blacklist
|
|
||||||
for name in list
|
|
||||||
if name is ns or name.indexOf("#ns.") is 0
|
|
||||||
@[name] = no
|
|
||||||
|
|
||||||
TARGET = temp.path {suffix: '.js'}
|
|
||||||
|
|
||||||
err, info <~! webpack do
|
|
||||||
entry: list.filter(~> @[it]).map ~>
|
|
||||||
if library => join __dirname, '..', 'library', 'modules', it
|
|
||||||
else join __dirname, '..', 'modules', it
|
|
||||||
output:
|
|
||||||
path: dirname TARGET
|
|
||||||
filename: basename "./#TARGET"
|
|
||||||
if err => return reject err
|
|
||||||
|
|
||||||
err, script <~! readFile TARGET
|
|
||||||
if err => return reject err
|
|
||||||
|
|
||||||
err <~! unlink TARGET
|
|
||||||
if err => return reject err
|
|
||||||
|
|
||||||
if umd
|
|
||||||
exportScript = """
|
|
||||||
// CommonJS export
|
|
||||||
if (typeof module != 'undefined' && module.exports) module.exports = __e;
|
|
||||||
// RequireJS export
|
|
||||||
else if (typeof define == 'function' && define.amd) define(function () { return __e; });
|
|
||||||
// Export to global object
|
|
||||||
else __g.core = __e;
|
|
||||||
"""
|
|
||||||
else
|
|
||||||
exportScript = ""
|
|
||||||
|
|
||||||
resolve """
|
|
||||||
#banner
|
|
||||||
!function(__e, __g, undefined){
|
|
||||||
'use strict';
|
|
||||||
#script
|
|
||||||
#exportScript
|
|
||||||
}(1, 1);
|
|
||||||
"""
|
|
|
@ -1,275 +0,0 @@
|
||||||
module.exports = {
|
|
||||||
list: [
|
|
||||||
'es6.symbol',
|
|
||||||
'es6.object.define-property',
|
|
||||||
'es6.object.define-properties',
|
|
||||||
'es6.object.get-own-property-descriptor',
|
|
||||||
'es6.object.create',
|
|
||||||
'es6.object.get-prototype-of',
|
|
||||||
'es6.object.keys',
|
|
||||||
'es6.object.get-own-property-names',
|
|
||||||
'es6.object.freeze',
|
|
||||||
'es6.object.seal',
|
|
||||||
'es6.object.prevent-extensions',
|
|
||||||
'es6.object.is-frozen',
|
|
||||||
'es6.object.is-sealed',
|
|
||||||
'es6.object.is-extensible',
|
|
||||||
'es6.object.assign',
|
|
||||||
'es6.object.is',
|
|
||||||
'es6.object.set-prototype-of',
|
|
||||||
'es6.object.to-string',
|
|
||||||
'es6.function.bind',
|
|
||||||
'es6.function.name',
|
|
||||||
'es6.function.has-instance',
|
|
||||||
'es6.number.constructor',
|
|
||||||
'es6.number.to-fixed',
|
|
||||||
'es6.number.to-precision',
|
|
||||||
'es6.number.epsilon',
|
|
||||||
'es6.number.is-finite',
|
|
||||||
'es6.number.is-integer',
|
|
||||||
'es6.number.is-nan',
|
|
||||||
'es6.number.is-safe-integer',
|
|
||||||
'es6.number.max-safe-integer',
|
|
||||||
'es6.number.min-safe-integer',
|
|
||||||
'es6.number.parse-float',
|
|
||||||
'es6.number.parse-int',
|
|
||||||
'es6.parse-int',
|
|
||||||
'es6.parse-float',
|
|
||||||
'es6.math.acosh',
|
|
||||||
'es6.math.asinh',
|
|
||||||
'es6.math.atanh',
|
|
||||||
'es6.math.cbrt',
|
|
||||||
'es6.math.clz32',
|
|
||||||
'es6.math.cosh',
|
|
||||||
'es6.math.expm1',
|
|
||||||
'es6.math.fround',
|
|
||||||
'es6.math.hypot',
|
|
||||||
'es6.math.imul',
|
|
||||||
'es6.math.log10',
|
|
||||||
'es6.math.log1p',
|
|
||||||
'es6.math.log2',
|
|
||||||
'es6.math.sign',
|
|
||||||
'es6.math.sinh',
|
|
||||||
'es6.math.tanh',
|
|
||||||
'es6.math.trunc',
|
|
||||||
'es6.string.from-code-point',
|
|
||||||
'es6.string.raw',
|
|
||||||
'es6.string.trim',
|
|
||||||
'es6.string.code-point-at',
|
|
||||||
'es6.string.ends-with',
|
|
||||||
'es6.string.includes',
|
|
||||||
'es6.string.repeat',
|
|
||||||
'es6.string.starts-with',
|
|
||||||
'es6.string.iterator',
|
|
||||||
'es6.string.anchor',
|
|
||||||
'es6.string.big',
|
|
||||||
'es6.string.blink',
|
|
||||||
'es6.string.bold',
|
|
||||||
'es6.string.fixed',
|
|
||||||
'es6.string.fontcolor',
|
|
||||||
'es6.string.fontsize',
|
|
||||||
'es6.string.italics',
|
|
||||||
'es6.string.link',
|
|
||||||
'es6.string.small',
|
|
||||||
'es6.string.strike',
|
|
||||||
'es6.string.sub',
|
|
||||||
'es6.string.sup',
|
|
||||||
'es6.array.is-array',
|
|
||||||
'es6.array.from',
|
|
||||||
'es6.array.of',
|
|
||||||
'es6.array.join',
|
|
||||||
'es6.array.slice',
|
|
||||||
'es6.array.sort',
|
|
||||||
'es6.array.for-each',
|
|
||||||
'es6.array.map',
|
|
||||||
'es6.array.filter',
|
|
||||||
'es6.array.some',
|
|
||||||
'es6.array.every',
|
|
||||||
'es6.array.reduce',
|
|
||||||
'es6.array.reduce-right',
|
|
||||||
'es6.array.index-of',
|
|
||||||
'es6.array.last-index-of',
|
|
||||||
'es6.array.copy-within',
|
|
||||||
'es6.array.fill',
|
|
||||||
'es6.array.find',
|
|
||||||
'es6.array.find-index',
|
|
||||||
'es6.array.iterator',
|
|
||||||
'es6.array.species',
|
|
||||||
'es6.regexp.constructor',
|
|
||||||
'es6.regexp.exec',
|
|
||||||
'es6.regexp.to-string',
|
|
||||||
'es6.regexp.flags',
|
|
||||||
'es6.regexp.match',
|
|
||||||
'es6.regexp.replace',
|
|
||||||
'es6.regexp.search',
|
|
||||||
'es6.regexp.split',
|
|
||||||
'es6.promise',
|
|
||||||
'es6.map',
|
|
||||||
'es6.set',
|
|
||||||
'es6.weak-map',
|
|
||||||
'es6.weak-set',
|
|
||||||
'es6.reflect.apply',
|
|
||||||
'es6.reflect.construct',
|
|
||||||
'es6.reflect.define-property',
|
|
||||||
'es6.reflect.delete-property',
|
|
||||||
'es6.reflect.enumerate',
|
|
||||||
'es6.reflect.get',
|
|
||||||
'es6.reflect.get-own-property-descriptor',
|
|
||||||
'es6.reflect.get-prototype-of',
|
|
||||||
'es6.reflect.has',
|
|
||||||
'es6.reflect.is-extensible',
|
|
||||||
'es6.reflect.own-keys',
|
|
||||||
'es6.reflect.prevent-extensions',
|
|
||||||
'es6.reflect.set',
|
|
||||||
'es6.reflect.set-prototype-of',
|
|
||||||
'es6.date.now',
|
|
||||||
'es6.date.to-json',
|
|
||||||
'es6.date.to-iso-string',
|
|
||||||
'es6.date.to-string',
|
|
||||||
'es6.date.to-primitive',
|
|
||||||
'es6.typed.array-buffer',
|
|
||||||
'es6.typed.data-view',
|
|
||||||
'es6.typed.int8-array',
|
|
||||||
'es6.typed.uint8-array',
|
|
||||||
'es6.typed.uint8-clamped-array',
|
|
||||||
'es6.typed.int16-array',
|
|
||||||
'es6.typed.uint16-array',
|
|
||||||
'es6.typed.int32-array',
|
|
||||||
'es6.typed.uint32-array',
|
|
||||||
'es6.typed.float32-array',
|
|
||||||
'es6.typed.float64-array',
|
|
||||||
'es7.array.includes',
|
|
||||||
'es7.array.flat-map',
|
|
||||||
'es7.array.flatten',
|
|
||||||
'es7.string.at',
|
|
||||||
'es7.string.pad-start',
|
|
||||||
'es7.string.pad-end',
|
|
||||||
'es7.string.trim-left',
|
|
||||||
'es7.string.trim-right',
|
|
||||||
'es7.string.match-all',
|
|
||||||
'es7.symbol.async-iterator',
|
|
||||||
'es7.symbol.observable',
|
|
||||||
'es7.object.get-own-property-descriptors',
|
|
||||||
'es7.object.values',
|
|
||||||
'es7.object.entries',
|
|
||||||
'es7.object.define-getter',
|
|
||||||
'es7.object.define-setter',
|
|
||||||
'es7.object.lookup-getter',
|
|
||||||
'es7.object.lookup-setter',
|
|
||||||
'es7.map.to-json',
|
|
||||||
'es7.set.to-json',
|
|
||||||
'es7.map.of',
|
|
||||||
'es7.set.of',
|
|
||||||
'es7.weak-map.of',
|
|
||||||
'es7.weak-set.of',
|
|
||||||
'es7.map.from',
|
|
||||||
'es7.set.from',
|
|
||||||
'es7.weak-map.from',
|
|
||||||
'es7.weak-set.from',
|
|
||||||
'es7.global',
|
|
||||||
'es7.system.global',
|
|
||||||
'es7.error.is-error',
|
|
||||||
'es7.math.clamp',
|
|
||||||
'es7.math.deg-per-rad',
|
|
||||||
'es7.math.degrees',
|
|
||||||
'es7.math.fscale',
|
|
||||||
'es7.math.iaddh',
|
|
||||||
'es7.math.isubh',
|
|
||||||
'es7.math.imulh',
|
|
||||||
'es7.math.rad-per-deg',
|
|
||||||
'es7.math.radians',
|
|
||||||
'es7.math.scale',
|
|
||||||
'es7.math.umulh',
|
|
||||||
'es7.math.signbit',
|
|
||||||
'es7.promise.finally',
|
|
||||||
'es7.promise.try',
|
|
||||||
'es7.reflect.define-metadata',
|
|
||||||
'es7.reflect.delete-metadata',
|
|
||||||
'es7.reflect.get-metadata',
|
|
||||||
'es7.reflect.get-metadata-keys',
|
|
||||||
'es7.reflect.get-own-metadata',
|
|
||||||
'es7.reflect.get-own-metadata-keys',
|
|
||||||
'es7.reflect.has-metadata',
|
|
||||||
'es7.reflect.has-own-metadata',
|
|
||||||
'es7.reflect.metadata',
|
|
||||||
'es7.asap',
|
|
||||||
'es7.observable',
|
|
||||||
'web.immediate',
|
|
||||||
'web.dom.iterable',
|
|
||||||
'web.timers',
|
|
||||||
'core.dict',
|
|
||||||
'core.get-iterator-method',
|
|
||||||
'core.get-iterator',
|
|
||||||
'core.is-iterable',
|
|
||||||
'core.delay',
|
|
||||||
'core.function.part',
|
|
||||||
'core.object.is-object',
|
|
||||||
'core.object.classof',
|
|
||||||
'core.object.define',
|
|
||||||
'core.object.make',
|
|
||||||
'core.number.iterator',
|
|
||||||
'core.regexp.escape',
|
|
||||||
'core.string.escape-html',
|
|
||||||
'core.string.unescape-html',
|
|
||||||
],
|
|
||||||
experimental: [
|
|
||||||
],
|
|
||||||
libraryBlacklist: [
|
|
||||||
'es6.object.to-string',
|
|
||||||
'es6.function.name',
|
|
||||||
'es6.regexp.constructor',
|
|
||||||
'es6.regexp.to-string',
|
|
||||||
'es6.regexp.flags',
|
|
||||||
'es6.regexp.match',
|
|
||||||
'es6.regexp.replace',
|
|
||||||
'es6.regexp.search',
|
|
||||||
'es6.regexp.split',
|
|
||||||
'es6.number.constructor',
|
|
||||||
'es6.date.to-string',
|
|
||||||
'es6.date.to-primitive',
|
|
||||||
],
|
|
||||||
es5SpecialCase: [
|
|
||||||
'es6.object.create',
|
|
||||||
'es6.object.define-property',
|
|
||||||
'es6.object.define-properties',
|
|
||||||
'es6.object.get-own-property-descriptor',
|
|
||||||
'es6.object.get-prototype-of',
|
|
||||||
'es6.object.keys',
|
|
||||||
'es6.object.get-own-property-names',
|
|
||||||
'es6.object.freeze',
|
|
||||||
'es6.object.seal',
|
|
||||||
'es6.object.prevent-extensions',
|
|
||||||
'es6.object.is-frozen',
|
|
||||||
'es6.object.is-sealed',
|
|
||||||
'es6.object.is-extensible',
|
|
||||||
'es6.function.bind',
|
|
||||||
'es6.array.is-array',
|
|
||||||
'es6.array.join',
|
|
||||||
'es6.array.slice',
|
|
||||||
'es6.array.sort',
|
|
||||||
'es6.array.for-each',
|
|
||||||
'es6.array.map',
|
|
||||||
'es6.array.filter',
|
|
||||||
'es6.array.some',
|
|
||||||
'es6.array.every',
|
|
||||||
'es6.array.reduce',
|
|
||||||
'es6.array.reduce-right',
|
|
||||||
'es6.array.index-of',
|
|
||||||
'es6.array.last-index-of',
|
|
||||||
'es6.number.to-fixed',
|
|
||||||
'es6.number.to-precision',
|
|
||||||
'es6.date.now',
|
|
||||||
'es6.date.to-iso-string',
|
|
||||||
'es6.date.to-json',
|
|
||||||
'es6.string.trim',
|
|
||||||
'es6.regexp.to-string',
|
|
||||||
'es6.parse-int',
|
|
||||||
'es6.parse-float',
|
|
||||||
],
|
|
||||||
banner: '/**\n' +
|
|
||||||
' * core-js ' + require('../package').version + '\n' +
|
|
||||||
' * https://github.com/zloirock/core-js\n' +
|
|
||||||
' * License: http://rock.mit-license.org\n' +
|
|
||||||
' * © ' + new Date().getFullYear() + ' Denis Pushkarev\n' +
|
|
||||||
' */',
|
|
||||||
};
|
|
|
@ -1,104 +0,0 @@
|
||||||
// Generated by LiveScript 1.4.0
|
|
||||||
(function(){
|
|
||||||
var Promise, ref$, list, experimental, libraryBlacklist, es5SpecialCase, banner, readFile, writeFile, unlink, basename, dirname, join, webpack, temp;
|
|
||||||
Promise = require('../library/fn/promise');
|
|
||||||
ref$ = require('./config'), list = ref$.list, experimental = ref$.experimental, libraryBlacklist = ref$.libraryBlacklist, es5SpecialCase = ref$.es5SpecialCase, banner = ref$.banner;
|
|
||||||
ref$ = require('fs'), readFile = ref$.readFile, writeFile = ref$.writeFile, unlink = ref$.unlink;
|
|
||||||
ref$ = require('path'), basename = ref$.basename, dirname = ref$.dirname, join = ref$.join;
|
|
||||||
webpack = require('webpack');
|
|
||||||
temp = require('temp');
|
|
||||||
module.exports = function(arg$){
|
|
||||||
var modules, ref$, blacklist, library, umd, this$ = this;
|
|
||||||
modules = (ref$ = arg$.modules) != null
|
|
||||||
? ref$
|
|
||||||
: [], blacklist = (ref$ = arg$.blacklist) != null
|
|
||||||
? ref$
|
|
||||||
: [], library = (ref$ = arg$.library) != null ? ref$ : false, umd = (ref$ = arg$.umd) != null ? ref$ : true;
|
|
||||||
return new Promise(function(resolve, reject){
|
|
||||||
(function(){
|
|
||||||
var i$, x$, ref$, len$, y$, ns, name, j$, len1$, TARGET, this$ = this;
|
|
||||||
if (this.exp) {
|
|
||||||
for (i$ = 0, len$ = (ref$ = experimental).length; i$ < len$; ++i$) {
|
|
||||||
x$ = ref$[i$];
|
|
||||||
this[x$] = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (this.es5) {
|
|
||||||
for (i$ = 0, len$ = (ref$ = es5SpecialCase).length; i$ < len$; ++i$) {
|
|
||||||
y$ = ref$[i$];
|
|
||||||
this[y$] = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (ns in this) {
|
|
||||||
if (this[ns]) {
|
|
||||||
for (i$ = 0, len$ = (ref$ = list).length; i$ < len$; ++i$) {
|
|
||||||
name = ref$[i$];
|
|
||||||
if (name.indexOf(ns + ".") === 0 && !in$(name, experimental)) {
|
|
||||||
this[name] = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (library) {
|
|
||||||
blacklist = blacklist.concat(libraryBlacklist);
|
|
||||||
}
|
|
||||||
for (i$ = 0, len$ = blacklist.length; i$ < len$; ++i$) {
|
|
||||||
ns = blacklist[i$];
|
|
||||||
for (j$ = 0, len1$ = (ref$ = list).length; j$ < len1$; ++j$) {
|
|
||||||
name = ref$[j$];
|
|
||||||
if (name === ns || name.indexOf(ns + ".") === 0) {
|
|
||||||
this[name] = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
TARGET = temp.path({
|
|
||||||
suffix: '.js'
|
|
||||||
});
|
|
||||||
webpack({
|
|
||||||
entry: list.filter(function(it){
|
|
||||||
return this$[it];
|
|
||||||
}).map(function(it){
|
|
||||||
if (library) {
|
|
||||||
return join(__dirname, '..', 'library', 'modules', it);
|
|
||||||
} else {
|
|
||||||
return join(__dirname, '..', 'modules', it);
|
|
||||||
}
|
|
||||||
}),
|
|
||||||
output: {
|
|
||||||
path: dirname(TARGET),
|
|
||||||
filename: basename("./" + TARGET)
|
|
||||||
}
|
|
||||||
}, function(err, info){
|
|
||||||
if (err) {
|
|
||||||
return reject(err);
|
|
||||||
}
|
|
||||||
readFile(TARGET, function(err, script){
|
|
||||||
if (err) {
|
|
||||||
return reject(err);
|
|
||||||
}
|
|
||||||
unlink(TARGET, function(err){
|
|
||||||
var exportScript;
|
|
||||||
if (err) {
|
|
||||||
return reject(err);
|
|
||||||
}
|
|
||||||
if (umd) {
|
|
||||||
exportScript = "// CommonJS export\nif (typeof module != 'undefined' && module.exports) module.exports = __e;\n// RequireJS export\nelse if (typeof define == 'function' && define.amd) define(function () { return __e; });\n// Export to global object\nelse __g.core = __e;";
|
|
||||||
} else {
|
|
||||||
exportScript = "";
|
|
||||||
}
|
|
||||||
resolve("" + banner + "\n!function(__e, __g, undefined){\n'use strict';\n" + script + "\n" + exportScript + "\n}(1, 1);");
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}.call(modules.reduce(function(memo, it){
|
|
||||||
memo[it] = true;
|
|
||||||
return memo;
|
|
||||||
}, {})));
|
|
||||||
});
|
|
||||||
};
|
|
||||||
function in$(x, xs){
|
|
||||||
var i = -1, l = xs.length >>> 0;
|
|
||||||
while (++i < l) if (x === xs[i]) return true;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}).call(this);
|
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -1,2 +0,0 @@
|
||||||
require('../modules/core.function.part');
|
|
||||||
module.exports = require('../modules/_core')._;
|
|
|
@ -1,2 +0,0 @@
|
||||||
require('../modules/core.delay');
|
|
||||||
module.exports = require('../modules/_core').delay;
|
|
|
@ -1,2 +0,0 @@
|
||||||
require('../modules/core.dict');
|
|
||||||
module.exports = require('../modules/_core').Dict;
|
|
|
@ -1,2 +0,0 @@
|
||||||
require('../modules/core.function.part');
|
|
||||||
module.exports = require('../modules/_core').Function;
|
|
|
@ -1,15 +0,0 @@
|
||||||
require('../modules/core.dict');
|
|
||||||
require('../modules/core.get-iterator-method');
|
|
||||||
require('../modules/core.get-iterator');
|
|
||||||
require('../modules/core.is-iterable');
|
|
||||||
require('../modules/core.delay');
|
|
||||||
require('../modules/core.function.part');
|
|
||||||
require('../modules/core.object.is-object');
|
|
||||||
require('../modules/core.object.classof');
|
|
||||||
require('../modules/core.object.define');
|
|
||||||
require('../modules/core.object.make');
|
|
||||||
require('../modules/core.number.iterator');
|
|
||||||
require('../modules/core.regexp.escape');
|
|
||||||
require('../modules/core.string.escape-html');
|
|
||||||
require('../modules/core.string.unescape-html');
|
|
||||||
module.exports = require('../modules/_core');
|
|
|
@ -1,2 +0,0 @@
|
||||||
require('../modules/core.number.iterator');
|
|
||||||
module.exports = require('../modules/_core').Number;
|
|
|
@ -1,5 +0,0 @@
|
||||||
require('../modules/core.object.is-object');
|
|
||||||
require('../modules/core.object.classof');
|
|
||||||
require('../modules/core.object.define');
|
|
||||||
require('../modules/core.object.make');
|
|
||||||
module.exports = require('../modules/_core').Object;
|
|
|
@ -1,2 +0,0 @@
|
||||||
require('../modules/core.regexp.escape');
|
|
||||||
module.exports = require('../modules/_core').RegExp;
|
|
|
@ -1,3 +0,0 @@
|
||||||
require('../modules/core.string.escape-html');
|
|
||||||
require('../modules/core.string.unescape-html');
|
|
||||||
module.exports = require('../modules/_core').String;
|
|
|
@ -1,37 +0,0 @@
|
||||||
require('../modules/es6.object.create');
|
|
||||||
require('../modules/es6.object.define-property');
|
|
||||||
require('../modules/es6.object.define-properties');
|
|
||||||
require('../modules/es6.object.get-own-property-descriptor');
|
|
||||||
require('../modules/es6.object.get-prototype-of');
|
|
||||||
require('../modules/es6.object.keys');
|
|
||||||
require('../modules/es6.object.get-own-property-names');
|
|
||||||
require('../modules/es6.object.freeze');
|
|
||||||
require('../modules/es6.object.seal');
|
|
||||||
require('../modules/es6.object.prevent-extensions');
|
|
||||||
require('../modules/es6.object.is-frozen');
|
|
||||||
require('../modules/es6.object.is-sealed');
|
|
||||||
require('../modules/es6.object.is-extensible');
|
|
||||||
require('../modules/es6.function.bind');
|
|
||||||
require('../modules/es6.array.is-array');
|
|
||||||
require('../modules/es6.array.join');
|
|
||||||
require('../modules/es6.array.slice');
|
|
||||||
require('../modules/es6.array.sort');
|
|
||||||
require('../modules/es6.array.for-each');
|
|
||||||
require('../modules/es6.array.map');
|
|
||||||
require('../modules/es6.array.filter');
|
|
||||||
require('../modules/es6.array.some');
|
|
||||||
require('../modules/es6.array.every');
|
|
||||||
require('../modules/es6.array.reduce');
|
|
||||||
require('../modules/es6.array.reduce-right');
|
|
||||||
require('../modules/es6.array.index-of');
|
|
||||||
require('../modules/es6.array.last-index-of');
|
|
||||||
require('../modules/es6.number.to-fixed');
|
|
||||||
require('../modules/es6.number.to-precision');
|
|
||||||
require('../modules/es6.date.now');
|
|
||||||
require('../modules/es6.date.to-iso-string');
|
|
||||||
require('../modules/es6.date.to-json');
|
|
||||||
require('../modules/es6.parse-int');
|
|
||||||
require('../modules/es6.parse-float');
|
|
||||||
require('../modules/es6.string.trim');
|
|
||||||
require('../modules/es6.regexp.to-string');
|
|
||||||
module.exports = require('../modules/_core');
|
|
|
@ -1,23 +0,0 @@
|
||||||
require('../modules/es6.string.iterator');
|
|
||||||
require('../modules/es6.array.is-array');
|
|
||||||
require('../modules/es6.array.from');
|
|
||||||
require('../modules/es6.array.of');
|
|
||||||
require('../modules/es6.array.join');
|
|
||||||
require('../modules/es6.array.slice');
|
|
||||||
require('../modules/es6.array.sort');
|
|
||||||
require('../modules/es6.array.for-each');
|
|
||||||
require('../modules/es6.array.map');
|
|
||||||
require('../modules/es6.array.filter');
|
|
||||||
require('../modules/es6.array.some');
|
|
||||||
require('../modules/es6.array.every');
|
|
||||||
require('../modules/es6.array.reduce');
|
|
||||||
require('../modules/es6.array.reduce-right');
|
|
||||||
require('../modules/es6.array.index-of');
|
|
||||||
require('../modules/es6.array.last-index-of');
|
|
||||||
require('../modules/es6.array.copy-within');
|
|
||||||
require('../modules/es6.array.fill');
|
|
||||||
require('../modules/es6.array.find');
|
|
||||||
require('../modules/es6.array.find-index');
|
|
||||||
require('../modules/es6.array.species');
|
|
||||||
require('../modules/es6.array.iterator');
|
|
||||||
module.exports = require('../modules/_core').Array;
|
|
|
@ -1,6 +0,0 @@
|
||||||
require('../modules/es6.date.now');
|
|
||||||
require('../modules/es6.date.to-json');
|
|
||||||
require('../modules/es6.date.to-iso-string');
|
|
||||||
require('../modules/es6.date.to-string');
|
|
||||||
require('../modules/es6.date.to-primitive');
|
|
||||||
module.exports = Date;
|
|
|
@ -1,4 +0,0 @@
|
||||||
require('../modules/es6.function.bind');
|
|
||||||
require('../modules/es6.function.name');
|
|
||||||
require('../modules/es6.function.has-instance');
|
|
||||||
module.exports = require('../modules/_core').Function;
|
|
|
@ -1,139 +0,0 @@
|
||||||
require('../modules/es6.symbol');
|
|
||||||
require('../modules/es6.object.create');
|
|
||||||
require('../modules/es6.object.define-property');
|
|
||||||
require('../modules/es6.object.define-properties');
|
|
||||||
require('../modules/es6.object.get-own-property-descriptor');
|
|
||||||
require('../modules/es6.object.get-prototype-of');
|
|
||||||
require('../modules/es6.object.keys');
|
|
||||||
require('../modules/es6.object.get-own-property-names');
|
|
||||||
require('../modules/es6.object.freeze');
|
|
||||||
require('../modules/es6.object.seal');
|
|
||||||
require('../modules/es6.object.prevent-extensions');
|
|
||||||
require('../modules/es6.object.is-frozen');
|
|
||||||
require('../modules/es6.object.is-sealed');
|
|
||||||
require('../modules/es6.object.is-extensible');
|
|
||||||
require('../modules/es6.object.assign');
|
|
||||||
require('../modules/es6.object.is');
|
|
||||||
require('../modules/es6.object.set-prototype-of');
|
|
||||||
require('../modules/es6.object.to-string');
|
|
||||||
require('../modules/es6.function.bind');
|
|
||||||
require('../modules/es6.function.name');
|
|
||||||
require('../modules/es6.function.has-instance');
|
|
||||||
require('../modules/es6.parse-int');
|
|
||||||
require('../modules/es6.parse-float');
|
|
||||||
require('../modules/es6.number.constructor');
|
|
||||||
require('../modules/es6.number.to-fixed');
|
|
||||||
require('../modules/es6.number.to-precision');
|
|
||||||
require('../modules/es6.number.epsilon');
|
|
||||||
require('../modules/es6.number.is-finite');
|
|
||||||
require('../modules/es6.number.is-integer');
|
|
||||||
require('../modules/es6.number.is-nan');
|
|
||||||
require('../modules/es6.number.is-safe-integer');
|
|
||||||
require('../modules/es6.number.max-safe-integer');
|
|
||||||
require('../modules/es6.number.min-safe-integer');
|
|
||||||
require('../modules/es6.number.parse-float');
|
|
||||||
require('../modules/es6.number.parse-int');
|
|
||||||
require('../modules/es6.math.acosh');
|
|
||||||
require('../modules/es6.math.asinh');
|
|
||||||
require('../modules/es6.math.atanh');
|
|
||||||
require('../modules/es6.math.cbrt');
|
|
||||||
require('../modules/es6.math.clz32');
|
|
||||||
require('../modules/es6.math.cosh');
|
|
||||||
require('../modules/es6.math.expm1');
|
|
||||||
require('../modules/es6.math.fround');
|
|
||||||
require('../modules/es6.math.hypot');
|
|
||||||
require('../modules/es6.math.imul');
|
|
||||||
require('../modules/es6.math.log10');
|
|
||||||
require('../modules/es6.math.log1p');
|
|
||||||
require('../modules/es6.math.log2');
|
|
||||||
require('../modules/es6.math.sign');
|
|
||||||
require('../modules/es6.math.sinh');
|
|
||||||
require('../modules/es6.math.tanh');
|
|
||||||
require('../modules/es6.math.trunc');
|
|
||||||
require('../modules/es6.string.from-code-point');
|
|
||||||
require('../modules/es6.string.raw');
|
|
||||||
require('../modules/es6.string.trim');
|
|
||||||
require('../modules/es6.string.iterator');
|
|
||||||
require('../modules/es6.string.code-point-at');
|
|
||||||
require('../modules/es6.string.ends-with');
|
|
||||||
require('../modules/es6.string.includes');
|
|
||||||
require('../modules/es6.string.repeat');
|
|
||||||
require('../modules/es6.string.starts-with');
|
|
||||||
require('../modules/es6.string.anchor');
|
|
||||||
require('../modules/es6.string.big');
|
|
||||||
require('../modules/es6.string.blink');
|
|
||||||
require('../modules/es6.string.bold');
|
|
||||||
require('../modules/es6.string.fixed');
|
|
||||||
require('../modules/es6.string.fontcolor');
|
|
||||||
require('../modules/es6.string.fontsize');
|
|
||||||
require('../modules/es6.string.italics');
|
|
||||||
require('../modules/es6.string.link');
|
|
||||||
require('../modules/es6.string.small');
|
|
||||||
require('../modules/es6.string.strike');
|
|
||||||
require('../modules/es6.string.sub');
|
|
||||||
require('../modules/es6.string.sup');
|
|
||||||
require('../modules/es6.date.now');
|
|
||||||
require('../modules/es6.date.to-json');
|
|
||||||
require('../modules/es6.date.to-iso-string');
|
|
||||||
require('../modules/es6.date.to-string');
|
|
||||||
require('../modules/es6.date.to-primitive');
|
|
||||||
require('../modules/es6.array.is-array');
|
|
||||||
require('../modules/es6.array.from');
|
|
||||||
require('../modules/es6.array.of');
|
|
||||||
require('../modules/es6.array.join');
|
|
||||||
require('../modules/es6.array.slice');
|
|
||||||
require('../modules/es6.array.sort');
|
|
||||||
require('../modules/es6.array.for-each');
|
|
||||||
require('../modules/es6.array.map');
|
|
||||||
require('../modules/es6.array.filter');
|
|
||||||
require('../modules/es6.array.some');
|
|
||||||
require('../modules/es6.array.every');
|
|
||||||
require('../modules/es6.array.reduce');
|
|
||||||
require('../modules/es6.array.reduce-right');
|
|
||||||
require('../modules/es6.array.index-of');
|
|
||||||
require('../modules/es6.array.last-index-of');
|
|
||||||
require('../modules/es6.array.copy-within');
|
|
||||||
require('../modules/es6.array.fill');
|
|
||||||
require('../modules/es6.array.find');
|
|
||||||
require('../modules/es6.array.find-index');
|
|
||||||
require('../modules/es6.array.species');
|
|
||||||
require('../modules/es6.array.iterator');
|
|
||||||
require('../modules/es6.regexp.constructor');
|
|
||||||
require('../modules/es6.regexp.exec');
|
|
||||||
require('../modules/es6.regexp.to-string');
|
|
||||||
require('../modules/es6.regexp.flags');
|
|
||||||
require('../modules/es6.regexp.match');
|
|
||||||
require('../modules/es6.regexp.replace');
|
|
||||||
require('../modules/es6.regexp.search');
|
|
||||||
require('../modules/es6.regexp.split');
|
|
||||||
require('../modules/es6.promise');
|
|
||||||
require('../modules/es6.map');
|
|
||||||
require('../modules/es6.set');
|
|
||||||
require('../modules/es6.weak-map');
|
|
||||||
require('../modules/es6.weak-set');
|
|
||||||
require('../modules/es6.typed.array-buffer');
|
|
||||||
require('../modules/es6.typed.data-view');
|
|
||||||
require('../modules/es6.typed.int8-array');
|
|
||||||
require('../modules/es6.typed.uint8-array');
|
|
||||||
require('../modules/es6.typed.uint8-clamped-array');
|
|
||||||
require('../modules/es6.typed.int16-array');
|
|
||||||
require('../modules/es6.typed.uint16-array');
|
|
||||||
require('../modules/es6.typed.int32-array');
|
|
||||||
require('../modules/es6.typed.uint32-array');
|
|
||||||
require('../modules/es6.typed.float32-array');
|
|
||||||
require('../modules/es6.typed.float64-array');
|
|
||||||
require('../modules/es6.reflect.apply');
|
|
||||||
require('../modules/es6.reflect.construct');
|
|
||||||
require('../modules/es6.reflect.define-property');
|
|
||||||
require('../modules/es6.reflect.delete-property');
|
|
||||||
require('../modules/es6.reflect.enumerate');
|
|
||||||
require('../modules/es6.reflect.get');
|
|
||||||
require('../modules/es6.reflect.get-own-property-descriptor');
|
|
||||||
require('../modules/es6.reflect.get-prototype-of');
|
|
||||||
require('../modules/es6.reflect.has');
|
|
||||||
require('../modules/es6.reflect.is-extensible');
|
|
||||||
require('../modules/es6.reflect.own-keys');
|
|
||||||
require('../modules/es6.reflect.prevent-extensions');
|
|
||||||
require('../modules/es6.reflect.set');
|
|
||||||
require('../modules/es6.reflect.set-prototype-of');
|
|
||||||
module.exports = require('../modules/_core');
|
|
|
@ -1,5 +0,0 @@
|
||||||
require('../modules/es6.object.to-string');
|
|
||||||
require('../modules/es6.string.iterator');
|
|
||||||
require('../modules/web.dom.iterable');
|
|
||||||
require('../modules/es6.map');
|
|
||||||
module.exports = require('../modules/_core').Map;
|
|
|
@ -1,18 +0,0 @@
|
||||||
require('../modules/es6.math.acosh');
|
|
||||||
require('../modules/es6.math.asinh');
|
|
||||||
require('../modules/es6.math.atanh');
|
|
||||||
require('../modules/es6.math.cbrt');
|
|
||||||
require('../modules/es6.math.clz32');
|
|
||||||
require('../modules/es6.math.cosh');
|
|
||||||
require('../modules/es6.math.expm1');
|
|
||||||
require('../modules/es6.math.fround');
|
|
||||||
require('../modules/es6.math.hypot');
|
|
||||||
require('../modules/es6.math.imul');
|
|
||||||
require('../modules/es6.math.log10');
|
|
||||||
require('../modules/es6.math.log1p');
|
|
||||||
require('../modules/es6.math.log2');
|
|
||||||
require('../modules/es6.math.sign');
|
|
||||||
require('../modules/es6.math.sinh');
|
|
||||||
require('../modules/es6.math.tanh');
|
|
||||||
require('../modules/es6.math.trunc');
|
|
||||||
module.exports = require('../modules/_core').Math;
|
|
|
@ -1,13 +0,0 @@
|
||||||
require('../modules/es6.number.constructor');
|
|
||||||
require('../modules/es6.number.to-fixed');
|
|
||||||
require('../modules/es6.number.to-precision');
|
|
||||||
require('../modules/es6.number.epsilon');
|
|
||||||
require('../modules/es6.number.is-finite');
|
|
||||||
require('../modules/es6.number.is-integer');
|
|
||||||
require('../modules/es6.number.is-nan');
|
|
||||||
require('../modules/es6.number.is-safe-integer');
|
|
||||||
require('../modules/es6.number.max-safe-integer');
|
|
||||||
require('../modules/es6.number.min-safe-integer');
|
|
||||||
require('../modules/es6.number.parse-float');
|
|
||||||
require('../modules/es6.number.parse-int');
|
|
||||||
module.exports = require('../modules/_core').Number;
|
|
|
@ -1,20 +0,0 @@
|
||||||
require('../modules/es6.symbol');
|
|
||||||
require('../modules/es6.object.create');
|
|
||||||
require('../modules/es6.object.define-property');
|
|
||||||
require('../modules/es6.object.define-properties');
|
|
||||||
require('../modules/es6.object.get-own-property-descriptor');
|
|
||||||
require('../modules/es6.object.get-prototype-of');
|
|
||||||
require('../modules/es6.object.keys');
|
|
||||||
require('../modules/es6.object.get-own-property-names');
|
|
||||||
require('../modules/es6.object.freeze');
|
|
||||||
require('../modules/es6.object.seal');
|
|
||||||
require('../modules/es6.object.prevent-extensions');
|
|
||||||
require('../modules/es6.object.is-frozen');
|
|
||||||
require('../modules/es6.object.is-sealed');
|
|
||||||
require('../modules/es6.object.is-extensible');
|
|
||||||
require('../modules/es6.object.assign');
|
|
||||||
require('../modules/es6.object.is');
|
|
||||||
require('../modules/es6.object.set-prototype-of');
|
|
||||||
require('../modules/es6.object.to-string');
|
|
||||||
|
|
||||||
module.exports = require('../modules/_core').Object;
|
|
|
@ -1,2 +0,0 @@
|
||||||
require('../modules/es6.parse-float');
|
|
||||||
module.exports = require('../modules/_core').parseFloat;
|
|
|
@ -1,2 +0,0 @@
|
||||||
require('../modules/es6.parse-int');
|
|
||||||
module.exports = require('../modules/_core').parseInt;
|
|
|
@ -1,5 +0,0 @@
|
||||||
require('../modules/es6.object.to-string');
|
|
||||||
require('../modules/es6.string.iterator');
|
|
||||||
require('../modules/web.dom.iterable');
|
|
||||||
require('../modules/es6.promise');
|
|
||||||
module.exports = require('../modules/_core').Promise;
|
|
|
@ -1,15 +0,0 @@
|
||||||
require('../modules/es6.reflect.apply');
|
|
||||||
require('../modules/es6.reflect.construct');
|
|
||||||
require('../modules/es6.reflect.define-property');
|
|
||||||
require('../modules/es6.reflect.delete-property');
|
|
||||||
require('../modules/es6.reflect.enumerate');
|
|
||||||
require('../modules/es6.reflect.get');
|
|
||||||
require('../modules/es6.reflect.get-own-property-descriptor');
|
|
||||||
require('../modules/es6.reflect.get-prototype-of');
|
|
||||||
require('../modules/es6.reflect.has');
|
|
||||||
require('../modules/es6.reflect.is-extensible');
|
|
||||||
require('../modules/es6.reflect.own-keys');
|
|
||||||
require('../modules/es6.reflect.prevent-extensions');
|
|
||||||
require('../modules/es6.reflect.set');
|
|
||||||
require('../modules/es6.reflect.set-prototype-of');
|
|
||||||
module.exports = require('../modules/_core').Reflect;
|
|
|
@ -1,9 +0,0 @@
|
||||||
require('../modules/es6.regexp.constructor');
|
|
||||||
require('../modules/es6.regexp.exec');
|
|
||||||
require('../modules/es6.regexp.to-string');
|
|
||||||
require('../modules/es6.regexp.flags');
|
|
||||||
require('../modules/es6.regexp.match');
|
|
||||||
require('../modules/es6.regexp.replace');
|
|
||||||
require('../modules/es6.regexp.search');
|
|
||||||
require('../modules/es6.regexp.split');
|
|
||||||
module.exports = require('../modules/_core').RegExp;
|
|
|
@ -1,5 +0,0 @@
|
||||||
require('../modules/es6.object.to-string');
|
|
||||||
require('../modules/es6.string.iterator');
|
|
||||||
require('../modules/web.dom.iterable');
|
|
||||||
require('../modules/es6.set');
|
|
||||||
module.exports = require('../modules/_core').Set;
|
|
|
@ -1,27 +0,0 @@
|
||||||
require('../modules/es6.string.from-code-point');
|
|
||||||
require('../modules/es6.string.raw');
|
|
||||||
require('../modules/es6.string.trim');
|
|
||||||
require('../modules/es6.string.iterator');
|
|
||||||
require('../modules/es6.string.code-point-at');
|
|
||||||
require('../modules/es6.string.ends-with');
|
|
||||||
require('../modules/es6.string.includes');
|
|
||||||
require('../modules/es6.string.repeat');
|
|
||||||
require('../modules/es6.string.starts-with');
|
|
||||||
require('../modules/es6.string.anchor');
|
|
||||||
require('../modules/es6.string.big');
|
|
||||||
require('../modules/es6.string.blink');
|
|
||||||
require('../modules/es6.string.bold');
|
|
||||||
require('../modules/es6.string.fixed');
|
|
||||||
require('../modules/es6.string.fontcolor');
|
|
||||||
require('../modules/es6.string.fontsize');
|
|
||||||
require('../modules/es6.string.italics');
|
|
||||||
require('../modules/es6.string.link');
|
|
||||||
require('../modules/es6.string.small');
|
|
||||||
require('../modules/es6.string.strike');
|
|
||||||
require('../modules/es6.string.sub');
|
|
||||||
require('../modules/es6.string.sup');
|
|
||||||
require('../modules/es6.regexp.match');
|
|
||||||
require('../modules/es6.regexp.replace');
|
|
||||||
require('../modules/es6.regexp.search');
|
|
||||||
require('../modules/es6.regexp.split');
|
|
||||||
module.exports = require('../modules/_core').String;
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue