You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
> [Babel](https://babeljs.io/) plugin to optimize [`obj-str`](../) calls by replacing them with an equivalent unrolled expression.
4
4
5
5
Even though the `obj-str` function is negligible in size over-the-wire, the motivation for this plugin is that transformed expressions [execute almost twice as fast as equivalent calls.](#performance)
@@ -105,10 +105,13 @@ You should not expect this transform should to reduce bundle size. Depending on
105
105
106
106
### Leading Space
107
107
108
-
Direct results from `objstr()` always omit a leading space. This is not the case when y using this transform:
108
+
Direct results from `objstr()` always omit a leading space. This is not the case when using this transform:
109
109
110
110
```js
111
-
objstr({ a:false, foo:true });
111
+
objstr({
112
+
a:false,
113
+
foo:true
114
+
});
112
115
113
116
// transformed:
114
117
(' foo');
@@ -121,15 +124,17 @@ You must ensure that your expression consumers ignore this leading space. A [cla
121
124
Object literals may contain duplicate property names, in which case [the lastly defined value is preserved.](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Object_initializer#Duplicate_property_names)
122
125
123
126
```js
124
-
objstr({ dupe: one, dupe: two });
127
+
objstr({
128
+
dupe: one,
129
+
dupe: two
130
+
});
125
131
126
132
// Transformed:
127
133
''+ (two ?'dupe':'');
128
134
```
129
135
130
-
The example above is transformed properly since the duplicate property names are literal and constant. The plugin does its best to override duplicates by comparing property name expressions, but it's unable to compare equal computed results whose expressions vary.
136
+
The example above is transformed properly since the duplicate property names are literal and constant. The plugin does its best to override duplicates by comparing property name expressions, but it's unable to compare equal computed results whose expressions vary:
0 commit comments