@jasonhk/variable-name
v0.0.2
Published
A utility package consists functions that used to retrieve the name of variables.
Downloads
5
Readme
@jasonhk/variable-name
A utility package consists functions that used to retrieve the name of variables.
Installation
Node.js
$ npm install @jasonhk/variable-name
Usage
Load the Library
CommonJS
const { getVariableName, getVariableNames } = require("@jasonhk/variable-name");
ES2015 Modules
import { getVariableName, getVariableNames } from "@jasonhk/variable-name";
Using the Library
Get the name of a variable:
const variable = 1337;
// Should return "variable"
getVariableName({ variable });
Get the names of a list of variables:
const object = { property: 1337 };
const { property } = object;
// Should return ["object", "property"]
getVariableNames(
[
{ object },
{ property },
]);
License
Copyright © 2019 Jason Kwok. Licensed under the MIT License.