is-what 5.5.0 → 5.5.2

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
@@ -1,9 +1,9 @@
1
1
  # is What? 🙉
2
2
 
3
- <a href="https://www.npmjs.com/package/is-what"><img src="https://img.shields.io/npm/v/is-what.svg" alt="Total Downloads"></a>
4
- <a href="https://www.npmjs.com/package/is-what"><img src="https://img.shields.io/npm/dw/is-what.svg" alt="Latest Stable Version"></a>
3
+ <a href="https://www.npmjs.com/package/is-what"><img src="https://img.shields.io/npm/v/is-what.svg" alt="npm version"></a>
4
+ <a href="https://www.npmjs.com/package/is-what"><img src="https://img.shields.io/npm/dw/is-what.svg" alt="npm downloads/week"></a>
5
5
 
6
- Very simple & small JS type check functions. It's fully TypeScript supported!
6
+ Tiny, zero-dependency JavaScript type guards with first-class TypeScript support. Tree-shakable ESM by default.
7
7
 
8
8
  ```
9
9
  npm i is-what
@@ -34,9 +34,9 @@ is-what is really easy to use, and most functions work just like you'd expect.
34
34
  import { isString, isDate, isPlainObject } from 'is-what'
35
35
  ```
36
36
 
37
- 1. First I'll go over the simple functions available. Only `isNumber` and `isDate` have special treatment.
38
- 2. After that I'll talk about working with Objects (plain objects vs class instances etc.).
39
- 3. Lastly I'll talk about TypeScript implementation
37
+ 1. Below are the most common functions (with a special note on `isNumber` and `isDate`).
38
+ 2. Then we cover Objects (plain objects vs class instances).
39
+ 3. Finally we show TypeScript narrowing and `isObjectLike<T>`.
40
40
 
41
41
  ### Simple type check functions
42
42
 
@@ -177,7 +177,7 @@ isAnyObject(specialObject) // returns true
177
177
  getType(specialObject) // returns 'Object'
178
178
  ```
179
179
 
180
- > Please note that `isPlainObject` will only return `true` for normal plain JavaScript objects.
180
+ > Please note that `isPlainObject` returns `true` only for plain JavaScript objects.
181
181
 
182
182
  ### Getting and checking for specific types
183
183
 
@@ -191,8 +191,7 @@ getType('') // returns 'String'
191
191
  isType('', String) // returns true
192
192
  ```
193
193
 
194
- If you just want to make sure your object _inherits_ from a particular class or
195
- `toStringTag` value, you can use `isInstanceOf()` like this:
194
+ If you want to make sure your object inherits from a particular class or matches a `toStringTag` value, use `isInstanceOf()`:
196
195
 
197
196
  ```js
198
197
  import { isInstanceOf } from 'is-what'
@@ -211,7 +210,7 @@ is-what makes TypeScript know the type during if statements. This means that a c
211
210
  function isNumber(payload: unknown): payload is number {
212
211
  // return boolean
213
212
  }
214
- // As you can see above, all functions return a boolean for JavaScript, but pass the payload type to TypeScript.
213
+ // All functions return a boolean for JavaScript, but act as type guards for TypeScript.
215
214
 
216
215
  // usage example:
217
216
  function fn(payload: string | number): number {
@@ -235,7 +234,7 @@ if (isPlainObject(payload) && payload.id) return payload.id
235
234
 
236
235
  ### isObjectLike
237
236
 
238
- If you want more control over what kind of interface/type is casted when checking for objects.
237
+ If you want more control over what kind of interface/type is cast when checking for objects:
239
238
 
240
239
  To cast to a specific type while checking for `isAnyObject`, can use `isObjectLike<T>`:
241
240
 
@@ -6,7 +6,7 @@ import { isString } from './isString.js';
6
6
  export function isHexDecimal(payload, length) {
7
7
  if (!isString(payload))
8
8
  return false;
9
- if (!/^[0-9a-fA-F]+$/.test(payload))
9
+ if (!/^[0-9a-fA-F]+$/u.test(payload))
10
10
  return false;
11
11
  return length === undefined || payload.length === length;
12
12
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "is-what",
3
- "version": "5.5.0",
3
+ "version": "5.5.2",
4
4
  "description": "JS type check (TypeScript supported) functions like `isPlainObject() isArray()` etc. A simple & small integration.",
5
5
  "type": "module",
6
6
  "sideEffects": false,
@@ -11,21 +11,14 @@
11
11
  "engines": {
12
12
  "node": ">=18"
13
13
  },
14
- "scripts": {
15
- "test": "vitest run",
16
- "lint": "tsc --noEmit && oxlint",
17
- "build": "del-cli dist && tsc",
18
- "build:docs": "typedoc",
19
- "release": "npm run lint && npm run build && np --no-publish"
20
- },
21
14
  "devDependencies": {
22
- "@cycraft/eslint": "^0.4.4",
23
- "@cycraft/tsconfig": "^0.1.2",
15
+ "bumpp": "^12.3.0",
24
16
  "del-cli": "^7.0.0",
25
- "np": "^10.2.0",
26
- "oxlint": "^1.16.0",
27
- "typedoc": "^0.28.13",
28
- "vitest": "^3.2.4"
17
+ "oxfmt": "^0.70.0",
18
+ "oxlint": "^1.85.0",
19
+ "typedoc": "^0.28.20",
20
+ "typescript": "^5.9.3",
21
+ "vitest": "^5.0.2"
29
22
  },
30
23
  "files": [
31
24
  "dist"
@@ -59,5 +52,13 @@
59
52
  "url": "https://github.com/mesqueeb/is-what.git"
60
53
  },
61
54
  "homepage": "https://github.com/mesqueeb/is-what#readme",
62
- "bugs": "https://github.com/mesqueeb/is-what/issues"
63
- }
55
+ "bugs": "https://github.com/mesqueeb/is-what/issues",
56
+ "scripts": {
57
+ "test": "vitest run",
58
+ "lint": "tsc --noEmit && oxlint && oxfmt --check",
59
+ "build": "del-cli dist && tsc",
60
+ "build:docs": "typedoc",
61
+ "release": "pnpm run lint && pnpm run build && pnpm test && bumpp --no-push --all && pnpm publish --no-git-checks && npx jsr publish && git push --follow-tags && gh release create $(git describe --tags --abbrev=0) --generate-notes --notes \"$(git log --pretty='- %s %h' $(git describe --tags --abbrev=0 HEAD~1 2>/dev/null || git rev-list --max-parents=0 HEAD)..HEAD~1)\"",
62
+ "format": "oxfmt"
63
+ }
64
+ }