source: trip-planner-front/node_modules/ajv-formats/dist/index.js@ 76712b2

Last change on this file since 76712b2 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 1.5 KB
Line 
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3const formats_1 = require("./formats");
4const limit_1 = require("./limit");
5const codegen_1 = require("ajv/dist/compile/codegen");
6const fullName = new codegen_1.Name("fullFormats");
7const fastName = new codegen_1.Name("fastFormats");
8const formatsPlugin = (ajv, opts = { keywords: true }) => {
9 if (Array.isArray(opts)) {
10 addFormats(ajv, opts, formats_1.fullFormats, fullName);
11 return ajv;
12 }
13 const [formats, exportName] = opts.mode === "fast" ? [formats_1.fastFormats, fastName] : [formats_1.fullFormats, fullName];
14 const list = opts.formats || formats_1.formatNames;
15 addFormats(ajv, list, formats, exportName);
16 if (opts.keywords)
17 limit_1.default(ajv);
18 return ajv;
19};
20formatsPlugin.get = (name, mode = "full") => {
21 const formats = mode === "fast" ? formats_1.fastFormats : formats_1.fullFormats;
22 const f = formats[name];
23 if (!f)
24 throw new Error(`Unknown format "${name}"`);
25 return f;
26};
27function addFormats(ajv, list, fs, exportName) {
28 var _a;
29 var _b;
30 (_a = (_b = ajv.opts.code).formats) !== null && _a !== void 0 ? _a : (_b.formats = codegen_1._ `require("ajv-formats/dist/formats").${exportName}`);
31 for (const f of list)
32 ajv.addFormat(f, fs[f]);
33}
34module.exports = exports = formatsPlugin;
35Object.defineProperty(exports, "__esModule", { value: true });
36exports.default = formatsPlugin;
37//# sourceMappingURL=index.js.map
Note: See TracBrowser for help on using the repository browser.