@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 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 for better tree-shaking or the entire package (not recommended). On the docs site, each tab below imports from its own package and checks one small call:
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
- Import only the functions you use. Importing the entire package with `import * as Arr from "@tolki/arr"` is not recommended: it can pull every function into your bundle, even the ones you never call, which makes the bundles larger. Importing individual functions lets your build ship only the code that runs.
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
- However, if you are working on a backend project where bundle size is not a concern, importing the entire package can be more convenient.
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