MCPcopy Create free account
hub / github.com/krasimir/react-in-patterns / escape

Function escape

code/third-party/public/app.js:18215–18226  ·  view source on GitHub ↗

* Escape and wrap key so it is safe to use as a reactid * * @param {string} key to be escaped. * @return {string} the escaped key.

(key)

Source from the content-addressed store, hash-verified

18213 * @return {string} the escaped key.
18214 */
18215function escape(key) {
18216 var escapeRegex = /[=:]/g;
18217 var escaperLookup = {
18218 '=': '=0',
18219 ':': '=2'
18220 };
18221 var escapedString = ('' + key).replace(escapeRegex, function (match) {
18222 return escaperLookup[match];
18223 });
18224
18225 return '$' + escapedString;
18226}
18227
18228/**
18229 * TODO: Test that a single child and an array with one item have the same key

Callers 2

getComponentKeyFunction · 0.70
RFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected