@putout/engine-parser 13.0.1 → 13.1.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/parse.js +10 -2
  2. package/package.json +4 -4
package/lib/parse.js CHANGED
@@ -1,11 +1,14 @@
1
1
  'use strict';
2
2
 
3
- const toBabel = require('estree-to-babel');
3
+ const {estreeToBabel} = require('estree-to-babel');
4
4
  const customParser = require('./custom-parser');
5
5
  const {tryThrowWithReason} = require('./try-throw-with-reason');
6
6
  const {assign} = Object;
7
+ const isString = (a) => typeof a === 'string';
7
8
 
8
9
  module.exports = (source, options) => {
10
+ check(source);
11
+
9
12
  const {
10
13
  parser,
11
14
  printer = 'putout',
@@ -32,7 +35,7 @@ const getParser = ({parser = 'babel', isTS, isJSX, printer}) => ({
32
35
  convertParens: false,
33
36
  });
34
37
 
35
- const ast = toBabel(customParser(source, parser, {
38
+ const ast = estreeToBabel(customParser(source, parser, {
36
39
  isTS,
37
40
  isJSX,
38
41
  printer,
@@ -41,3 +44,8 @@ const getParser = ({parser = 'babel', isTS, isJSX, printer}) => ({
41
44
  return ast;
42
45
  },
43
46
  });
47
+
48
+ function check(source) {
49
+ if (!isString(source))
50
+ throw Error(`☝️ Looks like type of 'source' is not 'string', but '${typeof source}'`);
51
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putout/engine-parser",
3
- "version": "13.0.1",
3
+ "version": "13.1.0",
4
4
  "type": "commonjs",
5
5
  "author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
6
6
  "description": "🐊Putout parser",
@@ -36,7 +36,7 @@
36
36
  "@putout/babel": "^3.0.0",
37
37
  "@putout/printer": "^14.0.0",
38
38
  "align-spaces": "^2.0.0",
39
- "estree-to-babel": "^10.0.0",
39
+ "estree-to-babel": "^11.0.0",
40
40
  "nano-memoize": "^3.0.11",
41
41
  "once": "^1.4.0",
42
42
  "try-catch": "^3.0.0"
@@ -56,14 +56,14 @@
56
56
  "eslint-plugin-putout": "^26.0.0",
57
57
  "espree": "^10.0.0",
58
58
  "esprima": "^4.0.1",
59
- "hermes-parser": "^0.26.0",
59
+ "hermes-parser": "^0.28.0",
60
60
  "just-camel-case": "^6.2.0",
61
61
  "madrun": "^11.0.0",
62
62
  "mock-require": "^3.0.3",
63
63
  "montag": "^1.0.0",
64
64
  "nodemon": "^3.0.1",
65
65
  "putout": "*",
66
- "supertape": "^10.0.0",
66
+ "supertape": "^11.0.3",
67
67
  "tenko": "^2.0.0"
68
68
  },
69
69
  "license": "MIT",