vue-computed-eager 1.0.5 → 1.0.6

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,49 @@
1
+ <p align="center">
2
+ <img src="banner.svg" alt="vue-computed-eager" width="100%" />
3
+ </p>
4
+
5
+ <h1 align="center">vue-computed-eager</h1>
6
+
7
+ <p align="center">A Vue 3 composition API utility that creates computed properties which evaluate immediately when dependencies change, rather than lazily on access. Ideal for simple boolean checks with rarely-changing values. Note: Vue 3.4+ has built-in optimization making this less necessary.</p>
8
+
9
+ <p align="center">
10
+ <a href="https://www.npmjs.com/package/vue-computed-eager"><img src="https://img.shields.io/npm/v/vue-computed-eager.svg" alt="npm version" /></a>
11
+ <a href="https://www.npmjs.com/package/vue-computed-eager"><img src="https://img.shields.io/npm/dm/vue-computed-eager.svg" alt="npm downloads" /></a>
12
+ <a href="https://github.com/vuefrag/vue-computed-eager/blob/main/LICENSE"><img src="https://img.shields.io/npm/l/vue-computed-eager.svg" alt="license" /></a>
13
+ </p>
14
+
15
+ ## Installation
16
+
17
+ ```bash
18
+ npm install vue-computed-eager
19
+ ```
20
+
21
+ ## Usage
22
+
23
+ ```ts
24
+ import { computedEager } from 'vue-computed-eager';
25
+ ```
26
+
27
+ Eager computed without lazy evaluation.
28
+
29
+ Learn more at [Vue: When a computed property can be the wrong tool](https://dev.to/linusborg/vue-when-a-computed-property-can-be-the-wrong-tool-195j).
30
+
31
+ - Use `computed()` when you have a complex calculation going on, which can actually profit from caching and lazy evaluation and should only be (re-)calculated if really necessary.
32
+ - Use `computedEager()` when you have a simple operation, with a rarely changing return value – often a boolean.
33
+
34
+ ```ts
35
+ import { computedEager } from 'vue-computed-eager'
36
+
37
+ const todos = ref([])
38
+ const hasOpenTodos = computedEager(() => !!todos.length)
39
+
40
+ console.log(hasOpenTodos.value) // false
41
+ toTodos.value.push({ title: 'Learn Vue' })
42
+ console.log(hasOpenTodos.value) // true
43
+ ```
44
+
45
+ > Extracted from [VueUse](https://vueuse.org/) for standalone use.
46
+
47
+ ## License
48
+
49
+ MIT
package/README.md CHANGED
@@ -1,5 +1,5 @@
1
1
  <p align="center">
2
- <img src="logo.svg" alt="vue-computed-eager" width="180" />
2
+ <img src="banner.svg" alt="vue-computed-eager" width="100%" />
3
3
  </p>
4
4
 
5
5
  <h1 align="center">vue-computed-eager</h1>
@@ -12,7 +12,6 @@
12
12
  <a href="https://github.com/vuefrag/vue-computed-eager/blob/main/LICENSE"><img src="https://img.shields.io/npm/l/vue-computed-eager.svg" alt="license" /></a>
13
13
  </p>
14
14
 
15
-
16
15
  ## Installation
17
16
 
18
17
  ```bash
@@ -22,29 +21,29 @@ npm install vue-computed-eager
22
21
  ## Usage
23
22
 
24
23
  ```ts
25
- import { ref } from 'vue'
24
+ import { computedEager } from 'vue-computed-eager';
25
+ ```
26
+
27
+ Eager computed without lazy evaluation.
28
+
29
+ Learn more at [Vue: When a computed property can be the wrong tool](https://dev.to/linusborg/vue-when-a-computed-property-can-be-the-wrong-tool-195j).
30
+
31
+ - Use `computed()` when you have a complex calculation going on, which can actually profit from caching and lazy evaluation and should only be (re-)calculated if really necessary.
32
+ - Use `computedEager()` when you have a simple operation, with a rarely changing return value – often a boolean.
33
+
34
+ ```ts
26
35
  import { computedEager } from 'vue-computed-eager'
27
36
 
28
37
  const todos = ref([])
29
38
  const hasOpenTodos = computedEager(() => !!todos.length)
30
39
 
31
40
  console.log(hasOpenTodos.value) // false
32
- todos.value.push({ title: 'Learn Vue' })
41
+ toTodos.value.push({ title: 'Learn Vue' })
33
42
  console.log(hasOpenTodos.value) // true
34
43
  ```
35
44
 
36
- ## When to use
37
-
38
- - Use `computed()` when you have a complex calculation that profits from caching and lazy evaluation.
39
- - Use `computedEager()` when you have a simple operation with a rarely changing return value (often a boolean).
40
-
41
- Learn more: [Vue: When a computed property can be the wrong tool](https://dev.to/linusborg/vue-when-a-computed-property-can-be-the-wrong-tool-195j)
42
-
43
- **Note:** If you are using Vue 3.4+, standard `computed` has been optimized to avoid triggering effects when the value hasn't changed. See [vuejs/core#5912](https://github.com/vuejs/core/pull/5912).
44
-
45
45
  > Extracted from [VueUse](https://vueuse.org/) for standalone use.
46
46
 
47
-
48
47
  ## License
49
48
 
50
49
  MIT
package/README.npm.md ADDED
@@ -0,0 +1,49 @@
1
+ <p align="center">
2
+ <img src="logo.svg" alt="vue-computed-eager" width="180" />
3
+ </p>
4
+
5
+ <h1 align="center">vue-computed-eager</h1>
6
+
7
+ <p align="center">A Vue 3 composition API utility that creates computed properties which evaluate immediately when dependencies change, rather than lazily on access. Ideal for simple boolean checks with rarely-changing values. Note: Vue 3.4+ has built-in optimization making this less necessary.</p>
8
+
9
+ <p align="center">
10
+ <a href="https://www.npmjs.com/package/vue-computed-eager"><img src="https://img.shields.io/npm/v/vue-computed-eager.svg" alt="npm version" /></a>
11
+ <a href="https://www.npmjs.com/package/vue-computed-eager"><img src="https://img.shields.io/npm/dm/vue-computed-eager.svg" alt="npm downloads" /></a>
12
+ <a href="https://github.com/vuefrag/vue-computed-eager/blob/main/LICENSE"><img src="https://img.shields.io/npm/l/vue-computed-eager.svg" alt="license" /></a>
13
+ </p>
14
+
15
+ ## Installation
16
+
17
+ ```bash
18
+ npm install vue-computed-eager
19
+ ```
20
+
21
+ ## Usage
22
+
23
+ ```ts
24
+ import { computedEager } from 'vue-computed-eager';
25
+ ```
26
+
27
+ Eager computed without lazy evaluation.
28
+
29
+ Learn more at [Vue: When a computed property can be the wrong tool](https://dev.to/linusborg/vue-when-a-computed-property-can-be-the-wrong-tool-195j).
30
+
31
+ - Use `computed()` when you have a complex calculation going on, which can actually profit from caching and lazy evaluation and should only be (re-)calculated if really necessary.
32
+ - Use `computedEager()` when you have a simple operation, with a rarely changing return value – often a boolean.
33
+
34
+ ```ts
35
+ import { computedEager } from 'vue-computed-eager'
36
+
37
+ const todos = ref([])
38
+ const hasOpenTodos = computedEager(() => !!todos.length)
39
+
40
+ console.log(hasOpenTodos.value) // false
41
+ toTodos.value.push({ title: 'Learn Vue' })
42
+ console.log(hasOpenTodos.value) // true
43
+ ```
44
+
45
+ > Extracted from [VueUse](https://vueuse.org/) for standalone use.
46
+
47
+ ## License
48
+
49
+ MIT
package/banner.svg CHANGED
@@ -10,27 +10,27 @@
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="#42b883" opacity="0.05"/>
14
- <circle cx="80" cy="540" r="200" fill="#42b883" opacity="0.05"/>
13
+ <circle cx="200" cy="150" r="120" fill="#42b883" opacity="0.06"/>
14
+ <circle cx="1150" cy="500" r="100" fill="#42b883" opacity="0.06"/>
15
15
 
16
16
  <!-- Top accent bar -->
17
17
  <rect x="0" y="0" width="1280" height="8" fill="#42b883"/>
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="#42b883"/>
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 -->
26
26
  <text x="80" y="280" font-family="system-ui, -apple-system, sans-serif" font-size="72" font-weight="700" fill="white">vue-computed-eager</text>
27
27
 
28
28
  <!-- Description -->
29
- <text x="80" y="360" font-family="system-ui, -apple-system, sans-serif" font-size="32" fill="#94a3b8">Vue 3 eager computed that evaluates immediately on depend...</text>
29
+ <text x="80" y="360" font-family="system-ui, -apple-system, sans-serif" font-size="32" fill="#94a3b8">Vue 3 eager computed that evaluates immediately on dependency change</text>
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="499.2" 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="#42b883">vue-computed-eager</text>
36
36
  </g>
@@ -41,12 +41,8 @@
41
41
  <text x="86" y="27" text-anchor="middle" font-family="system-ui, -apple-system, sans-serif" font-size="18" fill="#42b883">Reactivity</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="#42b883" opacity="0.3"/>
47
- <polygon points="100,40 125,90 75,90" fill="#42b883" opacity="0.5"/>
44
+ <!-- Category icon (top right corner) -->
45
+ <g>
46
+ <circle cx="1080" cy="150" r="60" fill="none" stroke="#42b883" stroke-width="15"/><circle cx="1080" cy="150" r="25" fill="#42b883"/><path d="M1000 150h-20M1160 150h20M1080 70v-20M1080 230v20" stroke="#42b883" 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,7 +9,6 @@
9
9
  <!-- Background -->
10
10
  <rect width="96" height="96" rx="16" fill="url(#bg-grad)"/>
11
11
 
12
-
13
12
  <!-- Vue badge -->
14
13
  <g transform="translate(8, 8)">
15
14
  <rect width="18" height="9" rx="2" fill="#42b883"/>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vue-computed-eager",
3
- "version": "1.0.5",
3
+ "version": "1.0.6",
4
4
  "description": "Vue 3 eager computed that evaluates immediately on dependency change",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.mjs",
@@ -19,7 +19,9 @@
19
19
  ],
20
20
  "scripts": {
21
21
  "build": "unbuild",
22
- "prepublishOnly": "npm run build"
22
+ "prepare": "cp README.github.md README.md 2>/dev/null || true",
23
+ "prepublishOnly": "cp README.npm.md README.md && npm run build",
24
+ "postpublish": "cp README.github.md README.md"
23
25
  },
24
26
  "keywords": [
25
27
  "vue",