assign-gingerly 0.0.87 → 0.0.89

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/DX/emojis.js CHANGED
@@ -51,6 +51,7 @@ export const akaMethods = {
51
51
  '🚨': 'error',
52
52
  '🤱': 'appendChild',
53
53
  '😣': 'focus',
54
+ '🌐': 'toLocaleString',
54
55
  //'🧩': 'includes'
55
56
  };
56
57
  export const aka = {
package/DX/emojis.ts CHANGED
@@ -53,6 +53,7 @@ export const akaMethods = {
53
53
  '🚨': 'error',
54
54
  '🤱': 'appendChild',
55
55
  '😣': 'focus',
56
+ '🌐': 'toLocaleString',
56
57
  //'🧩': 'includes'
57
58
  };
58
59
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "assign-gingerly",
3
- "version": "0.0.87",
3
+ "version": "0.0.89",
4
4
  "description": "This package provides a utility function for carefully merging one object into another.",
5
5
  "homepage": "https://github.com/bahrus/assign-gingerly#readme",
6
6
  "bugs": {
@@ -145,12 +145,23 @@ function navigatePath(source, parts, withMethods, permissionProcessor) {
145
145
  while (i < parts.length) {
146
146
  if (current == null)
147
147
  return current;
148
- const part = parts[i];
149
- if (isAllowedMethod(part, withMethods, permissionProcessor)) {
148
+ const rawPart = parts[i];
149
+ // A trailing | forces a zero-argument method call: 'toLocaleString|' calls
150
+ // toLocaleString() without consuming the next segment. Only applies to
151
+ // names listed in withMethods; otherwise | is part of a literal key.
152
+ const isZeroArg = rawPart.endsWith('|')
153
+ && isAllowedMethod(rawPart.slice(0, -1), withMethods, permissionProcessor);
154
+ const part = isZeroArg ? rawPart.slice(0, -1) : rawPart;
155
+ if (isZeroArg || isAllowedMethod(part, withMethods, permissionProcessor)) {
150
156
  const method = current[part];
151
157
  if (typeof method === 'function') {
152
158
  const nextPart = parts[i + 1];
153
- if (nextPart !== undefined && !isAllowedMethod(nextPart, withMethods, permissionProcessor)) {
159
+ // Consecutive methods (including a |-marked next segment) mean a
160
+ // zero-arg call; otherwise the next segment is the string argument.
161
+ const nextIsMethod = nextPart !== undefined
162
+ && (isAllowedMethod(nextPart, withMethods, permissionProcessor)
163
+ || (nextPart.endsWith('|') && isAllowedMethod(nextPart.slice(0, -1), withMethods, permissionProcessor)));
164
+ if (!isZeroArg && nextPart !== undefined && !nextIsMethod) {
154
165
  current = method.call(current, nextPart);
155
166
  i += 2;
156
167
  }
@@ -165,7 +176,7 @@ function navigatePath(source, parts, withMethods, permissionProcessor) {
165
176
  }
166
177
  }
167
178
  else {
168
- current = current[part];
179
+ current = current[rawPart];
169
180
  i++;
170
181
  }
171
182
  }
@@ -182,13 +182,25 @@ function navigatePath(
182
182
  while (i < parts.length) {
183
183
  if (current == null) return current;
184
184
 
185
- const part = parts[i];
185
+ const rawPart = parts[i];
186
186
 
187
- if (isAllowedMethod(part, withMethods, permissionProcessor)) {
187
+ // A trailing | forces a zero-argument method call: 'toLocaleString|' calls
188
+ // toLocaleString() without consuming the next segment. Only applies to
189
+ // names listed in withMethods; otherwise | is part of a literal key.
190
+ const isZeroArg = rawPart.endsWith('|')
191
+ && isAllowedMethod(rawPart.slice(0, -1), withMethods, permissionProcessor);
192
+ const part = isZeroArg ? rawPart.slice(0, -1) : rawPart;
193
+
194
+ if (isZeroArg || isAllowedMethod(part, withMethods, permissionProcessor)) {
188
195
  const method = current[part];
189
196
  if (typeof method === 'function') {
190
197
  const nextPart = parts[i + 1];
191
- if (nextPart !== undefined && !isAllowedMethod(nextPart, withMethods, permissionProcessor)) {
198
+ // Consecutive methods (including a |-marked next segment) mean a
199
+ // zero-arg call; otherwise the next segment is the string argument.
200
+ const nextIsMethod = nextPart !== undefined
201
+ && (isAllowedMethod(nextPart, withMethods, permissionProcessor)
202
+ || (nextPart.endsWith('|') && isAllowedMethod(nextPart.slice(0, -1), withMethods, permissionProcessor)));
203
+ if (!isZeroArg && nextPart !== undefined && !nextIsMethod) {
192
204
  current = method.call(current, nextPart);
193
205
  i += 2;
194
206
  } else {
@@ -200,7 +212,7 @@ function navigatePath(
200
212
  i++;
201
213
  }
202
214
  } else {
203
- current = current[part];
215
+ current = current[rawPart];
204
216
  i++;
205
217
  }
206
218
  }