Skip to content
master
Go to file
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
src
 
 
 
 
 
 
 
 
 
 
 
 
 
 

README.md

babel-plugin-nameof-js

The plugin works with variables and object members.

Setup:

npm install --save-dev babel-plugin-nameof-js
yarn add --dev babel-plugin-nameof-js

In your .babelrc:

"plugins": ["nameof-js"]

Usage:

const myVar = "I love 🦄";
const nameOfMyVar = nameof(myVar); // Turns into "myVar";

const myObject = {
  myMember: true
};
const nameOfMyMember = nameof(myObject.myMember); // Turns into "myMember";



// Works with all identifiers.
class MyClass {
}

// Outputs: What's my classes name? MyClass
consolge.log(`What's my classes name? ${nameof(MyClass)}`);

About

Babel plugin that allows for C# like obtaining of string from variable or member names.

Resources

License

Packages

No packages published
You can’t perform that action at this time.