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.
- package/README.github.md +49 -0
- package/README.md +13 -14
- package/README.npm.md +49 -0
- package/banner.svg +9 -13
- package/logo.svg +0 -1
- package/package.json +4 -2
package/README.github.md
ADDED
|
@@ -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="
|
|
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 {
|
|
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
|
-
|
|
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="
|
|
14
|
-
<circle cx="
|
|
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
|
-
<!--
|
|
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">
|
|
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
|
|
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="
|
|
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
|
-
<!--
|
|
45
|
-
<g
|
|
46
|
-
<
|
|
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
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vue-computed-eager",
|
|
3
|
-
"version": "1.0.
|
|
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
|
-
"
|
|
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",
|