@putout/operator-json 3.1.0 → 3.2.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/README.md +8 -0
- package/lib/json.js +4 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -87,6 +87,14 @@ isJSON(`hello({"hello": "world"});`);
|
|
|
87
87
|
false;
|
|
88
88
|
```
|
|
89
89
|
|
|
90
|
+
### `isJSONJGrop(source: string)`
|
|
91
|
+
|
|
92
|
+
```js
|
|
93
|
+
isJSONGroup(`__putout_processor_toml({"hello": "world"});`);
|
|
94
|
+
// returns
|
|
95
|
+
true;
|
|
96
|
+
```
|
|
97
|
+
|
|
90
98
|
### `toJS(source: string, name?: string)`;
|
|
91
99
|
|
|
92
100
|
```js
|
package/lib/json.js
CHANGED
|
@@ -25,6 +25,7 @@ export const __ignore = `${__ignore_name}(__array)`;
|
|
|
25
25
|
|
|
26
26
|
const TYPES = [
|
|
27
27
|
__json_name,
|
|
28
|
+
__toml_name,
|
|
28
29
|
__yaml_name,
|
|
29
30
|
__filesystem_name,
|
|
30
31
|
__ignore_name,
|
|
@@ -51,7 +52,9 @@ export const fromJS = (source, name = __json) => {
|
|
|
51
52
|
return maybeNewline(removeBlankLines(sliced));
|
|
52
53
|
};
|
|
53
54
|
|
|
54
|
-
export const isJSON = (source) =>
|
|
55
|
+
export const isJSON = (source) => !source.indexOf(__json_name);
|
|
56
|
+
export const isTOML = (source) => !source.indexOf(__toml_name);
|
|
57
|
+
export const isJSONGroup = (source) => {
|
|
55
58
|
for (const type of TYPES) {
|
|
56
59
|
if (!source.indexOf(type))
|
|
57
60
|
return true;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@putout/operator-json",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.2.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
|
|
6
6
|
"description": "🐊Putout operator adds ability to work with json",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"c8": "^10.0.0",
|
|
35
35
|
"eslint": "^10.0.0-alpha.0",
|
|
36
36
|
"eslint-plugin-n": "^17.0.0",
|
|
37
|
-
"eslint-plugin-putout": "^
|
|
37
|
+
"eslint-plugin-putout": "^30.0.0",
|
|
38
38
|
"madrun": "^12.0.0",
|
|
39
39
|
"montag": "^1.2.1",
|
|
40
40
|
"nodemon": "^3.0.1",
|