@putout/operator-json 1.2.1 → 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.
- package/lib/json.js +26 -10
- package/package.json +1 -1
package/lib/json.js
CHANGED
|
@@ -3,27 +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) =>
|
|
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
|
|
11
|
-
const
|
|
12
|
-
const
|
|
13
|
-
const
|
|
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';
|
|
20
|
+
|
|
21
|
+
const __json = `${__json_name}(__object)`;
|
|
22
|
+
const __yaml = `${__yaml_name}(__object)`;
|
|
23
|
+
const __filesystem = `${__filesystem_name}(__object)`;
|
|
24
|
+
const __ignore = `${__ignore_name}(__array)`;
|
|
14
25
|
|
|
15
26
|
const TYPES = [
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
]
|
|
27
|
+
__json_name,
|
|
28
|
+
__yaml_name,
|
|
29
|
+
__filesystem_name,
|
|
30
|
+
__ignore_name,
|
|
31
|
+
];
|
|
21
32
|
|
|
22
33
|
module.exports.__json = __json;
|
|
23
34
|
module.exports.__yaml = __yaml;
|
|
24
35
|
module.exports.__filesystem = __filesystem;
|
|
25
36
|
module.exports.__ignore = __ignore;
|
|
26
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
|
+
|
|
27
43
|
module.exports.toJS = (source, name = __json) => {
|
|
28
44
|
const prefix = createPrefix(name);
|
|
29
45
|
const suffix = createSuffix();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@putout/operator-json",
|
|
3
|
-
"version": "1.
|
|
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",
|