@tolki/data 1.0.2 → 1.0.4
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 +13 -3
- package/dist/data.d.ts +94 -98
- package/dist/data.d.ts.map +1 -1
- package/dist/data.js +354 -24
- package/dist/dispatch.d.ts +27 -4
- package/dist/dispatch.d.ts.map +1 -1
- package/dist/dispatch.js +14 -6
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/package.json +7 -9
package/README.md
CHANGED
|
@@ -48,7 +48,7 @@ The return types follow the same split. `dataGet` is typed as the two packages'
|
|
|
48
48
|
|
|
49
49
|
### Importing the Package
|
|
50
50
|
|
|
51
|
-
You can import individual functions
|
|
51
|
+
You can import individual functions or the package as a namespace. Both tree-shake the same way. On the docs site, each tab below imports from its own package and checks one small call:
|
|
52
52
|
|
|
53
53
|
```js [@tolki/data]
|
|
54
54
|
import { dataGet } from "@tolki/data";
|
|
@@ -60,9 +60,19 @@ dataGet({ desk: { price: 100 } }, "desk.price");
|
|
|
60
60
|
// => 100
|
|
61
61
|
```
|
|
62
62
|
|
|
63
|
-
|
|
63
|
+
Importing the package as a namespace, as in `import * as Arr from "@tolki/arr"`, tree-shakes the same way when you read its members by name, such as `Arr.get(...)`: your bundle holds only the members you use. Passing the namespace object around, or reading a computed member such as `Arr[name]`, keeps every function. See [Bundling and Tree-Shaking](https://tolki.abe.dev/tree-shaking.html#namespace-imports).
|
|
64
64
|
|
|
65
|
-
|
|
65
|
+
### Bundling
|
|
66
|
+
|
|
67
|
+
A helper call whose result nothing uses drops out of your bundle in Vite (Rolldown), Rollup, webpack and Rspack, because the helpers are marked as free of side effects. This holds for the `data*` helpers as it does for `@tolki/arr` and `@tolki/obj`, including a call at the top level of a module.
|
|
68
|
+
|
|
69
|
+
esbuild doesn't follow that mark across files, so it keeps the call unless the call site says it is safe to remove (see [Bundling and Tree-Shaking](https://tolki.abe.dev/tree-shaking.html)):
|
|
70
|
+
|
|
71
|
+
```typescript
|
|
72
|
+
export const prices = /* @__PURE__ */ dataPluck(products, "price");
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
`pop`, `shift`, `unshift` and `splice`, and `dataPop`, `dataShift`, `dataUnshift` and `dataSplice`, can change the data you pass, so a call to them is always kept.
|
|
66
76
|
|
|
67
77
|
### How to read the utilities list
|
|
68
78
|
|