MCPcopy Create free account
hub / github.com/nodejs/node / keyToString

Function keyToString

deps/v8/tools/clusterfuzz/js_fuzzer/mutators/object_mutator.js:22–31  ·  view source on GitHub ↗

* Turn the key of an object property into a string literal.

(key)

Source from the content-addressed store, hash-verified

20 * Turn the key of an object property into a string literal.
21 */
22function keyToString(key) {
23 if (babelTypes.isNumericLiteral(key)) {
24 return babelTypes.stringLiteral(key.value.toString());
25 }
26 if (babelTypes.isIdentifier(key)) {
27 return babelTypes.stringLiteral(key.name);
28 }
29 // Already a string literal.
30 return key;
31}
32
33class ObjectMutator extends mutator.Mutator {
34 get visitor() {

Callers 1

stringifyKeyMethod · 0.70

Calls 1

toStringMethod · 0.45

Tested by

no test coverage detected