@putout/engine-loader 11.1.1 → 11.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,12 +1,13 @@
1
1
  'use strict';
2
2
 
3
+ const {nanomemoize} = require('nano-memoize');
3
4
  const tryToCatch = require('try-to-catch');
4
5
  const {simpleImport} = require('./simple-import');
5
6
 
6
7
  const {assign} = Object;
7
8
  const stub = () => () => {};
8
9
 
9
- module.exports.createAsyncLoader = (type) => async (name, load) => {
10
+ module.exports.createAsyncLoader = (type) => nanomemoize(async (name, load) => {
10
11
  if (name === 'none')
11
12
  return stub();
12
13
 
@@ -16,7 +17,7 @@ module.exports.createAsyncLoader = (type) => async (name, load) => {
16
17
  throw e;
17
18
 
18
19
  return reporter;
19
- };
20
+ });
20
21
 
21
22
  async function cleverLoad(names, load = simpleImport) {
22
23
  let e;
@@ -2,16 +2,16 @@
2
2
 
3
3
  const isEnabled = require('./is-enabled');
4
4
  const parseRules = require('./parse-rules');
5
- const {nanomemoize} = require('nano-memoize');
6
5
  const {createAsyncLoader} = require('./async-loader');
7
6
  const parsePluginNames = require('./parse-plugin-names');
8
7
  const validateRules = require('./validate-rules');
9
8
  const validatePlugin = require('./validate-plugin');
10
9
  const {mergeRules} = require('./merge-rules');
11
10
 
11
+ const loadPluginAsync = createAsyncLoader('plugin');
12
12
  const isString = (a) => typeof a === 'string';
13
13
 
14
- module.exports.loadPluginsAsync = nanomemoize(async (options) => {
14
+ module.exports.loadPluginsAsync = async (options) => {
15
15
  check(options);
16
16
 
17
17
  const {pluginNames = [], rules = {}} = options;
@@ -49,14 +49,13 @@ module.exports.loadPluginsAsync = nanomemoize(async (options) => {
49
49
  }
50
50
 
51
51
  return result;
52
- });
52
+ };
53
53
 
54
54
  function splitRule(rule) {
55
55
  return [rule, 'putout'];
56
56
  }
57
57
 
58
58
  async function loadPlugins({items, loadedRules}) {
59
- const loadPlugin = createAsyncLoader('plugin');
60
59
  const promises = [];
61
60
  const enabledRules = [];
62
61
 
@@ -67,7 +66,7 @@ async function loadPlugins({items, loadedRules}) {
67
66
  checkRule(rule);
68
67
 
69
68
  const [name] = splitRule(rule);
70
- const plugin = itemPlugin || loadPlugin(name);
69
+ const plugin = itemPlugin || loadPluginAsync(name);
71
70
 
72
71
  enabledRules.push(rule);
73
72
  promises.push(plugin);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putout/engine-loader",
3
- "version": "11.1.1",
3
+ "version": "11.1.2",
4
4
  "type": "commonjs",
5
5
  "author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
6
6
  "description": "load plugins and prepare them to run",