@putout/operator-json 1.2.0 → 1.3.0

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.
Files changed (2) hide show
  1. package/lib/json.js +27 -6
  2. package/package.json +1 -4
package/lib/json.js CHANGED
@@ -3,22 +3,43 @@
3
3
  const removeBlankLines = require('remove-blank-lines');
4
4
 
5
5
  const cut = (a) => a.slice(0, a.indexOf('('));
6
- const createPrefix = (name) => `${cut(name)}(`;
6
+ const createPrefix = (name) => {
7
+ if (name.includes('('))
8
+ return `${cut(name)}(`;
9
+
10
+ return `${name}(`;
11
+ };
12
+
7
13
  const createSuffix = () => ');\n';
8
14
  const maybeNewline = (a) => a.at(-1) === '\n' ? a : `${a}\n`;
9
15
 
10
- const __json = '__putout_processor_json(__object)';
11
- const __yaml = '__putout_processor_yaml(__object)';
12
- const __filesystem = '__putout_processor_filesystem(__object)';
13
- const __ignore = '__putout_processor_ignore(__array)';
16
+ const __json_name = '__putout_processor_json';
17
+ const __yaml_name = '__putout_processor_yaml';
18
+ const __filesystem_name = '__putout_processor_filesystem';
19
+ const __ignore_name = '__putout_processor_ignore';
14
20
 
15
- const TYPES = [__json, __yaml, __filesystem, __ignore].map(cut);
21
+ const __json = `${__json_name}(__object)`;
22
+ const __yaml = `${__yaml_name}(__object)`;
23
+ const __filesystem = `${__filesystem_name}(__object)`;
24
+ const __ignore = `${__ignore_name}(__array)`;
25
+
26
+ const TYPES = [
27
+ __json_name,
28
+ __yaml_name,
29
+ __filesystem_name,
30
+ __ignore_name,
31
+ ];
16
32
 
17
33
  module.exports.__json = __json;
18
34
  module.exports.__yaml = __yaml;
19
35
  module.exports.__filesystem = __filesystem;
20
36
  module.exports.__ignore = __ignore;
21
37
 
38
+ module.exports.__json_name = __json_name;
39
+ module.exports.__yaml_name = __yaml_name;
40
+ module.exports.__filesystem_name = __filesystem_name;
41
+ module.exports.__ignore_name = __ignore_name;
42
+
22
43
  module.exports.toJS = (source, name = __json) => {
23
44
  const prefix = createPrefix(name);
24
45
  const suffix = createSuffix();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putout/operator-json",
3
- "version": "1.2.0",
3
+ "version": "1.3.0",
4
4
  "type": "commonjs",
5
5
  "author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
6
6
  "description": "🐊Putout operator adds ability to json referenced variables that was not defined",
@@ -42,9 +42,6 @@
42
42
  "supertape": "^8.0.0",
43
43
  "try-catch": "^3.0.0"
44
44
  },
45
- "peerDependencies": {
46
- "putout": ">=33"
47
- },
48
45
  "license": "MIT",
49
46
  "engines": {
50
47
  "node": ">=16"