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

Function escape

code/communication/public/app.js:19017–19028  ·  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

19015 * @return {string} the escaped key.
19016 */
19017function escape(key) {
19018 var escapeRegex = /[=:]/g;
19019 var escaperLookup = {
19020 '=': '=0',
19021 ':': '=2'
19022 };
19023 var escapedString = ('' + key).replace(escapeRegex, function (match) {
19024 return escaperLookup[match];
19025 });
19026
19027 return '$' + escapedString;
19028}
19029
19030/**
19031 * 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