@putout/operator-json 2.2.0 → 3.0.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 +12 -24
  2. package/package.json +11 -13
package/lib/json.js CHANGED
@@ -1,6 +1,4 @@
1
- 'use strict';
2
-
3
- const removeBlankLines = require('remove-blank-lines');
1
+ import removeBlankLines from 'remove-blank-lines';
4
2
 
5
3
  const cut = (a) => a.slice(0, a.indexOf('('));
6
4
  const createPrefix = (name) => {
@@ -13,15 +11,15 @@ const createPrefix = (name) => {
13
11
  const createSuffix = () => ');\n';
14
12
  const maybeNewline = (a) => a.at(-1) === '\n' ? a : `${a}\n`;
15
13
 
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
+ export const __json_name = '__putout_processor_json';
15
+ export const __yaml_name = '__putout_processor_yaml';
16
+ export const __filesystem_name = '__putout_processor_filesystem';
17
+ export const __ignore_name = '__putout_processor_ignore';
20
18
 
21
- const __json = `${__json_name}(__object)`;
22
- const __yaml = `${__yaml_name}(__object)`;
23
- const __filesystem = `${__filesystem_name}(__object)`;
24
- const __ignore = `${__ignore_name}(__array)`;
19
+ export const __json = `${__json_name}(__object)`;
20
+ export const __yaml = `${__yaml_name}(__object)`;
21
+ export const __filesystem = `${__filesystem_name}(__object)`;
22
+ export const __ignore = `${__ignore_name}(__array)`;
25
23
 
26
24
  const TYPES = [
27
25
  __json_name,
@@ -30,24 +28,14 @@ const TYPES = [
30
28
  __ignore_name,
31
29
  ];
32
30
 
33
- module.exports.__json = __json;
34
- module.exports.__yaml = __yaml;
35
- module.exports.__filesystem = __filesystem;
36
- module.exports.__ignore = __ignore;
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
-
43
- module.exports.toJS = (source, name = __json) => {
31
+ export const toJS = (source, name = __json) => {
44
32
  const prefix = createPrefix(name);
45
33
  const suffix = createSuffix();
46
34
 
47
35
  return `${prefix}${source}${suffix}`;
48
36
  };
49
37
 
50
- module.exports.fromJS = (source, name = __json) => {
38
+ export const fromJS = (source, name = __json) => {
51
39
  source = maybeNewline(source);
52
40
  const shortName = cut(name);
53
41
 
@@ -61,7 +49,7 @@ module.exports.fromJS = (source, name = __json) => {
61
49
  return maybeNewline(removeBlankLines(sliced));
62
50
  };
63
51
 
64
- module.exports.isJSON = (source) => {
52
+ export const isJSON = (source) => {
65
53
  for (const type of TYPES) {
66
54
  if (!source.indexOf(type))
67
55
  return true;
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@putout/operator-json",
3
- "version": "2.2.0",
4
- "type": "commonjs",
3
+ "version": "3.0.0",
4
+ "type": "module",
5
5
  "author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
6
- "description": "🐊Putout operator adds ability to json referenced variables that was not defined",
6
+ "description": "🐊Putout operator adds ability to work with json",
7
7
  "homepage": "https://github.com/coderaiser/putout/tree/master/packages/operator-json#readme",
8
8
  "main": "lib/json.js",
9
9
  "release": false,
@@ -11,7 +11,7 @@
11
11
  "changelog": false,
12
12
  "repository": {
13
13
  "type": "git",
14
- "url": "git://github.com/coderaiser/putout.git"
14
+ "url": "git+https://github.com/coderaiser/putout.git"
15
15
  },
16
16
  "scripts": {
17
17
  "test": "madrun test",
@@ -30,21 +30,19 @@
30
30
  "json"
31
31
  ],
32
32
  "devDependencies": {
33
- "@putout/test": "^9.0.0",
34
- "c8": "^9.0.0",
35
- "eslint": "^9.0.0",
33
+ "@putout/test": "^15.0.0",
34
+ "c8": "^10.0.0",
35
+ "eslint": "^10.0.0-alpha.0",
36
36
  "eslint-plugin-n": "^17.0.0",
37
- "eslint-plugin-putout": "^22.0.0",
38
- "lerna": "^6.0.1",
39
- "madrun": "^10.0.0",
37
+ "eslint-plugin-putout": "^29.0.0",
38
+ "madrun": "^12.0.0",
40
39
  "montag": "^1.2.1",
41
40
  "nodemon": "^3.0.1",
42
- "supertape": "^10.0.0",
43
- "try-catch": "^3.0.0"
41
+ "supertape": "^12.0.0"
44
42
  },
45
43
  "license": "MIT",
46
44
  "engines": {
47
- "node": ">=18"
45
+ "node": ">=22"
48
46
  },
49
47
  "publishConfig": {
50
48
  "access": "public"