@putout/plugin-types 6.2.0 → 7.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.
package/README.md CHANGED
@@ -45,6 +45,7 @@ Supported assertions:
45
45
  - `isString`;
46
46
  - `isEmptyString`;
47
47
  - `isNumber`;
48
+ - `isNumberLike` - checks if `a` can be convert to `Number` from `String`;
48
49
  - `isFn`;
49
50
  - `isBool`;
50
51
  - `isObject`;
@@ -60,13 +61,18 @@ Supported assertions:
60
61
 
61
62
  ```js
62
63
  isString('hello');
64
+ isNumber('a' - 5);
63
65
  ```
64
66
 
65
67
  ### ✅ Example of correct code
66
68
 
67
69
  ```js
68
70
  const isString = (a) => typeof a === 'string';
71
+ const isNumber = (a) => !Number.isNaN(a) && typeof a === 'number';
72
+
69
73
  isString('hello');
74
+
75
+ isNumber('a' - 5);
70
76
  ```
71
77
 
72
78
  When you want to skip some declaration use `dismiss`:
@@ -3,7 +3,8 @@
3
3
  module.exports.declare = () => ({
4
4
  isString: `const isString = (a) => typeof a === 'string'`,
5
5
  isEmptyString: `const isEmptyString = (a) => !a && isString(a)`,
6
- isNumber: `const isNumber = (a) => typeof a === 'number'`,
6
+ isNumber: `const isNumber = (a) => !Number.isNaN(a) && typeof a === 'number'`,
7
+ isNumberLike: `const isNumberLike = (a, b = Number(a)) => isNumber(b)`,
7
8
  isFn: `const isFn = (a) => typeof a === 'function'`,
8
9
  isBool: `const isBool = (a) => typeof a === 'boolean'`,
9
10
  isObject: `const isObject = (a) => a && typeof a === 'object'`,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putout/plugin-types",
3
- "version": "6.2.0",
3
+ "version": "7.0.0",
4
4
  "type": "commonjs",
5
5
  "author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
6
6
  "description": "🐊Putout plugin adds ability to transform code related to types assertions",
@@ -31,19 +31,20 @@
31
31
  "types"
32
32
  ],
33
33
  "devDependencies": {
34
+ "@putout/eslint-flat": "^2.0.0",
34
35
  "@putout/plugin-putout": "*",
35
36
  "@putout/test": "^11.0.0",
36
37
  "c8": "^10.0.0",
37
38
  "eslint": "^9.0.0",
38
39
  "eslint-plugin-n": "^17.0.0",
39
- "eslint-plugin-putout": "^23.0.0",
40
+ "eslint-plugin-putout": "^24.0.0",
40
41
  "lerna": "^6.0.1",
41
42
  "madrun": "^10.0.0",
42
43
  "montag": "^1.2.1",
43
44
  "nodemon": "^3.0.1"
44
45
  },
45
46
  "peerDependencies": {
46
- "putout": ">=37"
47
+ "putout": ">=38"
47
48
  },
48
49
  "license": "MIT",
49
50
  "engines": {