vue-is-defined 1.0.1 → 1.0.3

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.
@@ -0,0 +1,42 @@
1
+ <p align="center">
2
+ <img src="banner.svg" alt="vue-is-defined" width="100%" />
3
+ </p>
4
+
5
+ <h1 align="center">vue-is-defined</h1>
6
+
7
+ <p align="center">A Vue 3 composition API type guard utility that checks if a ref's value is defined (not null or undefined), with proper TypeScript type narrowing for safe property access.</p>
8
+
9
+ <p align="center">
10
+ <a href="https://www.npmjs.com/package/vue-is-defined"><img src="https://img.shields.io/npm/v/vue-is-defined.svg" alt="npm version" /></a>
11
+ <a href="https://www.npmjs.com/package/vue-is-defined"><img src="https://img.shields.io/npm/dm/vue-is-defined.svg" alt="npm downloads" /></a>
12
+ <a href="https://github.com/vuefrag/vue-is-defined/blob/main/LICENSE"><img src="https://img.shields.io/npm/l/vue-is-defined.svg" alt="license" /></a>
13
+ </p>
14
+
15
+ ## Installation
16
+
17
+ ```bash
18
+ npm install vue-is-defined
19
+ ```
20
+
21
+ ## Usage
22
+
23
+ ```ts
24
+ import { isDefined } from 'vue-is-defined';
25
+ ```
26
+
27
+ Non-nullish checking type guard for Ref.
28
+
29
+ ```ts
30
+ import { isDefined } from 'vue-is-defined'
31
+
32
+ const example = ref(Math.random() ? 'example' : undefined) // Ref<string | undefined>
33
+
34
+ if (isDefined(example))
35
+ example // Ref<string>
36
+ ```
37
+
38
+ > Extracted from [VueUse](https://vueuse.org/) for standalone use.
39
+
40
+ ## License
41
+
42
+ MIT
package/README.md CHANGED
@@ -12,7 +12,6 @@
12
12
  <a href="https://github.com/vuefrag/vue-is-defined/blob/main/LICENSE"><img src="https://img.shields.io/npm/l/vue-is-defined.svg" alt="license" /></a>
13
13
  </p>
14
14
 
15
-
16
15
  ## Installation
17
16
 
18
17
  ```bash
@@ -38,7 +37,6 @@ if (isDefined(example))
38
37
 
39
38
  > Extracted from [VueUse](https://vueuse.org/) for standalone use.
40
39
 
41
-
42
40
  ## License
43
41
 
44
42
  MIT
package/README.npm.md ADDED
@@ -0,0 +1,42 @@
1
+ <p align="center">
2
+ <img src="logo.svg" alt="vue-is-defined" width="180" />
3
+ </p>
4
+
5
+ <h1 align="center">vue-is-defined</h1>
6
+
7
+ <p align="center">A Vue 3 composition API type guard utility that checks if a ref's value is defined (not null or undefined), with proper TypeScript type narrowing for safe property access.</p>
8
+
9
+ <p align="center">
10
+ <a href="https://www.npmjs.com/package/vue-is-defined"><img src="https://img.shields.io/npm/v/vue-is-defined.svg" alt="npm version" /></a>
11
+ <a href="https://www.npmjs.com/package/vue-is-defined"><img src="https://img.shields.io/npm/dm/vue-is-defined.svg" alt="npm downloads" /></a>
12
+ <a href="https://github.com/vuefrag/vue-is-defined/blob/main/LICENSE"><img src="https://img.shields.io/npm/l/vue-is-defined.svg" alt="license" /></a>
13
+ </p>
14
+
15
+ ## Installation
16
+
17
+ ```bash
18
+ npm install vue-is-defined
19
+ ```
20
+
21
+ ## Usage
22
+
23
+ ```ts
24
+ import { isDefined } from 'vue-is-defined';
25
+ ```
26
+
27
+ Non-nullish checking type guard for Ref.
28
+
29
+ ```ts
30
+ import { isDefined } from 'vue-is-defined'
31
+
32
+ const example = ref(Math.random() ? 'example' : undefined) // Ref<string | undefined>
33
+
34
+ if (isDefined(example))
35
+ example // Ref<string>
36
+ ```
37
+
38
+ > Extracted from [VueUse](https://vueuse.org/) for standalone use.
39
+
40
+ ## License
41
+
42
+ MIT
package/banner.svg CHANGED
@@ -10,16 +10,16 @@
10
10
  <rect width="1280" height="640" fill="url(#banner-bg)"/>
11
11
 
12
12
  <!-- Decorative elements -->
13
- <circle cx="1200" cy="100" r="300" fill="#3498db" opacity="0.05"/>
14
- <circle cx="80" cy="540" r="200" fill="#3498db" opacity="0.05"/>
13
+ <circle cx="200" cy="150" r="120" fill="#3498db" opacity="0.06"/>
14
+ <circle cx="1150" cy="500" r="100" fill="#3498db" opacity="0.06"/>
15
15
 
16
16
  <!-- Top accent bar -->
17
17
  <rect x="0" y="0" width="1280" height="8" fill="#3498db"/>
18
18
 
19
- <!-- VueFrag badge -->
19
+ <!-- Vuefrag badge -->
20
20
  <g transform="translate(80, 80)">
21
21
  <rect width="140" height="50" rx="8" fill="#3498db"/>
22
- <text x="70" y="33" text-anchor="middle" font-family="system-ui, -apple-system, sans-serif" font-size="22" font-weight="700" fill="white">VueFrag</text>
22
+ <text x="70" y="33" text-anchor="middle" font-family="system-ui, -apple-system, sans-serif" font-size="22" font-weight="700" fill="white">Vuefrag</text>
23
23
  </g>
24
24
 
25
25
  <!-- Package name -->
@@ -30,7 +30,7 @@
30
30
 
31
31
  <!-- Install command -->
32
32
  <g transform="translate(80, 420)">
33
- <rect width="500" height="60" rx="8" fill="#0f172a"/>
33
+ <rect width="441.6" height="60" rx="8" fill="#0f172a"/>
34
34
  <text x="20" y="40" font-family="ui-monospace, monospace" font-size="24" fill="#94a3b8">npm install</text>
35
35
  <text x="200" y="40" font-family="ui-monospace, monospace" font-size="24" fill="#3498db">vue-is-defined</text>
36
36
  </g>
@@ -41,12 +41,8 @@
41
41
  <text x="79" y="27" text-anchor="middle" font-family="system-ui, -apple-system, sans-serif" font-size="18" fill="#3498db">Utilities</text>
42
42
  </g>
43
43
 
44
- <!-- Vue logo hint -->
45
- <g transform="translate(1080, 480)">
46
- <polygon points="100,20 140,100 60,100" fill="#3498db" opacity="0.3"/>
47
- <polygon points="100,40 125,90 75,90" fill="#3498db" opacity="0.5"/>
44
+ <!-- Category icon (top right corner) -->
45
+ <g>
46
+ <path d="M1040 120l-40 40 40 40" fill="none" stroke="#3498db" stroke-width="12" stroke-linecap="round" stroke-linejoin="round"/><path d="M1120 120l40 40-40 40" fill="none" stroke="#3498db" stroke-width="12" stroke-linecap="round" stroke-linejoin="round"/><line x1="1105" y1="110" x2="1055" y2="190" stroke="#3498db" stroke-width="10" stroke-linecap="round"/>
48
47
  </g>
49
-
50
- <!-- Bottom text -->
51
- <text x="1200" y="600" text-anchor="end" font-family="system-ui, -apple-system, sans-serif" font-size="18" fill="#64748b">Standalone VueUse function</text>
52
48
  </svg>
package/logo.svg CHANGED
@@ -9,9 +9,6 @@
9
9
  <!-- Background -->
10
10
  <rect width="96" height="96" rx="16" fill="url(#bg-grad)"/>
11
11
 
12
- <!-- Decorative corner accent -->
13
- <path d="M96 0v20c0-11.046-8.954-20-20-20H96z" fill="#3498db" opacity="0.12"/>
14
-
15
12
  <!-- Vue badge -->
16
13
  <g transform="translate(8, 8)">
17
14
  <rect width="18" height="9" rx="2" fill="#3498db"/>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vue-is-defined",
3
- "version": "1.0.1",
3
+ "version": "1.0.3",
4
4
  "description": "Vue 3 type guard checking if ref value is not null/undefined",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.mjs",
@@ -19,7 +19,8 @@
19
19
  ],
20
20
  "scripts": {
21
21
  "build": "unbuild",
22
- "prepublishOnly": "npm run build"
22
+ "prepublishOnly": "cp README.npm.md README.md && npm run build",
23
+ "postpublish": "cp README.github.md README.md"
23
24
  },
24
25
  "keywords": [
25
26
  "vue",
@@ -58,4 +59,4 @@
58
59
  "typescript": "^5.0.0",
59
60
  "vue": "^3.4.0"
60
61
  }
61
- }
62
+ }