@dcp-ai/create-langchain 2.0.1 → 2.0.2
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/package.json +1 -1
- package/template/index.js +14 -3
package/package.json
CHANGED
package/template/index.js
CHANGED
|
@@ -180,9 +180,20 @@ console.log(`📒 Audit entry recorded: ${auditId}`);
|
|
|
180
180
|
|
|
181
181
|
function canonicalize(obj) {
|
|
182
182
|
if (obj === null || typeof obj !== "object") return JSON.stringify(obj);
|
|
183
|
-
if (Array.isArray(obj))
|
|
184
|
-
|
|
185
|
-
|
|
183
|
+
if (Array.isArray(obj)) {
|
|
184
|
+
// By index: Array#map skips a hole, and join() writes nothing for it or for an undefined.
|
|
185
|
+
// JSON.stringify writes both as null, and so does this.
|
|
186
|
+
const items = [];
|
|
187
|
+
for (let i = 0; i < obj.length; i++) items.push(canonicalize(obj[i]) ?? "null");
|
|
188
|
+
return "[" + items.join(",") + "]";
|
|
189
|
+
}
|
|
190
|
+
// A member with no JSON value (an undefined, a function, a symbol) is left out, as JSON.stringify leaves it out.
|
|
191
|
+
const members = [];
|
|
192
|
+
for (const k of Object.keys(obj).sort()) {
|
|
193
|
+
const v = canonicalize(obj[k]);
|
|
194
|
+
if (v !== undefined) members.push(JSON.stringify(k) + ":" + v);
|
|
195
|
+
}
|
|
196
|
+
return "{" + members.join(",") + "}";
|
|
186
197
|
}
|
|
187
198
|
|
|
188
199
|
function hashPayload(payload) {
|