MCPcopy Index your code
hub / github.com/parse-community/parse-server / stringify

Function stringify

src/LiveQuery/QueryTools.js:74–93  ·  view source on GitHub ↗

* Deterministically turns an object into a string. Disregards ordering

(object)

Source from the content-addressed store, hash-verified

72 * Deterministically turns an object into a string. Disregards ordering
73 */
74function stringify(object): string {
75 if (typeof object !== 'object' || object === null) {
76 if (typeof object === 'string') {
77 return '"' + object.replace(/\|/g, '%|') + '"';
78 }
79 return object + '';
80 }
81 if (Array.isArray(object)) {
82 var copy = object.map(stringify);
83 copy.sort();
84 return '[' + copy.join(',') + ']';
85 }
86 var sections = [];
87 var keys = Object.keys(object);
88 keys.sort();
89 for (var k = 0; k < keys.length; k++) {
90 sections.push(stringify(keys[k]) + ':' + stringify(object[keys[k]]));
91 }
92 return '{' + sections.join(',') + '}';
93}
94
95/**
96 * Generate a hash from a query, with unique fields for columns, values, order,

Callers 1

queryHashFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected