MCPcopy
hub / github.com/apache/echarts / isMethodShorthandNotAccurate

Function isMethodShorthandNotAccurate

test/lib/testHelper.js:2778–2796  ·  view source on GitHub ↗

* Simple implementation for detecting method shorthand, such as, * ({abc() { return 1; }}).abc is a method shorthand and needs to * be serialized as `{abc() { return 1; }}` rather than `{abc: abc() { return 1; }}`. * Those cases can be detected: * ({abc() {

(fnStr, fnName, objKey)

Source from the content-addressed store, hash-verified

2776 * ({[some]() { return 1; }})[some] expected: IS_SHORTHAND
2777 */
2778 function isMethodShorthandNotAccurate(fnStr, fnName, objKey) {
2779 // Assert fnStr, fnName, objKey is a string.
2780 if (fnName !== objKey) {
2781 return false;
2782 }
2783 var matched = fnStr.match(/^\s*(async\s+)?(function\s*)?(\*\s*)?([a-zA-Z$_][a-zA-Z0-9$_]*)?\s*\(/);
2784 if (!matched) {
2785 return false;
2786 }
2787 if (matched[2]) { // match 'function'
2788 return false;
2789 }
2790 // May enhanced by /(['"])(?:(?=(\\?))\2.)*?\1/; to match literal string,
2791 // such as "ab-c", "a\nc". But this simple impl does not cover it.
2792 if (!matched[4] || matched[4] !== objKey) { // match "maybe function name"
2793 return false;
2794 }
2795 return true;
2796 }
2797
2798 };
2799

Callers 1

doPrintFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…