@openfn/language-collections 0.6.2 → 0.7.0
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/dist/index.cjs +13 -4
- package/dist/index.js +13 -4
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -385,10 +385,19 @@ function set(name, keyGen, values) {
|
|
|
385
385
|
} else {
|
|
386
386
|
const dataArray = Array.isArray(resolvedValues) ? resolvedValues : [resolvedValues];
|
|
387
387
|
const keyGenFn = typeof keyGen === "string" ? () => keyGen : keyGen;
|
|
388
|
-
kvPairs = dataArray.map((value, index) =>
|
|
389
|
-
key
|
|
390
|
-
|
|
391
|
-
|
|
388
|
+
kvPairs = dataArray.map((value, index) => {
|
|
389
|
+
const key = keyGenFn(value, state, index);
|
|
390
|
+
if (typeof key !== "string") {
|
|
391
|
+
const e = new Error("KEYGEN_ERROR");
|
|
392
|
+
e.description = "The key generator function returned a non-string value which is not a valid key";
|
|
393
|
+
e.fix = `The second argument to set() is a key or key-generator function. If you pass a function, make sure the function returns a string (a key). Note that this function is NOT a state reference and does not support lazy state ($)`;
|
|
394
|
+
throw e;
|
|
395
|
+
}
|
|
396
|
+
return {
|
|
397
|
+
key,
|
|
398
|
+
value: JSON.stringify(value)
|
|
399
|
+
};
|
|
400
|
+
});
|
|
392
401
|
}
|
|
393
402
|
while (kvPairs.length) {
|
|
394
403
|
const batch = kvPairs.splice(0, batchSize);
|
package/dist/index.js
CHANGED
|
@@ -360,10 +360,19 @@ function set(name, keyGen, values) {
|
|
|
360
360
|
} else {
|
|
361
361
|
const dataArray = Array.isArray(resolvedValues) ? resolvedValues : [resolvedValues];
|
|
362
362
|
const keyGenFn = typeof keyGen === "string" ? () => keyGen : keyGen;
|
|
363
|
-
kvPairs = dataArray.map((value, index) =>
|
|
364
|
-
key
|
|
365
|
-
|
|
366
|
-
|
|
363
|
+
kvPairs = dataArray.map((value, index) => {
|
|
364
|
+
const key = keyGenFn(value, state, index);
|
|
365
|
+
if (typeof key !== "string") {
|
|
366
|
+
const e = new Error("KEYGEN_ERROR");
|
|
367
|
+
e.description = "The key generator function returned a non-string value which is not a valid key";
|
|
368
|
+
e.fix = `The second argument to set() is a key or key-generator function. If you pass a function, make sure the function returns a string (a key). Note that this function is NOT a state reference and does not support lazy state ($)`;
|
|
369
|
+
throw e;
|
|
370
|
+
}
|
|
371
|
+
return {
|
|
372
|
+
key,
|
|
373
|
+
value: JSON.stringify(value)
|
|
374
|
+
};
|
|
375
|
+
});
|
|
367
376
|
}
|
|
368
377
|
while (kvPairs.length) {
|
|
369
378
|
const batch = kvPairs.splice(0, batchSize);
|