flow-remove-types 2.160.2 → 2.163.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 (3) hide show
  1. package/README.md +24 -24
  2. package/jest.js +14 -0
  3. package/package.json +3 -2
package/README.md CHANGED
@@ -1,13 +1,11 @@
1
- flow-remove-types
2
- =================
1
+ # flow-remove-types
3
2
 
4
3
  [![npm](https://img.shields.io/npm/v/flow-remove-types.svg?maxAge=86400)](https://www.npmjs.com/package/flow-remove-types)
5
- [![Build Status](https://img.shields.io/travis/flowtype/flow-remove-types.svg?style=flat&label=travis&branch=master)](https://travis-ci.org/flowtype/flow-remove-types)
6
4
 
7
5
  Turn your JavaScript with [Flow](https://flowtype.org/) type annotations into
8
6
  standard JavaScript in an instant with no configuration and minimal setup.
9
7
 
10
- [Flow](https://flowtype.org/) provides static type checking to JavaScript which
8
+ [Flow](https://flow.org/) provides static type checking to JavaScript which
11
9
  can both help find and detect bugs long before code is deployed and can make
12
10
  code easier to read and more self-documenting. The Flow tool itself only reads
13
11
  and analyzes code. Running code with Flow type annotations requires first
@@ -20,23 +18,22 @@ every browser.
20
18
  `flow-remove-types` is a faster, simpler, zero-configuration alternative with
21
19
  minimal dependencies for super-fast `npm install` time.
22
20
 
23
-
24
- ## Get Started!
21
+ ## Getting Started
25
22
 
26
23
  Use the command line:
27
24
 
28
- ```
25
+ ```bash
29
26
  npm install --global flow-remove-types
30
27
  ```
31
28
 
32
- ```
29
+ ```bash
33
30
  flow-remove-types --help
34
31
  flow-remove-types input.js > output.js
35
32
  ```
36
33
 
37
34
  Or the JavaScript API:
38
35
 
39
- ```
36
+ ```bash
40
37
  npm install flow-remove-types
41
38
  ```
42
39
 
@@ -51,7 +48,7 @@ fs.writeFileSync('output.js', output.toString());
51
48
 
52
49
  When using the `flow-remove-types` script, be sure [not to direct the output to itself](https://superuser.com/questions/597244/why-does-redirecting-the-output-of-a-file-to-itself-produce-a-blank-file)!
53
50
 
54
- ## Use in Build Systems:
51
+ ## Use in Build Systems
55
52
 
56
53
  **Rollup:** [`rollup-plugin-flow`](https://github.com/leebyron/rollup-plugin-flow)
57
54
 
@@ -61,19 +58,24 @@ When using the `flow-remove-types` script, be sure [not to direct the output to
61
58
 
62
59
  **Gulp:** [`gulp-flow-remove-types`](https://github.com/wain-pc/gulp-flow-remove-types)
63
60
 
64
-
65
61
  ## Use with existing development tools
66
62
 
67
- * ESLint: [eslint-plugin-flowtype](https://github.com/gajus/eslint-plugin-flowtype)
68
- * Mocha: `mocha -r flow-remove-types/register`
63
+ * ESLint: [eslint-plugin-flowtype](https://github.com/gajus/eslint-plugin-flowtype)
64
+ * Mocha: `mocha -r flow-remove-types/register`
65
+ * Jest: Add to your config:
69
66
 
67
+ ```js
68
+ transform: {
69
+ "^.+\\.js(?:\\.flow)?$": "flow-remove-types/jest"
70
+ }
71
+ ```
70
72
 
71
73
  ## Use `flow-node`
72
74
 
73
75
  Wherever you use `node` you can substitute `flow-node` and have a super fast
74
76
  flow-types aware evaluator or REPL.
75
77
 
76
- ```
78
+ ```bash
77
79
  $ flow-node
78
80
  > var x: number = 42
79
81
  undefined
@@ -110,12 +112,11 @@ expressions. All files are included by default except those found in the
110
112
  require('flow-remove-types/register')({ includes: /\/custom_path\// })
111
113
  ```
112
114
 
113
- > #### Don't use the require hook in packages distributed on NPM
115
+ > **Don't use the require hook in packages distributed on NPM**
114
116
  > As always, don't forget to use `flow-remove-types` to compile files before distributing
115
117
  > your code on npm, as using the require hook affects the whole runtime and not
116
118
  > just your module and may hurt the runtime performance of code that includes it.
117
119
 
118
-
119
120
  ## Dead-Simple Transforms
120
121
 
121
122
  When `flow-remove-types` removes Flow types, it replaces them with whitespace.
@@ -176,7 +177,7 @@ export class MyClass extends SomeClass {
176
177
 
177
178
  Rather not have the whitespace? Pass the `--pretty` flag to remove the whitespace.
178
179
 
179
- ```
180
+ ```bash
180
181
  flow-remove-types --pretty --sourcemaps source.js
181
182
  ```
182
183
 
@@ -193,18 +194,17 @@ var sourceMap = output.generateMap();
193
194
  fs.writeFileSync('output.js.map', JSON.stringify(sourceMap));
194
195
  ```
195
196
 
196
-
197
197
  ## Performance
198
198
 
199
199
  > *NOTE*: These timings are for `flow-remove-types` v1.
200
200
 
201
- ### Install:
201
+ ### Install
202
202
 
203
203
  Installing via `npm` from an empty project:
204
204
 
205
205
  **flow-remove-types:**
206
206
 
207
- ```
207
+ ```bash
208
208
  time npm install flow-remove-types
209
209
 
210
210
  real 0m3.193s
@@ -214,7 +214,7 @@ sys 0m0.775s
214
214
 
215
215
  **Babel:**
216
216
 
217
- ```
217
+ ```bash
218
218
  time npm install babel-cli babel-plugin-transform-flow-strip-types
219
219
 
220
220
  real 0m23.200s
@@ -222,13 +222,13 @@ user 0m10.395s
222
222
  sys 0m4.238s
223
223
  ```
224
224
 
225
- ### Transform:
225
+ ### Transform
226
226
 
227
227
  Transforming a directory of 20 files of 100 lines each:
228
228
 
229
229
  **flow-remove-types:**
230
230
 
231
- ```
231
+ ```bash
232
232
  time flow-remove-types src/ --out-dir dest/
233
233
 
234
234
  real 0m0.431s
@@ -238,7 +238,7 @@ sys 0m0.068s
238
238
 
239
239
  **Babel:**
240
240
 
241
- ```
241
+ ```bash
242
242
  time babel src/ --out-dir dest/
243
243
 
244
244
  real 0m1.074s
package/jest.js ADDED
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Copyright (c) Facebook, Inc. and its affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+
8
+ var flowRemoveTypes = require('./index');
9
+
10
+ module.exports = {
11
+ process: function(src, filename) {
12
+ return flowRemoveTypes(src).toString();
13
+ }
14
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "flow-remove-types",
3
- "version": "2.160.2",
3
+ "version": "2.163.0",
4
4
  "description": "Removes Flow type annotations from JavaScript files with speed and simplicity.",
5
5
  "author": {
6
6
  "name": "Flow Team",
@@ -17,6 +17,7 @@
17
17
  },
18
18
  "files": [
19
19
  "index.js",
20
+ "jest.js",
20
21
  "register.js",
21
22
  "flow-remove-types",
22
23
  "flow-node",
@@ -43,7 +44,7 @@
43
44
  "es6"
44
45
  ],
45
46
  "dependencies": {
46
- "flow-parser": "^0.160.2",
47
+ "flow-parser": "^0.163.0",
47
48
  "pirates": "^3.0.2",
48
49
  "vlq": "^0.2.1"
49
50
  },