refactor: remove nodent, use ajv-async bundle instead

master
Evgeny Poberezkin 2017-11-08 21:52:03 +00:00
parent 482c80c49c
commit ceefaa2a05
6 changed files with 12 additions and 12 deletions

View File

@ -551,9 +551,7 @@ validate({ userId: 1, postId: 19 })
### Using transpilers with asynchronous validation functions.
To use a transpiler you should separately install it (or load its bundle in the browser).
Ajv npm package includes minified browser bundle of regenerator and nodent in dist folder.
[ajv-async](https://github.com/epoberezkin/ajv-async) uses [nodent](https://github.com/MatAtBread/nodent) to transpile async functions. To use another transpiler you should separately install it (or load its bundle in the browser).
#### Using nodent
@ -561,6 +559,8 @@ Ajv npm package includes minified browser bundle of regenerator and nodent in di
```javascript
var ajv = new Ajv;
require('ajv-async')(ajv);
// in the browser if you want to load ajv-async bundle separately you can:
// window.ajvAsync(ajv);
var validate = ajv.compile(schema); // transpiled es7 async function
validate(data).then(successFunc).catch(errorFunc);
```

View File

@ -17,7 +17,7 @@ module.exports = function(config) {
files: [
'dist/ajv.min.js',
'node_modules/chai/chai.js',
'dist/nodent.min.js',
'node_modules/ajv-async/dist/ajv-async.min.js',
'node_modules/bluebird/js/browser/bluebird.core.min.js',
'.browser/*.spec.js'
],

View File

@ -112,7 +112,7 @@ module.exports = function(config) {
files: [
'dist/ajv.min.js',
'node_modules/chai/chai.js',
'dist/nodent.min.js',
'node_modules/ajv-async/dist/ajv-async.min.js',
'node_modules/bluebird/js/browser/bluebird.core.min.js',
'.browser/*.spec.js'
],

View File

@ -19,15 +19,13 @@
"test-debug": "mocha spec/*.spec.js --debug-brk -R spec",
"test-cov": "nyc npm run test-spec",
"test-ts": "tsc --target ES5 --noImplicitAny lib/ajv.d.ts",
"bundle": "node ./scripts/bundle.js . Ajv pure_getters",
"bundle-nodent": "node ./scripts/bundle.js nodent",
"bundle-all": "del-cli dist && npm run bundle && npm run bundle-nodent",
"bundle": "del-cli dist && node ./scripts/bundle.js . Ajv pure_getters",
"bundle-beautify": "node ./scripts/bundle.js js-beautify",
"build": "del-cli lib/dotjs/*.js '!lib/dotjs/index.js' && node scripts/compile-dots.js",
"test-karma": "karma start --single-run --browsers PhantomJS",
"test-browser": "del-cli .browser && npm run bundle-all && scripts/prepare-tests && npm run test-karma",
"test-browser": "del-cli .browser && npm run bundle && scripts/prepare-tests && npm run test-karma",
"test": "npm run jshint && npm run eslint && npm run test-ts && npm run build && npm run test-cov && if-node-version 4 npm run test-browser",
"prepublish": "npm run build && npm run bundle-all",
"prepublish": "npm run build && npm run bundle",
"watch": "watch 'npm run build' ./lib/dot"
},
"nyc": {
@ -88,7 +86,6 @@
"karma-phantomjs-launcher": "^1.0.0",
"karma-sauce-launcher": "^1.1.0",
"mocha": "^4.0.0",
"nodent": "^3.1.3",
"nyc": "^11.0.2",
"phantomjs-prebuilt": "^2.1.4",
"pre-commit": "^1.1.1",

3
spec/ajv-async.js Normal file
View File

@ -0,0 +1,3 @@
'use strict';
module.exports = typeof window == 'object' ? window.ajvAsync : require('' + 'ajv-async');

View File

@ -2,7 +2,7 @@
var Ajv = require('./ajv')
, util = require('../lib/compile/util')
, setupAsync = require('ajv-async');
, setupAsync = require('./ajv-async');
module.exports = getAjvInstances;